]> git.ipfire.org Git - thirdparty/shadow.git/commitdiff
lib/getdef.c: getdef_num(): Simplify, by calling a2si() instead of str2sl()
authorAlejandro Colomar <alx@kernel.org>
Tue, 9 Jan 2024 18:58:02 +0000 (19:58 +0100)
committerAlejandro Colomar <alx@kernel.org>
Tue, 2 Jul 2024 20:52:31 +0000 (22:52 +0200)
Reviewed-by: "Serge E. Hallyn" <serge@hallyn.com>
Signed-off-by: Alejandro Colomar <alx@kernel.org>
lib/getdef.c

index c6f669df6434e96d255033164ccd2a16433d954f..624a056623803e55b91a92a64cbe1dd7a9451e81 100644 (file)
@@ -22,6 +22,7 @@
 #include <libeconf.h>
 #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);