Coding style updates

Michael Adam ma at sernet.de
Fri Oct 19 12:27:15 GMT 2007


On Fri, Oct 19, 2007 at 01:10:16PM +0200, Stefan (metze) Metzmacher wrote:
> -----BEGIN PGP SIGNED MESSAGE-----
> Hash: SHA1
> 
> Jelmer Vernooij schrieb:
> > Am Freitag, den 19.10.2007, 10:39 +0200 schrieb Stefan (metze) Metzmacher:
> >> +
> >> +These should only be use together with return, goto, exit() or free():
> >> +
> >> +	if (x == 1) return 0;
> >> +
> >> +	if (some_long_function_name_check(x))
> >> +		goto failed;
> >> +
> >> +	if (ptr) free(ptr);
> >> +
> > I prefer an explicit "!= NULL" in the expression when checking a pointer
> I think both (ptr) and (ptr != NULL) are fine

I am in favour of (ptr != NULL) as I generally like it more explicit.
But I guess both should be "allowed"...

> > and always having the action on the next line.
> 
> I assume it's because you use python a lot and this works there:
>     if z == 1:
>         print >> outfile
>         print >> outfile, 'string'
> 
> But it's very different from this in C:
> 
>     if (z == 1)
> 	printf("\n");
> 	printf("%s\n", "string");
> 
> So I'm for explict braces when it's not all in one line.

For that reason, I prefer *always* putting braces, even
when there is just one return or goto command.
If braces do have to be ommitted, then the command should
at least be put in one line with the condition, as Metze 
proposed.

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