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
On Jul 10, 2004, Eyal Lebedinsky <eyal@eyal.emu.id.au> 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@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:0.167 / U:5.788 seconds]
©2003-2018 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site