[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [Qemu-devel] [PATCH 1/2] hmp: expr_unary(): check for overflow in st
From: |
Eric Blake |
Subject: |
Re: [Qemu-devel] [PATCH 1/2] hmp: expr_unary(): check for overflow in strtoul() |
Date: |
Fri, 27 Apr 2012 08:07:20 -0600 |
User-agent: |
Mozilla/5.0 (X11; Linux x86_64; rv:11.0) Gecko/20120329 Thunderbird/11.0.1 |
On 04/26/2012 05:18 PM, Luiz Capitulino wrote:
>> Not quite right. ULLONG_MAX is a valid return, but you did not prime
>> errno, so if errno has junk ERANGE from some earlier point in the
>> program, you will have a false negative. You are guaranteed that errno
>> is unchanged on success, so prime things by setting errno to 0 before
>> calling strtoull.
>
> I thought about doing that but - hope that won't sound stupid - how can I
> guarantee that ERANGE is not 0?
Because POSIX requires that all E* constants are positive numbers,
reserving errno of 0 for success.
--
Eric Blake address@hidden +1-919-301-3266
Libvirt virtualization library http://libvirt.org
signature.asc
Description: OpenPGP digital signature
[Qemu-devel] [PATCH 2/2] hmp: fix bad value conversion for M type, Luiz Capitulino, 2012/04/26