From: Alejandro Colomar Date: Tue, 9 Jan 2024 18:58:02 +0000 (+0100) Subject: lib/getdef.c: getdef_num(): Simplify, by calling a2si() instead of str2sl() X-Git-Tag: 4.17.0-rc1~167 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=9415ce4a14c2348adb5fc93103d6c777095725b7;p=thirdparty%2Fshadow.git lib/getdef.c: getdef_num(): Simplify, by calling a2si() instead of str2sl() Reviewed-by: "Serge E. Hallyn" Signed-off-by: Alejandro Colomar --- diff --git a/lib/getdef.c b/lib/getdef.c index c6f669df6..624a05662 100644 --- a/lib/getdef.c +++ b/lib/getdef.c @@ -22,6 +22,7 @@ #include #endif +#include "atoi/a2i.h" #include "atoi/str2i.h" #include "defines.h" #include "getdef.h" @@ -233,10 +234,11 @@ bool getdef_bool (const char *item) * values are handled. */ -int getdef_num (const char *item, int dflt) +int +getdef_num(const char *item, int dflt) { - struct itemdef *d; - long val; + int val; + struct itemdef *d; if (!def_loaded) { def_load (); @@ -247,9 +249,7 @@ int getdef_num (const char *item, int dflt) return dflt; } - if ( (str2sl(&val, d->value) == -1) - || (val > INT_MAX) - || (val < -1)) { + if (a2si(&val, d->value, NULL, 0, -1, INT_MAX) == -1) { fprintf (shadow_logfd, _("configuration error - cannot parse %s value: '%s'"), item, d->value);