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

Eric Blake eblake at redhat.com
Mon Dec 6 16:30:42 UTC 2010


On 12/06/2010 04:06 AM, Daniel P. Berrange wrote:
>>>   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 dunno, I'd just change our variable to dname, or devicename.

The problem is that most development is done on glibc systems where
devname is not a shadowing issue, so we risk re-introducing the problem
for the next person who tries to build on BSD.  Performing the rename
via #define up front avoids the problem, while leaving the obvious
variable name for easy use in the rest of code (then again, for gdb
purposes, a #define rename should only be done when HAVE_DECL_DEVNAME,
so as not to make debugging confusing on glibc systems).

-- 
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/20101206/6120ab7f/attachment-0001.sig>


More information about the libvir-list mailing list