Coding style updates

Michael Adam ma at sernet.de
Mon Oct 22 21:13:24 GMT 2007


Gerald (Jerry) Carter wrote:
> Jelmer Vernooij wrote:
> 
> >> - -1.  We had this discussion before as well.  Mainly I don't
> >> like the "this one *or* that one".  Pick one.  We previously
> >> decided on if ((x=malloc) == NULL) format.
> > This seems inconsistent. If you favor "if (ptr)" over "if (ptr !=
> > NULL)", it should also be "if (!(x=malloc(...)))".
> 
> True.  But that was the original discussion.  I can be convinced
> but I don't think having two ways to check for NULL pointer
> assignment is a good idea.  So you guys decide which one we go with.
> 
> The argument for "if ((x=malloc) == NULL" was that it was clearer
> about what you intended to check.  And "if (!x)" is already clear
> enough.

Hmm, sorry, I am confused: what was the original choice?
"if (ptr)" or "if (ptr != NULL)" ?

I personally would vote for the more explicit "if (ptr != NULL)"
over the more idiomatic "if (ptr)". (Generally, not only for the
malloc case.)

Michael

-- 
Michael Adam <ma at sernet.de>
SerNet GmbH, Bahnhofsallee 1b, 37081 Göttingen
phone: +49-551-370000-0, fax: +49-551-370000-9
AG Göttingen, HRB 2816, GF: Dr. Johannes Loxen
http://www.SerNet.DE, mailto: Info @ SerNet.DE


More information about the samba-technical mailing list