summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAlejandro Colomar <alx@kernel.org>2024-04-15 11:18:46 +0200
committerSerge Hallyn <serge@hallyn.com>2024-05-04 17:22:57 -0500
commit6bf5d6d4f33c3df769ca22d39f76fd2b4c698774 (patch)
tree730c18cc7e4f67b0955b33193809656a2bab47e3
parentdbd3527c032bcabf6969977b033049cd3e9bc4e6 (diff)
lib/getrange.c: getrange(): Small refactor
Set *has_{min,max} = false at the begining, so we only need to set them to true later. This means we set these variables 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.c5
1 files changed, 3 insertions, 2 deletions
diff --git a/lib/getrange.c b/lib/getrange.c
index 03b0a913..5c0767c6 100644
--- a/lib/getrange.c
+++ b/lib/getrange.c
@@ -36,6 +36,9 @@ getrange(const char *range,
if (NULL == range)
return -1;
+ *has_min = false;
+ *has_max = false;
+
if ('-' == range[0]) {
if (!isdigit(range[1]))
return -1;
@@ -46,7 +49,6 @@ getrange(const char *range,
return -1;
/* -<long> */
- *has_min = false;
*has_max = true;
*max = n;
} else {
@@ -68,7 +70,6 @@ getrange(const char *range,
if ('\0' == *endptr) {
/* <long>- */
*has_min = true;
- *has_max = false;
*min = n;
} else if (!isdigit (*endptr)) {
return -1;