Coding practices updates

ghudson@MIT.EDU ghudson at MIT.EDU
Tue Oct 5 22:26:21 EDT 2010


I've made two updates to
http://k5wiki.kerberos.org/wiki/Coding_style/Practices.  One is the
addition of the Copyright/License Statements section, and is based on
list discussion about making copyright notices more easil extractable,
and corresponds to the change to prototype/prototype.[ch].

The other is just a primer on when to use krb5_set_error_message(),
since there were aspects of this infrastructure which weren't obvious
to me before today.  The text I added (under Exception Handling) was:

    Unless constrained by an API standard such as GSSAPI, functions
    which can fail should return a krb5_error_code.  Error codes are
    defined in com_err tables, usually located in
    src/lib/krb5/error_tables.

    Functions can also set extended error messages using
    krb5_set_error_message() (or, in dependencies of libkrb5,
    krb5int_set_error() on &context->err).  Code should set extended
    error messages when an error condition is moderately likely to
    occur and the default string for the error code is insufficiently
    clear.  Avoid exposing function names and other implementation
    details in error messages.

    After ignoring or handling an error code,
    krb5_clear_error_message() (or krb5int_clear_error()) should be
    used to ensure that an extended error message is not applied
    erroneously to a later instance of the same error code.  This can
    be especially important in loops.



More information about the krbdev mailing list