]> git.ozlabs.org Git - ccan/commit - ccan/opt/helpers.c
opt: always initialise values in set_llong_with_suffix()
authorDouglas Bagnall <douglas@halo.gen.nz>
Fri, 20 Jun 2014 02:33:53 +0000 (14:33 +1200)
committerRusty Russell <rusty@rustcorp.com.au>
Mon, 23 Jun 2014 00:57:23 +0000 (10:27 +0930)
commitb377324e5c1ad356b535f4c3724251c626abdf40
tree850bd69017f09c78f378b8e6c3d6081f4c173a10
parent19bfc149066268388e7227f024f5a86d4bd3550b
opt: always initialise values in set_llong_with_suffix()

The helper API functions based on set_llong_with_suffix() left the
value uninitialised in the case of an empty string argument. This is
quite unlikely to have caused problem in practice, as most values will
have already been set to a default and the non-NULL error message
should have triggered an early exit or some other emergency action.
Nevertheless, it caused a compiler warning on some minor version of
GCC 4.8 which I no longer seem to have, and the complaint seemed
reasonable at the time.

If an empty string (or any other non-numeric value) is passed to
strtoll(), the result is zero. As far as I know, the strtoll() call is
only short-circuited here to form a more specific error message, not
because there is a good reason for the empty string to be a special
non-initialising case. So let's set it to zero.

Signed-off-by: Douglas Bagnall <douglas@halo.gen.nz>
Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
ccan/opt/helpers.c