config-parser: Improve error checks for strtol/strtoul calls
authorBryce Harrington <bryce@osg.samsung.com>
Thu, 7 Jul 2016 21:08:28 +0000 (14:08 -0700)
committerBryce Harrington <bryce@osg.samsung.com>
Fri, 8 Jul 2016 18:10:38 +0000 (11:10 -0700)
commitcbc053781e059bcb6029ac2eb018f7afa2a5d6b5
treee45ab11888944d6d630d27ec01723da03c16053b
parente4cb3c2ce2f5e148a7fac467ffc805ffe91843d0
config-parser: Improve error checks for strtol/strtoul calls

Check errno, which is set of over/underflow, out of range, etc.  Also
check for empty strings (the usages covered in this patch already also
cover the case where there are non-digits present).  Set errno to 0
before making the strto*l call in case of pre-existing errors
(i.e. ENOTTY when running under the testsuite).

This follows the error checking style used in Wayland
(c.f. wayland-client.c and scanner.c).

In tests, also check errno, and add testcases for parsing '0'.

Signed-off-by: Bryce Harrington <bryce@osg.samsung.com>
Reviewed-by: Eric Engestrom <eric.engestrom@imgtec.com>
shared/config-parser.c
tests/config-parser-test.c