On 04/01/11 14:37, Karel Zak wrote: > On Tue, Jan 04, 2011 at 11:53:21AM +0000, PÃdraig Brady wrote: >> On 01/01/11 22:56, Karel Zak wrote: >>> On Sat, Jan 01, 2011 at 08:59:02PM +0000, Jon Grant wrote: >>>> Just building latest code and saw the compiler generated some >>>> warnings. Just thinking, one idea is to check the return value, and >>> >>> the warn_unused_result for write() in glibc is pretty idiotic... >>> >>>> use it as best possible (even just for trace) or (void)bytes to make >>>> it go quiet when there really is no use. >>> >>> (void) foo() is mess and it has no effect for warn_unused_result >>> >>>> bytes = write(1, "\n", 1); >>> >>> hmm.. possible solution is to call error() (but I'm not sure if this >>> is appropriate solution for unimportant things like /etc/issue) or >>> really ignore the return value. It would be nice to have a macro that >>> allows to ignore the return values in some cases >>> >>> ignore_result( write(1, "\n", 1) ); >> >> We use something like that in coreutils: >> http://git.sv.gnu.org/gitweb/?p=gnulib.git;a=blob;f=lib/ignore-value.h;hb=HEAD > > Nice, but it does not work for all types, what about: > > #define ignore(x) ({ typeof(x) __rc = (x); }) That looks right for util-linux but is probably not portable enough for gnulib. Also I'd be slightly worried that clang-analyzer would start complaining about dead stores with that. Perhaps this might work? static inline void _ignore (int i) { (void) i; } #define ignore(x) _ignore ((int)x) cheers, PÃdraig. -- To unsubscribe from this list: send the line "unsubscribe util-linux" in the body of a message to majordomo@xxxxxxxxxxxxxxx More majordomo info at http://vger.kernel.org/majordomo-info.html