]> git.ipfire.org Git - thirdparty/shadow.git/commitdiff
src/useradd.c: Simplify, by calling a2sl() instead of str2sl()
authorAlejandro Colomar <alx@kernel.org>
Tue, 9 Jan 2024 20:17:13 +0000 (21:17 +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>
src/useradd.c

index 9b4852265583eeae7acf42fe54ffa924fa43b5db..d307aecae9366382762f55c86fd1d222dbfaf647 100644 (file)
@@ -37,7 +37,7 @@
 #include <unistd.h>
 
 #include "alloc/x/xmalloc.h"
-#include "atoi/str2i.h"
+#include "atoi/a2i.h"
 #include "atoi/getnum.h"
 #include "chkname.h"
 #include "defines.h"
@@ -419,8 +419,7 @@ static void get_defaults (void)
                 * Default Password Inactive value
                 */
                else if (MATCH (buf, DINACT)) {
-                       if (   (str2sl(&def_inactive, ccp) == -1)
-                           || (def_inactive < -1)) {
+                       if (a2sl(&def_inactive, ccp, NULL, 0, -1, LONG_MAX) == -1) {
                                fprintf (stderr,
                                         _("%s: invalid numeric argument '%s'\n"),
                                         Prog, ccp);
@@ -1288,8 +1287,9 @@ static void process_flags (int argc, char **argv)
                                eflg = true;
                                break;
                        case 'f':
-                               if (   (str2sl(&def_inactive, optarg) == -1)
-                                   || (def_inactive < -1)) {
+                               if (a2sl(&def_inactive, optarg, NULL, 0, -1, LONG_MAX)
+                                   == -1)
+                               {
                                        fprintf (stderr,
                                                 _("%s: invalid numeric argument '%s'\n"),
                                                 Prog, optarg);