LWN.net Logo

On the importance of return codes

On the importance of return codes

Posted Dec 3, 2009 15:41 UTC (Thu) by rvfh (subscriber, #31018)
In reply to: On the importance of return codes by kpvangend
Parent article: On the importance of return codes

You can set attributes to a function for GCC to complain. I think you add __wur at the end of the declaration, like so:
extern int system (__const char *__command) __wur;


(Log in to post comments)

On the importance of return codes

Posted Dec 3, 2009 19:16 UTC (Thu) by kpfleming (subscriber, #23250) [Link]

There are some Linux distributions (Ubuntu I know for sure, Debian may have been the source) that by default enable such checking for library calls provided by glibc; compiling code that does not pay attention to return values results in warnings/errors. It's a start, at least.

On the importance of return codes

Posted Dec 4, 2009 0:38 UTC (Fri) by nix (subscriber, #2304) [Link]

You mean

extern int system (__const char *__command)
__attribute__((__warn_unused_result__))

__wur is a glibc-specific hack that should not be used outside of glibc
system headers.

Copyright © 2013, Eklektix, Inc.
Comments and public postings are copyrighted by their creators.
Linux is a registered trademark of Linus Torvalds