Coding style updates

Stefan (metze) Metzmacher metze at samba.org
Fri Oct 19 11:10:16 GMT 2007


-----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

> 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.

> Not a big deal though and the other changes are much of an improvement,
> so +1.

thanks!

metze
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.5 (GNU/Linux)
Comment: Using GnuPG with SUSE - http://enigmail.mozdev.org

iD8DBQFHGJCYm70gjA5TCD8RAt7XAKDEYxbCeGSgXIond1i2r0P4JzpmAwCfUY/L
2hxsAf8LVja0m5sprAYz5n0=
=U5AJ
-----END PGP SIGNATURE-----


More information about the samba-technical mailing list