Re: [PATCH] Use NULL instead of integer 0 in security/selinux/
From: Tim Wright
Date: Sat Jul 10 2004 - 19:17:45 EST
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@xxxxxxxxxxxxxxx
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/