From: Alejandro Colomar Date: Mon, 15 Apr 2024 09:32:39 +0000 (+0200) Subject: lib/getrange.c: getrange(): Small refactor X-Git-Tag: 4.15.2~49 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=38a0b0a610cb56c24941326e1e91e119e0c4a4a1;p=thirdparty%2Fshadow.git lib/getrange.c: getrange(): Small refactor All 3 non-error paths in the second part resulted in *has_min = true. Set in once before the switch(), to simplify. This means we set this variable 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. Also, move a couple of *has_max = true statements to before a comment, in preparation for future commits. Signed-off-by: Alejandro Colomar --- diff --git a/lib/getrange.c b/lib/getrange.c index 5c0767c6f..b12cb72aa 100644 --- a/lib/getrange.c +++ b/lib/getrange.c @@ -47,20 +47,20 @@ getrange(const char *range, n = strtoul_noneg(&range[1], &endptr, 10); if (('\0' != *endptr) || (0 != errno)) return -1; + *has_max = true; /* - */ - *has_max = true; *max = n; } else { errno = 0; n = strtoul_noneg(range, &endptr, 10); if (endptr == range || 0 != errno) return -1; + *has_min = true; switch (*endptr) { case '\0': /* */ - *has_min = true; *has_max = true; *min = n; *max = n; @@ -69,20 +69,18 @@ getrange(const char *range, endptr++; if ('\0' == *endptr) { /* - */ - *has_min = true; *min = n; } else if (!isdigit (*endptr)) { return -1; } else { - *has_min = true; *min = n; errno = 0; n = strtoul_noneg(endptr, &endptr, 10); if ('\0' != *endptr || 0 != errno) return -1; + *has_max = true; /* - */ - *has_max = true; *max = n; } break;