[libvirt] [PATCH] build: avoid shadowing devname() on BSD systems

Eric Blake eblake at redhat.com
Fri Dec 3 18:31:18 UTC 2010


On 12/03/2010 10:08 AM, Justin Clift wrote:
> Thanks Eric.  Captured the complete make log this time, to ensure it's fixed.
> 
> The same warning also appears in a few other places. :/
> 
>   libvirt.c: In function 'virDomainOpenConsole':
>   libvirt.c:13169: warning: declaration of 'devname' shadows a global declaration [-Wshadow]
>   /usr/include/stdlib.h:290: warning: shadowed declaration is here [-Wshadow]

Yuck.  'devname' is just too handy to be penalized by BSD's namespace
pollution.  What if we instead do this in internal.h:

#include <stdlib.h>
/* Silence -Wshadow on BSD systems, which declare a devname() that we
 * don't care about */
#define devname vir_devname

then all other shadowing warnings should just go away, without us having
to worry about the problem cropping up again.

(I've seen this trick used in gnulib, where we got rid of shadowing
warnings for the poorly-named and now-obsolete index().)

> While looking for those, a few more warnings also showed up:
> 
>   ../daemon/event.c: In function 'virEventInterruptLocked':
>   ../daemon/event.c:656: warning: cast from pointer to integer of different size [-Wpointer-to-int-cast]
> 
>   virsh.c: In function 'vshReadlineInit':
>   virsh.c:11575: warning: assignment discards qualifiers from pointer target type
> 
>   event.c: In function 'virEventInterruptLocked':
>   event.c:656: warning: cast from pointer to integer of different size [-Wpointer-to-int-cast]

I agree with Diego - these are real bugs and need fixing.

-- 
Eric Blake   eblake at redhat.com    +1-801-349-2682
Libvirt virtualization library http://libvirt.org

-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 619 bytes
Desc: OpenPGP digital signature
URL: <http://listman.redhat.com/archives/libvir-list/attachments/20101203/6e086a8a/attachment-0001.sig>


More information about the libvir-list mailing list