This is the mail archive of the gdb-patches@sourceware.org mailing list for the GDB project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: [doc patch] coding style: 0 vs. NULL + [patch] Code cleanup: skip.c


On Tue, 11 Dec 2012 02:53:43 +0100, Joel Brobecker wrote:
> > But GDB (IMO fortunately) already uses everywhere properly NULL vs. 0.
> [...]
> > I have added a new rule for the coding style for it.
> 
> So, just to be certain, this also includes testing for NULL, right?

I did not think about this case.


> Code like...
> 
>         first = strstr (big, small);
>         if (first)
> 
> ... should be written instead:
> 
>         if (first != NULL)

I find '(first)' OK myself but IIRC Pedro recently in some mail wrote he likes
more an explicit NULL comparison there.  Although I cannot find his mail now
so I hope I do not put these words in Pedro's mouth.

>From my point of view:
OK         if (first)
not great  if (!first)
OK         if (first == NULL)
OK         if (first != NULL)
BAD        if (first == 0)
BAD        if (first != 0)

There can be probably just disagreements about the first two cases, whether
they should be forbidden or not, I do not mind.


Thanks,
Jan


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]