]> git.ipfire.org Git - thirdparty/shadow.git/commitdiff
lib/getrange.c: getrange(): Remove temporary variable
authorAlejandro Colomar <alx@kernel.org>
Sat, 6 Jan 2024 22:48:33 +0000 (23:48 +0100)
committerSerge Hallyn <serge@hallyn.com>
Sat, 4 May 2024 22:22:57 +0000 (17:22 -0500)
This means we set the pointees on error, which we didn't do before, but
since we return -1 on error and ignore (don't use) the pointees at call
site, that's fine.

Signed-off-by: Alejandro Colomar <alx@kernel.org>
lib/getrange.c

index b12cb72aa62cb49ad2dd661550966a1782e68bd1..1fcab0691d858bcc766c107e944a9fd2efbf2acf 100644 (file)
@@ -30,8 +30,7 @@ getrange(const char *range,
          unsigned long *min, bool *has_min,
          unsigned long *max, bool *has_max)
 {
-       char *endptr;
-       unsigned long n;
+       char  *endptr;
 
        if (NULL == range)
                return -1;
@@ -44,16 +43,15 @@ getrange(const char *range,
                        return -1;
 
                errno = 0;
-               n = strtoul_noneg(&range[1], &endptr, 10);
+               *max = strtoul_noneg(&range[1], &endptr, 10);
                if (('\0' != *endptr) || (0 != errno))
                        return -1;
                *has_max = true;
 
                /* -<long> */
-               *max = n;
        } else {
                errno = 0;
-               n = strtoul_noneg(range, &endptr, 10);
+               *min = strtoul_noneg(range, &endptr, 10);
                if (endptr == range || 0 != errno)
                        return -1;
                *has_min = true;
@@ -62,26 +60,22 @@ getrange(const char *range,
                case '\0':
                        /* <long> */
                        *has_max = true;
-                       *min = n;
-                       *max = n;
+                       *max = *min;
                        break;
                case '-':
                        endptr++;
                        if ('\0' == *endptr) {
                                /* <long>- */
-                               *min = n;
                        } else if (!isdigit (*endptr)) {
                                return -1;
                        } else {
-                               *min = n;
                                errno = 0;
-                               n = strtoul_noneg(endptr, &endptr, 10);
+                               *max = strtoul_noneg(endptr, &endptr, 10);
                                if ('\0' != *endptr || 0 != errno)
                                        return -1;
                                *has_max = true;
 
                                /* <long>-<long> */
-                               *max = n;
                        }
                        break;
                default: