valid_temp_time: more simplification and test fixes

This commit is contained in:
Doug Freed 2022-06-20 11:33:03 +00:00 committed by Ed Kellett
parent 4f46809305
commit fae8f2517c
2 changed files with 5 additions and 3 deletions

View file

@ -694,8 +694,6 @@ valid_temp_time(const char *p)
errno = 0;
current = strtol(p, &endp, 10);
if (errno == ERANGE)
return -1;
if (endp == p)
return -1;
if (current < 0)

View file

@ -67,7 +67,11 @@ static void valid_temp_time_overflow(void)
t = valid_temp_time(s);
is_int(52 * WEEK, t, MSG);
snprintf(s, sizeof s, "%" PRIuMAX "m%" PRIuMAX "m", UINTMAX_MAX / 60 - 1, UINTMAX_MAX / 60 - 1);
snprintf(s, sizeof s, "%ldm", LONG_MAX / 60 + 2);
t = valid_temp_time(s);
is_int(52 * WEEK, t, MSG);
snprintf(s, sizeof s, "%ldm%ldm", LONG_MAX / 60 - 1, LONG_MAX / 60 - 1);
t = valid_temp_time(s);
is_int(52 * WEEK, t, MSG);
}