bug-gnulib
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: make ignore_value more generic; deprecate ignore_ptr


From: Eric Blake
Subject: Re: make ignore_value more generic; deprecate ignore_ptr
Date: Thu, 06 Jan 2011 15:15:57 -0700
User-agent: Mozilla/5.0 (X11; U; Linux x86_64; en-US; rv:1.9.2.13) Gecko/20101209 Fedora/3.1.7-0.35.b3pre.fc14 Lightning/1.0b3pre Mnenhy/0.8.3 Thunderbird/3.1.7

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 <address@hidden>
>> 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  <address@hidden>

+       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   address@hidden    +1-801-349-2682
Libvirt virtualization library http://libvirt.org

Attachment: signature.asc
Description: OpenPGP digital signature


reply via email to

[Prev in Thread] Current Thread [Next in Thread]