This is the mail archive of the gcc-patches@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: [PATCH] Add check_result attribute


On Friday, September 12, 2003, at 11:27 AM, Jakub Jelinek wrote:

Hi!

Some functions (e.g. in Linux kernel various uaccess.h functions/macros or
realloc) callers should never ignore their return values, as it is either
security problem or always a bug.
This patch adds a function attribute so that such function can be marked
and gcc issue warnings whenever their results are discarded.
It is possible to even check result of statement expressions etc., assuming
their return type is known, e.g. by writing:
extern inline __attribute__((always_inline, check_result)) int
check_int_result (int arg) { return arg; }
#define get_user(val, addr) check_int_result (({ ... }))
Bootstrapped/regtested on i386-redhat-linux, no regressions.
Ok to commit?

I thought this one of the patches we did not want. From <http://gcc.gnu.org/onlinedocs/gcc/Non-bugs.html>: Warning when a non-void function value is ignored.

Coming as I do from a Lisp background, I balk at the idea that there is something dangerous about discarding a value. There are functions that return values which some callers may find useful; it makes no sense to clutter the program with a cast to void whenever the value isn't useful.

Thanks,
Andrew Pinski


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]