From: Alejandro Colomar Date: Sat, 6 Jan 2024 22:48:33 +0000 (+0100) Subject: lib/getrange.c: getrange(): Remove temporary variable X-Git-Tag: 4.15.2~48 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=8d8062c770a109a283c99e8002f697adacf3cb03;p=thirdparty%2Fshadow.git lib/getrange.c: getrange(): Remove temporary variable 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 --- diff --git a/lib/getrange.c b/lib/getrange.c index b12cb72aa..1fcab0691 100644 --- a/lib/getrange.c +++ b/lib/getrange.c @@ -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; /* - */ - *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': /* */ *has_max = true; - *min = n; - *max = n; + *max = *min; break; case '-': endptr++; if ('\0' == *endptr) { /* - */ - *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; /* - */ - *max = n; } break; default: