On 07/20/2017 12:06 PM, Daniel P. Berrange wrote:
>>> IMHO your patch is ok, or we could be alittle more explicit about
>>> catching just the case where you pass -1 for bytes, and have
>>>
>>>   && bytes != -1
>>
>> This seems bizarre to me since bytes is   size_t bytes   and size_t
>> is unsigned, so I'd have sympathy for a compiler that warned that
>> bytes != -1 was always true.
> 
> Could be paranoid and do    "&& bytes !=  (size_t)-1"

Any compiler that treats 'bytes != -1' differently from 'bytes !=
(size_t)-1' is broken, since those two are equivalent per C99 promotion
rules (unsigned op signed produces unsigned, and conversion of signed to
unsigned is well-defined).  I prefer the form without a cast.

-- 
Eric Blake, Principal Software Engineer
Red Hat, Inc.           +1-919-301-3266
Virtualization:  qemu.org | libvirt.org

Attachment: signature.asc
Description: OpenPGP digital signature

Reply via email to