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 <alx@kernel.org>
n = strtoul_noneg(&range[1], &endptr, 10);
if (('\0' != *endptr) || (0 != errno))
return -1;
+ *has_max = true;
/* -<long> */
- *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':
/* <long> */
- *has_min = true;
*has_max = true;
*min = n;
*max = n;
endptr++;
if ('\0' == *endptr) {
/* <long>- */
- *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;
/* <long>-<long> */
- *has_max = true;
*max = n;
}
break;