As @yvs2014 noted in https://github.com/traviscross/mtr/issues/523#issuecomment-
2660970185, it is unnecessary to check whether an int is larger than the maximum int value. An int cannot be greater than the maximum int value.
if (str != NULL && *str != '\0') {
errno = 0;
num = strtol(str, &end, 0);
- if (errno == 0 && str != end && end != NULL && *end == '\0' && num < INT_MAX) {
+ if (errno == 0 && str != end && end != NULL && *end == '\0') {
return num;
}
}
if (str != NULL && *str != '\0') {
errno = 0;
num = strtoul(str, &end, 0);
- if (errno == 0 && str != end && end != NULL && *end == '\0' && num < UINT32_MAX) {
+ if (errno == 0 && str != end && end != NULL && *end == '\0') {
return num;
}
}