From: Garrett C. <yan...@gm...> - 2011-01-08 05:57:26
|
On Jan 7, 2011, at 11:08 AM, Garrett Cooper wrote: > On Jan 7, 2011, at 6:36 AM, Cyril Hrubis wrote: > >> Hi! >>> >>> Ok -- good to note for next time I guess. I fixed all of the compilation errors so now people can report runtime issues. There are a handful of them. >>> >> >> I still could not compile the latest git. I've got a bunch of: >> >> pipe declared with warn_unused_result >> write declared with warn_unused_result >> read declared with warn_unused_result > > Now you know why I used void casts in a few spots :). Some are of value, some are fud. This has me thinking. Given that the patterns are basically the same, I'm planning on writing some macros to add to include (say, safe_calls.h? I'm not sold on the name, but if you have a better one I'm all ears :)..), like the following: #define SAFE_WRITE(fildes, buf, nbyte, cleanup_fn) ({ \ int __rval = write((fildes), (buf), (nbyte)); \ if (__rval == -1) \ tst_brkm(TBROK|TERRNO, (cleanup_fn), "write failed at %s:%d", __FILE__, __LINE__); \ __rval; \ }) It would be strictly for libltp consumers. I'd add macros for open, pipe, read, write, and anything else that gcc deems bad with warnings if left unchecked, so that this warning junk could be handled properly. FWIW I wish I could get the non-gcc inline extension to work (do-while(0)), but that seems to be failing me right now :(..: $ gcc safe_write.c safe_write.c: In function ‘main’: safe_write.c:17: error: expected expression before ‘do’ safe_write.c:18: error: expected expression before ‘do’ Thanks, -Garrett |