for ( i=0, ptr=array, bError=FALSE; i<10 && !bError; i++, ptr++)
If I was the reviewer of that code it would never make it into production or even source control. Just because you can, does not mean it's a good idea to rape a for loop.
I even demand changing simple thing like:
if (0 < x)
to
if (x > 0)
just for the sake of general easy readability. It's all about people maintaining the code in the future not wasting time because it was written by someone thinking it was cool to write in that style.
Hmm, actually, this has a place in defensive programming, but for the test of equality.
Consider
if (x == 1)
A common typo is
if (x = 1)
which compiles without warning (on most compilers I use anyway). This code does something totally different and usually is undesired.
If you change this to:
if (1 == x)
instead, the typo
if (1 = x)
declares an error, as you cannot assign x to a constant. So once you get into this habit,
if (0 < x)
is a natural extension, and good practice to reducing coding errors.
No, no, no.
Any decent C compiler will warn you that you have an assignment used as a truth value if you write things like
if (x = 1).
GCC and Clang ail warn you, and that covers ARM, AVR, MIPS (PiC32), MSP430 and others.
If you are programming in C:
Turn on all the compiler warnings.
Pass your code through splint
[url=http://www.splint.org/]http://www.splint.org/[/url]
If possible check it with Valgrind
[url=http://valgrind.org/]http://valgrind.org/[/url]
Thanks