Tools: Check overflow/underflow (Fix)

This commit is contained in:
shahramn 2024-03-08 21:15:31 +00:00
parent 7b0a779890
commit 87d14a89b8
1 changed files with 1 additions and 2 deletions

View File

@ -1749,8 +1749,7 @@ static void set_value(grib_values* value, char* str, int equal)
value->long_value = strtol(buf, &p, 10);
if (*p == 0) {
// check the conversion from string to long
if ((errno == ERANGE && (value->long_value == LONG_MAX || value->long_value == LONG_MIN)) ||
(errno != 0 && value->long_value == 0)) {
if (errno == ERANGE && (value->long_value == LONG_MAX || value->long_value == LONG_MIN)) {
fprintf(stderr, "ECCODES WARNING : Setting %s=%s causes overflow/underflow\n", value->name, buf);
fprintf(stderr, "ECCODES WARNING : Value adjusted to %ld\n", value->long_value);
//perror("strtol");