Re: [PATCH] ppp: don't use 0 in pointer context

2006-02-09 Thread James Carlson
Paul Mackerras writes: > > And the solution is to treat it as a boolean instead?! I'm not sure > > which is more ugly. > > > > Why wouldn't explicit comparison against NULL be the preferred fix? > > I just think this whole "you shouldn't compare a pointer to 0" thing > is completely silly, Inde

Re: [PATCH] ppp: don't use 0 in pointer context

2006-02-08 Thread Herbert Xu
On Wed, Feb 08, 2006 at 03:58:59PM -0800, David S. Miller wrote: > From: Herbert Xu <[EMAIL PROTECTED]> > Date: Thu, 09 Feb 2006 10:49:37 +1100 > > > The difference between gcc -pedantic and sparse is that it doesn't > > warn about obviously correct cases like p != 0 or p = 0. > > So obviously co

Re: [PATCH] ppp: don't use 0 in pointer context

2006-02-08 Thread Randy.Dunlap
On Wed, 8 Feb 2006, David S. Miller wrote: > From: Herbert Xu <[EMAIL PROTECTED]> > Date: Thu, 09 Feb 2006 10:49:37 +1100 > > > The difference between gcc -pedantic and sparse is that it doesn't > > warn about obviously correct cases like p != 0 or p = 0. > > So obviously correct that you left out

Re: [PATCH] ppp: don't use 0 in pointer context

2006-02-08 Thread David S. Miller
From: Herbert Xu <[EMAIL PROTECTED]> Date: Thu, 09 Feb 2006 10:49:37 +1100 > The difference between gcc -pedantic and sparse is that it doesn't > warn about obviously correct cases like p != 0 or p = 0. So obviously correct that you left out an equals sign in the second case :-) - To unsubscribe

Re: [PATCH] ppp: don't use 0 in pointer context

2006-02-08 Thread Herbert Xu
Alexey Dobriyan <[EMAIL PROTECTED]> wrote: > > Oh, and for the record: current sparse from Linus doesn't warn about > this. Slightly modified sparse warns. Bugs which were uncovered by > more or less trivial and slightly broken sparse patch [1] are: > >[PATCH] dscc4: fix dscc4_init_dummy_

Re: [PATCH] ppp: don't use 0 in pointer context

2006-02-08 Thread Paul Mackerras
Alexey Dobriyan writes: > The fact that they can be represented by the same bit patterns is > irrelevant. Indeed it is. The fact that the C standard says that "0" is a valid representation for a null pointer in C source code *is* relevant, though. That is in fact something that *wasn't* in K&R

Re: [PATCH] ppp: don't use 0 in pointer context

2006-02-08 Thread Herbert Xu
On Wed, Feb 08, 2006 at 02:47:12PM -0800, David S. Miller wrote: > From: David Stevens <[EMAIL PROTECTED]> > Date: Wed, 8 Feb 2006 14:45:08 -0800 > > > Why would sparse complain about this? 0 is a well-defined > > pointer value (the only value guaranteed to be by the language). > > Becaus

Re: [PATCH] ppp: don't use 0 in pointer context

2006-02-08 Thread Alexey Dobriyan
On Wed, Feb 08, 2006 at 02:45:08PM -0800, David Stevens wrote: > [EMAIL PROTECTED] wrote on 02/08/2006 02:19:20 PM: > > > James Carlson <[EMAIL PROTECTED]> wrote: > > > Alexey Dobriyan writes: > > >> - if (ap == 0) > > >> + if (!ap) > > > > > > And the solution is to treat it as a boolean

Re: [PATCH] ppp: don't use 0 in pointer context

2006-02-08 Thread Rick Jones
David S. Miller wrote: From: David Stevens <[EMAIL PROTECTED]> Date: Wed, 8 Feb 2006 14:45:08 -0800 Why would sparse complain about this? 0 is a well-defined pointer value (the only value guaranteed to be by the language). Because sparse goes beyond the standards and tries to catch c

Re: [PATCH] ppp: don't use 0 in pointer context

2006-02-08 Thread Paul Mackerras
David S. Miller writes: > Because sparse goes beyond the standards and tries to > catch cases that usually end up being bugs. When has a pointer comparison with an explicit "0" ever caused a bug? Paul. - To unsubscribe from this list: send the line "unsubscribe netdev" in the body of a message t

Re: [PATCH] ppp: don't use 0 in pointer context

2006-02-08 Thread David S. Miller
From: David Stevens <[EMAIL PROTECTED]> Date: Wed, 8 Feb 2006 14:45:08 -0800 > Why would sparse complain about this? 0 is a well-defined > pointer value (the only value guaranteed to be by the language). Because sparse goes beyond the standards and tries to catch cases that usually end up

Re: [PATCH] ppp: don't use 0 in pointer context

2006-02-08 Thread Paul Mackerras
James Carlson writes: > Alexey Dobriyan writes: > > - if (ap == 0) > > + if (!ap) > > And the solution is to treat it as a boolean instead?! I'm not sure > which is more ugly. > > Why wouldn't explicit comparison against NULL be the preferred fix? I just think this whole "you shouldn't com

Re: [PATCH] ppp: don't use 0 in pointer context

2006-02-08 Thread David Stevens
[EMAIL PROTECTED] wrote on 02/08/2006 02:19:20 PM: > James Carlson <[EMAIL PROTECTED]> wrote: > > Alexey Dobriyan writes: > >> - if (ap == 0) > >> + if (!ap) > > > > And the solution is to treat it as a boolean instead?! I'm not sure > > which is more ugly. > > Treating it as a boolean

Re: [PATCH] ppp: don't use 0 in pointer context

2006-02-08 Thread Roland Dreier
James> And the solution is to treat it as a boolean instead?! I'm James> not sure which is more ugly. James> Why wouldn't explicit comparison against NULL be the James> preferred fix? "if (ptr)" and "if (!ptr)" are the preferred idiom for testing whether a pointer is NULL. What

Re: [PATCH] ppp: don't use 0 in pointer context

2006-02-08 Thread Herbert Xu
James Carlson <[EMAIL PROTECTED]> wrote: > Alexey Dobriyan writes: >> - if (ap == 0) >> + if (!ap) > > And the solution is to treat it as a boolean instead?! I'm not sure > which is more ugly. Treating it as a boolean looks good to me. It's better than the existing code because it shuts

Re: [PATCH] ppp: don't use 0 in pointer context

2006-02-08 Thread James Carlson
Alexey Dobriyan writes: > - if (ap == 0) > + if (!ap) And the solution is to treat it as a boolean instead?! I'm not sure which is more ugly. Why wouldn't explicit comparison against NULL be the preferred fix? -- James Carlson 42.703N 71.076W <[EMAIL PROTECTED]> - To un

[PATCH] ppp: don't use 0 in pointer context

2006-02-08 Thread Alexey Dobriyan
Signed-off-by: Alexey Dobriyan <[EMAIL PROTECTED]> --- ppp is the biggest offender. drivers/net/ppp_async.c | 34 ++-- drivers/net/ppp_generic.c | 128 +++--- drivers/net/ppp_synctty.c | 26 - drivers/net/pppoe.c |2 4 fil