Marking of functions with attributes like __wur

Andreas Jaeger aj@suse.com
Wed Apr 11 19:00:00 GMT 2012


__wur ( "warn unused result") is a function attribute that warns - if 
enabled - that the compiler should warn if the return value of the 
function is not checked.

We do have a couple of these attributes and as Roland suggested in his 
email with subject "Re: BZ #11959: stdio.h: remove fwrite's __wur 
attribute", we should document the usage.

The GCC manual descriping the attribute says:
"This is useful for functions where not checking the result is either a 
security problem or always a bug such as realloc"

I think that's good start. I would enhance it with:

This flag might not be set if the check for failure can be done in other 
ways, e.g. the return value of fwrite can be check with ferror as well.

What do you think?

What's the best place to document when to use the attribute? A place in 
the wiki called Attributes?

Andreas
-- 
  Andreas Jaeger aj@{suse.com,opensuse.org} Twitter/Identica: jaegerandi
   SUSE LINUX Products GmbH, Maxfeldstr. 5, 90409 Nürnberg, Germany
    GF: Jeff Hawn,Jennifer Guild,Felix Imendörffer,HRB16746 (AG Nürnberg)
     GPG fingerprint = 93A3 365E CE47 B889 DF7F  FED1 389A 563C C272 A126



More information about the Libc-alpha mailing list