[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.
signature.asc
Description: OpenPGP digital signature
- [Qemu-devel] [PULL 0/9] Socket next patches, Daniel P . Berrangé, 2018/03/12
- [Qemu-devel] [PULL 6/9] sockets: check that the named file descriptor is a socket, Daniel P . Berrangé, 2018/03/12
- [Qemu-devel] [PULL 5/9] sockets: move fd_is_socket() into common sockets code, Daniel P . Berrangé, 2018/03/12
- [Qemu-devel] [PULL 1/9] char: don't silently skip tn3270 protocol init when TLS is enabled, Daniel P . Berrangé, 2018/03/12
- [Qemu-devel] [PULL 4/9] sockets: strengthen test suite IP protocol availability checks, Daniel P . Berrangé, 2018/03/12
- [Qemu-devel] [PULL 7/9] sockets: allow SocketAddress 'fd' to reference numeric file descriptors, Daniel P . Berrangé, 2018/03/12
- [Qemu-devel] [PULL 3/9] sockets: pull code for testing IP availability out of specific test, Daniel P . Berrangé, 2018/03/12
- [Qemu-devel] [PULL 2/9] cutils: add qemu_strtoi & qemu_strtoui parsers for int/unsigned int types, Daniel P . Berrangé, 2018/03/12
- [Qemu-devel] [PULL 8/9] char: refactor parsing of socket address information, Daniel P . Berrangé, 2018/03/12
- [Qemu-devel] [PULL 9/9] char: allow passing pre-opened socket file descriptor at startup, Daniel P . Berrangé, 2018/03/12
- Re: [Qemu-devel] [PULL 0/9] Socket next patches, no-reply, 2018/03/12
- Re: [Qemu-devel] [PULL 0/9] Socket next patches, Peter Maydell, 2018/03/13