summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAlejandro Colomar <alx@kernel.org>2024-01-06 23:48:33 +0100
committerSerge Hallyn <serge@hallyn.com>2024-05-04 17:22:57 -0500
commit8d8062c770a109a283c99e8002f697adacf3cb03 (patch)
tree4ce98a9a5083ec75aed548511b8a3265cc6ab8ee
parent38a0b0a610cb56c24941326e1e91e119e0c4a4a1 (diff)
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 <alx@kernel.org>
-rw-r--r--lib/getrange.c16
1 files changed, 5 insertions, 11 deletions
diff --git a/lib/getrange.c b/lib/getrange.c
index b12cb72a..1fcab069 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;
/* -<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: