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
    Linus> I really don't see the point of complaining about the
Linus> fixes. There's just _no_ way to say that "0" is more
Linus> readable than "NULL" in any of the cases. I dare you -
Linus> show _one_ case where a 0/NULL patch was wrong or even
Linus> remotely debatable. I dare you.

I don't know if any of the 0/NULL kernel patches were of this form,
but I've seen sparse complain about this in my code and found it
somewhat annoying. I think the following is at least remotely debatable...

Suppose I have

struct foo {
int a;
int b;
};

then sparse is perfectly happy with someone clearing out a struct foo
like this:

struct foo bar = { 0 };

but then if someone changes struct foo to be

struct foo {
void *x;
int a;
int b;
};

sparse will complain about that initialization, and all of the fixes
I can think of seem somewhat worse than the original to me:

struct foo bar = { NULL }; /* will I have to change this
again if struct foo changes? */

or

struct foo bar = { .a = 0 }; /* why do I have to name a member? */

or

struct foo bar;
memset(&bar, 0, sizeof bar); /* WRONG if a null pointer is not
the bit pattern 0 */

- Roland
-
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.179 / U:0.216 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site