]> git.ipfire.org Git - thirdparty/libvirt.git/commit
util: new stricter unsigned int parsing
authorEric Blake <eblake@redhat.com>
Thu, 1 May 2014 02:11:09 +0000 (20:11 -0600)
committerEric Blake <eblake@redhat.com>
Thu, 1 May 2014 21:11:02 +0000 (15:11 -0600)
commit7b045c8ce95da2ff2e2c3e8c3f023232b0374631
tree623204e5800aa6bee54914b23245f9e8efa3828b
parentf18c02ec221a5b3ef91f7106d07fa3957a941c6e
util: new stricter unsigned int parsing

strtoul() is required to parse negative numbers as their
twos-complement positive counterpart.  But sometimes we want
to reject negative numbers.  Add new functions to do this.
The 'p' suffix is a mnemonic for 'positive' (technically it
also parses 0, but 'non-negative' doesn't lend itself to a
nice one-letter suffix).

* src/util/virstring.h (virStrToLong_uip, virStrToLong_ulp)
(virStrToLong_ullp): New prototypes.
* src/util/virstring.c (virStrToLong_uip, virStrToLong_ulp)
(virStrToLong_ullp): New functions.
* src/libvirt_private.syms (virstring.h): Export them.
* tests/virstringtest.c (testStringToLong): Test them.

Signed-off-by: Eric Blake <eblake@redhat.com>
src/libvirt_private.syms
src/util/virstring.c
src/util/virstring.h
tests/virstringtest.c