lkml.org 
[lkml]   [2004]   [Jul]   [10]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
/
SubjectRe: [PATCH] Use NULL instead of integer 0 in security/selinux/
From
Date
It was because

if (0 = i)

will give an error where you obviously meant '=='. It prevents
accidental "assignment in conditional context".

Tim

On Sat, 2004-07-10 at 16:52, Paul Jackson wrote:
> (off-topic alert)
>
> > if (0 != i)
>
> Does anyone know of the origins of writing such tests this way, rather
> than:
>
> if (i != 0)
>
> I read the first as testing whether "0" has a certain property, which is
> a silly thing to test, since the properties of "0" are rather constant.
>
> The second form I read as testing a property of "i" - much more
> interesting. Logically, the same, of course. Just a question of which
> form is more idiomatic.
>
> Back in the days when it was Ken, Dennis and Brian, not K & R, I don't
> recall seeing the first form used much. Even now I see _zero_ matches
> on "if (0 " in kernel or mm - only in arch, drivers, net, scripts, and
> sound (with a single time.h exception).
>
> If I were Linus, I'd vote the first form off the island. Then again,
> if I were Linus, you would never have heard of Linux ;).
-
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:04    [W:1.820 / U:0.212 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site