Re: [PATCH] Use NULL instead of integer 0 in security/selinux/
From: Alexandre Oliva
Date: Sat Jul 10 2004 - 17:08:12 EST
On Jul 10, 2004, Eyal Lebedinsky <eyal@xxxxxxxxxxxxxx> wrote:
> Very much yes. I will go further and say that only boolean
> variables should use the above syntax. Using
> if (i)
> where 'i' is a non-boolean integer instead of
> if (0 != i)
> makes me question what the programmer wanted. Since integers
> do not have clear names for true/false logic (booleans usually
> will be called something like 'have_brain" etc.) the simple
> 'if (i)' may just as well be a miswritten 'if (!i)' - and I
> caught a few of these bugs in my time.
So how about pushing for writing (i == 1) if i is boolean, to be
clearer? It's often nice to be able to tell whether a boolean
variable is strict 0/1 or just zero/non-zero, when you're thinking of
switching to 3+-state logic. But guess what, i == 1 is far less
efficient than i != 0 on many architectures. It's an unfortunate
trade-off you have to make in this case.
--
Alexandre Oliva http://www.ic.unicamp.br/~oliva/
Red Hat Compiler Engineer aoliva@{redhat.com, gcc.gnu.org}
Free Software Evangelist oliva@{lsd.ic.unicamp.br, gnu.org}
-
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/