On 01/06/2011 03:06 PM, Eric Blake wrote: > On 01/05/2011 05:06 AM, Pádraig Brady wrote: >> Looks good. I'll apply the following to coreutils, >> along with a gnulib update soon. >> >> thanks, >> Pádraig. >> >> commit 79138dbb615644c1b2d9ec05afa4e028e8b0ef06 >> Author: Pádraig Brady <[email protected]> >> Date: Wed Jan 5 12:01:14 2011 +0000 >> >> maint: replace uses of ignore_ptr with ignore_value > > This isn't in yet, and it bit me while playing with my fixes to > sc_prohibit_strcmp. Without it, I get build failures (configuring with > --enable-gcc-warnings) about deprecated ignore_ptr, but with it, I still > get build failures: > > chcon.c: In function 'process_file': > chcon.c:229:30: error: cast from function call of type 'struct FTSENT *' > to non-matching type 'long int' [-Wbad-function-cast]
Hmm, since the whole point of ignore_value is to work around a gcc warning, we can use gcc extensions to avoid the warning. What do you think about this patch, which once again makes coreutils happy? diff --git i/ChangeLog w/ChangeLog index 228b4e8..2db0f0b 100644 --- i/ChangeLog +++ w/ChangeLog @@ -1,5 +1,9 @@ 2011-01-06 Eric Blake <[email protected]> + ignore_value: work around gcc -Wbad-function-cast + * lib/ignore-value.h (ignore_value): Provide separate gcc + definition. + maint.mk: improve sc_prohibit_strcmp regex * top/maint.mk (sc_prohibit_strcmp): Detect strcmp()!=0, as documented. Also, detect strcmp((expr),expr) == 0. diff --git i/lib/ignore-value.h w/lib/ignore-value.h index 8f60b0e..9b73793 100644 --- i/lib/ignore-value.h +++ w/lib/ignore-value.h @@ -47,8 +47,13 @@ # endif # endif +# if __GNUC__ < 3 || (__GNUC__ == 3 && __GNUC_MINOR__ < 1) +# define ignore_value(x) ((void) (x)) +# else static inline void _ignore_value (intptr_t p) { (void) p; } -# define ignore_value(x) _ignore_value ((intptr_t) x) +# define ignore_value(x) \ + _ignore_value (({__typeof__(x) __x = (x); (intptr_t) __x;})) +# endif /* ignore_value works for both scalars and pointers; deprecate ignore_ptr. */ static inline void ATTRIBUTE_DEPRECATED -- Eric Blake [email protected] +1-801-349-2682 Libvirt virtualization library http://libvirt.org
signature.asc
Description: OpenPGP digital signature
