Coding style updates
Gerald (Jerry) Carter
jerry at samba.org
Sun Oct 21 13:15:39 GMT 2007
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1
Michael Adam wrote:
> 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.
- -1. We already had this discussion on list a long time ago.
> But I guess both should be "allowed"...
I disagree. We should consolidate on one idiom.
hat's the point of a coding style guideline.
>
>>> 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.
+1. This has been the unspoken rule for a long time
I believe.
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.4 (MingW32)
Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org
iD8DBQFHG1D7IR7qMdg1EfYRAiOnAKCKg4PoDTt9UlXpT4qe2Clw9hSpMQCgnjAA
P2O3ubp2HSVibqLQkwmb0OE=
=qq9u
-----END PGP SIGNATURE-----
More information about the samba-technical
mailing list