[libvirt] [PATCH 2/2] esx: silence spurious compiler warning

Eric Blake eblake at redhat.com
Fri Jul 30 12:35:19 UTC 2010


On 07/29/2010 06:25 PM, Matthias Bolte wrote:
> 2010/7/29 Eric Blake <eblake at redhat.com>:
>> * src/esx/esx_vi_types.c (_DESERIALIZE_NUMBER)
>> (ESX_VI__TEMPLATE__DESERIALIZE_NUMBER): Add range check to shut up
>> gcc 4.5.0 regarding long long.
>> ---
>>  src/esx/esx_vi_types.c |    6 ++++--
>>  1 files changed, 4 insertions(+), 2 deletions(-)

>> -        if (value < (_min) || value > (_max)) {                               \
>> +        if (((_min) != INT64_MIN && value < (_min))                           \
>> +            || ((_max) != INT64_MAX && value > (_max))) {                     \
>>
> 
> It seems that newer gcc warns about this, because in case of _min/_max
> == INT64_MIN/INT64_MAX the original condition is always false and
> adding the additional checks avoids this situation.

The original condition is still false for INT64_MIN/INT64_MAX even with
the additional checks, but the additional checks are enough to shut up
gcc.  Hopefully, since the additional checks are compile time constants
(based on all uses of the macros) it doesn't bloat the assembly any.  I
just hope that we don't have to keep tweaking this down the road for
future gcc (the whole point of the macro is that we know we are using
the same code for multiple types, where the range checks are important
for all but one of the types).

> 
> ACK.

Thanks; pushed.

-- 
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/20100730/a385d4da/attachment-0001.sig>


More information about the libvir-list mailing list