On 06/15/2015 07:53 AM, Don Slutz wrote: > On 06/12/15 18:38, Eric Blake wrote:
>>>
>>> + /* Only support 1 address */
>>> + if (addr) {
>>> + return ~0U;
>>> + }
>>
>> Different answer on 32-bit platforms (there, ~0U is 0xffffffff, which
>> then 0-extends to uint64_t rather than your desired result of
>> 0xffffffffffffffffULL).
>>
>
> This is not true:
Oh, I was confusing ~0UL (where sign extension on 32- vs 64-bit matters)
and ~0U (which you used).
>
>> Why can't you just 'return -1;'?
>>
>
> I/O instructions on x86 are limited to 32bits max. Also when EAX is
> changed via inl, the high 32bits are 0. So the correct result is ~0U
> not -1.
Still, it might be better to write an explicit 0xffffffff or even have a
named constant, rather than making people reason about whether ~0U
promotes into a 64-bit value with only 32 bits set.
--
Eric Blake eblake redhat com +1-919-301-3266
Libvirt virtualization library http://libvirt.org
signature.asc
Description: OpenPGP digital signature
