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

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

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

Attachment: signature.asc
Description: OpenPGP digital signature

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