Miscellaneous coding practice changes

ghudson@MIT.EDU ghudson at MIT.EDU
Tue Dec 1 16:30:16 EST 2009


Here are some minor coding practice changes we've discussed at team
meetings:

1. Amend the namespace section to recommend against using the krb5_ or
krb5int_ prefixes for static functions.  This allows static functions
to have shorter names and avoids some kinds of confusion (particularly
when a krb5_ prefix makes the function look like an API function).

It can be convenient when debugging to avoid duplicate names for
static functions, but in my experience this problem is rare and easily
worked around.

It's already a pretty common practice in our code base to use short
descriptive names for static functions; the amendment would basically
give developers a green light to remove krb5_ or krb5int_ prefixes in
cases where they are used.

2. When calling a function through a function pointer, the practices
document currently requires that you explicitly dereference the
pointer ("(*funcptr)(args)" instead of just "funcptr(args)").  Relax
this restriction to avoid the explicit dereference when the function
pointer is a member of a structure.  That is, we would write
"vtable.funcptr(args)" or "vtable->funcptr(args)" instead of
"(*vtable->funcptr)(args)".

The rationale here is that "funcptr(args)" is ambiguous and might send
people looking for a function named funcptr, while
vtable->funcptr(args) is not ambiguous.

3. Relax the comment formatting section to allow two line non-block
comments like:

    /* An explanation of the following code which doesn't entirely fit
     * on one line. */

Right now, if you want to explain a subsequent block of code and you
can't quite fit the explanation onto one line, you have to make a
four-line block comment, which substantially breaks up the flow of the
code.

Opinions are welcome; lack of opinions is also fine.



More information about the krbdev mailing list