On 7/10/06, Nicolás Lichtmaier <firstname.lastname@example.org> wrote:
> I think Subversion code can benefit from the use of some function
> attributes. These are some that seem to be appropiate:
> This one marks the function as returning a newly allocated memory
> area (which ensures that no already existing pointer aliases this new
> pointer). I think it could be aplied to every function returning
> This one instruct gcc to give a warning if the returned value is
> discared. This too can be used with functions returning svn_error_t*, as
> it's a memory leak not to handle its return value.
> This function attribute declares the function as receiving a mallloc
> style string. This is used in conjuction with gettext, so that xgettext
> can properly mark the strings as being printf format strings. Currently
> subversion lists all these functions when invoking xgettext, this is awful.
> Ensures that the last parameter in a variadic function is NULL.
> There are many functions that expect this. This catches a silly but
> common error.
> APR defines __atribute__(x) to nothingif not in GCC, but many of these
> attributes are only implemented in recent gcc versions, as such this
> support is not sufficient. The proper way of doing this is by using
> defines like SVN_GCC_WARN_UNUSED_RESULT or SVN_GCC_SENTINEL, which would
> know what to do and when. This don't need to be done for attributes that
> has been implemented in GCC for ever, like "printf" or (I think) "malloc".
> What do you think? Is there value in this? If not I could find another
> hobbie =).
We actually had a discussion about the warn_unused_result one a while
back, and I believe ended up deciding not to add it for one reason or
another. Search the archives for more info. The others might be more
practical since they're less invasive, warn_unused_result basically
needed to be added to every single function for it to be helpful.
To unsubscribe, e-mail: email@example.com
For additional commands, e-mail: firstname.lastname@example.org
Received on Tue Jul 11 15:20:32 2006