[Freeipa-devel] Suggested additions to codding standard page on freeIPA wiki.

Stephen Gallagher sgallagh at redhat.com
Mon Nov 3 13:31:34 UTC 2008


-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1


> if the function declaration does not fit 80 chars, put arguments after
> the first on following lines and indent them to start after the "("
> 
> Example:
> int very_long_function_name_that_makes_arguments_not_fit_80(int foo,
>                                                             int bar)
> {
> 
> 
- -1

I'm a bigger fan of using the two-indent approach to this problem

int very_long_function_name_that_makes_arguments_not_fit_80(
        int foo, int bar,
        void (*some_other_long_function_name)(int baz))
{



Other general points:
I tend to agree with the "always include a forward declaration" approach
to coding.

I disagree with the "mortal sin" of typedefing pointers in one case:
I believe it's perfectly sane to
typedef int (*long_function_name)(int foo, int bar, char *baz) foobar_fn

Yes you lose the obvious pointer qualification, but foobar_fn is a LOT
easier to add to subsequent argument lists than repeating the function
pointer declaration.

Hungarian notation should be grounds for revocation of commit privilege
on FreeIPA.

- From John:
> Actually it would be really nice we could agree on a basic helper
> library for implementing common data structures and operations. FWIW
> I've found glib to be pretty useful and widely available. But I'm sure
> others will have strong feelings about the merits of any such given
> library so let the flames begin  :-)

The problem with using a common helper library is that our goal on the
client-side is to be able to support as many client OSes as possible.
Glib is not available on all platforms, so we're avoiding it. If you
happen to know of a helper library that is available on all flavors of
Linux, Solaris, HP-UX, AIX, OSX and BSD, then we'll talk :)

- From Martin:
> Don't use binary not (!) in tests, unless you test for a boolean:
> good: if (*str = '\0')
> bad:  if (!*str)

I don't really see a problem with the approach
struct some_struct foo;
foo = malloc(sizeof(struct some_struct));
if (!foo) {
    /* Handle OOM condition */
}

!foo is at least as readable as (NULL == foo), if not more so.

One might be able to make a stronger argument about this use when
testing function arguments.

- --

- --------------------
Stephen Gallagher
RHCE 804006346421761
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.9 (GNU/Linux)
Comment: Using GnuPG with Fedora - http://enigmail.mozdev.org

iEYEARECAAYFAkkO/TMACgkQc7MaxVic+2oVigCfd8j+HMMNeVOBUrO3I6TfxQ+O
XacAn1lAcGFknnFuIbtNUvdZEozzkUjD
=4mrr
-----END PGP SIGNATURE-----




More information about the Freeipa-devel mailing list