qemu-devel
[Top][All Lists]
Advanced

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

Re: [Qemu-devel] [PULL 2/9] cutils: add qemu_strtoi & qemu_strtoui parse


From: Kamil Rytarowski
Subject: Re: [Qemu-devel] [PULL 2/9] cutils: add qemu_strtoi & qemu_strtoui parsers for int/unsigned int types
Date: Tue, 13 Mar 2018 20:10:10 +0100
User-agent: Mozilla/5.0 (X11; NetBSD amd64; rv:52.0) Gecko/20100101 Thunderbird/52.4.0

On 12.03.2018 21:12, Daniel P. Berrangé wrote:
> From: "Daniel P. Berrange" <address@hidden>
> 
> There are qemu_strtoNN functions for various sized integers. This adds two
> more for plain int & unsigned int types, with suitable range checking.
> 

There is a prior art in NetBSD with strtoi(3) and strtou(3).

http://netbsd.gw.com/cgi-bin/man-cgi?strtoi++NetBSD-current
http://netbsd.gw.com/cgi-bin/man-cgi?strtou++NetBSD-current

This is a clean room alternative for strtonum(3) with compat with some
other OSes.

The original code is in:

https://github.com/NetBSD/src/blob/trunk/common/lib/libc/stdlib/

It uses a wrapper for regular strtol(3)-like functions and strtol_l(3).

A simpler strtoi(3) wrapper is used in dhcpcd:

https://github.com/NetBSD/src/blob/trunk/external/bsd/dhcpcd/dist/compat/

It has one difference compared to new POSIX (release 2016 or so) - no
conversion at all is ECANCELED, not EINVAL. I think ECANCELED makes more
sense and is distinguishable with input base error, and should be preserved.

Attachment: signature.asc
Description: OpenPGP digital signature


reply via email to

[Prev in Thread] Current Thread [Next in Thread]