Re: [PATCH] virCommand: Cleanup unnecessarily variables

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

 



On 05/22/2011 09:00 AM, Michal Prívozník wrote:
> On 22.05.2011 16:42, Michal Privoznik wrote:
>> ---
>> Building with ENABLE_DEBUG=0 showed more errors,
>> because VIR_DEBUG() get replaced with dummy 'do {} while(0)' statement,
>> and compiler complains about unused parameters. So if anybody knows
>> how to get rid of this ... Note that I am speaking about '...' part in
>> VIR_DEBUG_INT() definition.

>>                      if (inoff == inlen) {
>> -                        int tmpfd = infd;
>>                          if (VIR_CLOSE(infd) < 0)
>> -                            VIR_DEBUG("ignoring failed close on fd %d", tmpfd);
>> +                            VIR_DEBUG("ignoring failed close on fd %d", infd);

That won't work (infd is -1 at this point, not the value you meant to
print).  Either we don't care about the failure (and VIR_FORCE_CLOSE is
the better fix), or we do care about it, and should be using something
stronger than a VIR_DEBUG that can be compiled out.

Using VIR_FORCE_CLOSE is probably the right fix for this immediate
issue; another option would be marking the variable as (potentially)
unused, as in:

int tmpfd ATTRIBUTE_UNUSED;
tmpfd = infd;

But I can't help but wonder if the more generic issue could be solved by
making VIR_DEBUG() (when ENABLE_DEBUG=0) actually call a static inline
no-op varargs function, so that gcc treats it as using its arguments,
rather than the current situation of expanding to nothing and leaving
variables unused.

-- 
Eric Blake   eblake@xxxxxxxxxx    +1-801-349-2682
Libvirt virtualization library http://libvirt.org

Attachment: signature.asc
Description: OpenPGP digital signature

--
libvir-list mailing list
libvir-list@xxxxxxxxxx
https://www.redhat.com/mailman/listinfo/libvir-list

[Index of Archives]     [Virt Tools]     [Libvirt Users]     [Lib OS Info]     [Fedora Users]     [Fedora Desktop]     [Fedora SELinux]     [Big List of Linux Books]     [Yosemite News]     [KDE Users]     [Fedora Tools]