That's the oldest gotcha in the C book. Welcome to the club
The problem is that "if (a=b)" is a perfectly legal statement. It just that it doesn't do what the programmer expected.
but presumably the same run time code
therefore I think it's fair to say that it's not good coding practice