Re: (0 == foo), rather than (foo == 0)

From: Andreas Schwab
Date: Thu Mar 11 2004 - 10:21:30 EST


mru@xxxxxx (Måns Rullgård) writes:

> Stefan Smietanowski <stesmi@xxxxxxxxxx> writes:
>
>> Hi Linus.
>>
>>> The warning should be there whether there are parenthesis or not,
>>> and it should state that you should have an explicit inequality
>>> expression. So if you have
>>> if (a = b) ...
>>> and you really _mean_ that, then the way to write it sanely is to
>>> just write it as
>>> if ((a = b) != 0)
>>> ...
>>> which makes it much clearer what you're actually doing.
>>
>> Or actually change it to
>>
>> a = b;
>> if (a)
>
> That doesn't work with while().

But this works: while (a = b, a != 0).
(not that it is any better readable :-) ).

Andreas.

--
Andreas Schwab, SuSE Labs, schwab@xxxxxxx
SuSE Linux AG, Maxfeldstraße 5, 90409 Nürnberg, Germany
Key fingerprint = 58CA 54C7 6D53 942B 1756 01D3 44D5 214B 8276 4ED5
"And now for something completely different."
-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/