lkml.org 
[lkml]   [2004]   [Mar]   [10]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
/
DateThu, 11 Mar 2004 05:40:12 +0100
FromStefan Smietanowski <>
SubjectRe: (0 == foo), rather than (foo == 0)
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's even more clear in my opinion. The other still feels a bit iffy
but maybe that's just me.

// Stefan
-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/

\
 
 \ /
  Last update: 2005-03-22 14:01    [from the cache]
©2003-2010