We do not require the special characteristics of SIZE_MAX (that it be
suitable for use in #if directives), and older library implementations
do not define it. Outside of the preprocessor, (size_t)-1 is exactly
equivalent so let's just use that instead.
const char **new;
size_t size;
- if (user_error_max >= MIN(SIZE_MAX, INT_MAX)/2 - LBX_EUBASE)
+ if (user_error_max >= MIN((size_t)-1, INT_MAX)/2 - LBX_EUBASE)
return -1;
- if (2 * user_error_max >= SIZE_MAX / sizeof *user_errors)
+ if (2 * user_error_max >= (size_t)-1 / sizeof *user_errors)
return -1;
size = 2 * user_error_max * sizeof *user_errors;
assert(fmt >= 0 && fmt < sizeof formats / sizeof formats[0]);
npixels = img->width;
- if (img->height && npixels >= SIZE_MAX / img->height) {
+ if (img->height && npixels >= (size_t)-1 / img->height) {
tool_err(-1, "image too large");
goto err;
}
if (rc < 0)
return -1;
- assert(rc < SIZE_MAX);
+ assert(rc < (size_t)-1);
buf = malloc(rc+1u);
if (!buf)
return -1;
/* Saturating addition. */
static size_t add_size(size_t a, size_t b)
{
- if (a >= SIZE_MAX - b)
- return SIZE_MAX;
+ if (a >= (size_t)-1 - b)
+ return (size_t)-1;
return a + b;
}
totlen = add_size(totlen, errlen);
}
- if (totlen == SIZE_MAX || totlen > INT_MAX)
+ if (totlen == (size_t)-1 || totlen > INT_MAX)
return -1;
newfmt = malloc(totlen);