lib/, src/: Rename some local variables

'endptr' is appropriate internally in strtol(3) because it's a pointer
to 'end', and 'end' itself is a pointer to one-after-the-last character
of the numeric string.  In other words,

	endptr == &end

However, naming the pointer whose address we pass to strtol(3)'s
'endptr' feels wrong, and causes me trouble while parsing the code; I
need to double check the number of dereferences, because something feels
wrong in my head.

Signed-off-by: Alejandro Colomar <alx@kernel.org>
This commit is contained in:
Alejandro Colomar
2024-01-07 01:37:04 +01:00
committed by Serge Hallyn
parent f40bd94856
commit 98aefe8772
9 changed files with 45 additions and 44 deletions
+9 -9
View File
@@ -30,7 +30,7 @@ getrange(const char *range,
unsigned long *min, bool *has_min,
unsigned long *max, bool *has_max)
{
char *endptr;
char *end;
if (NULL == range)
return -1;
@@ -39,32 +39,32 @@ getrange(const char *range,
*has_max = false;
if ('-' == range[0]) {
endptr = range + 1;
end = range + 1;
goto parse_max;
}
errno = 0;
*min = strtoul_noneg(range, &endptr, 10);
if (endptr == range || 0 != errno)
*min = strtoul_noneg(range, &end, 10);
if (end == range || 0 != errno)
return -1;
*has_min = true;
switch (*endptr++) {
switch (*end++) {
case '\0':
*has_max = true;
*max = *min;
return 0; /* <long> */
case '-':
if ('\0' == *endptr)
if ('\0' == *end)
return 0; /* <long>- */
parse_max:
if (!isdigit(*endptr))
if (!isdigit(*end))
return -1;
errno = 0;
*max = strtoul_noneg(endptr, &endptr, 10);
if ('\0' != *endptr || 0 != errno)
*max = strtoul_noneg(end, &end, 10);
if ('\0' != *end || 0 != errno)
return -1;
*has_max = true;