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

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

On 07/29/2010 06:25 PM, Matthias Bolte wrote:
> 2010/7/29 Eric Blake <eblake 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 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]