util/nvmutil: safer SSIZE_MAX define

the current one assumes two's compliment and no
padding bits. i assert two's compliment earlier
in code, but it doesn't guarantee:

sizeof(ssize_t) == sizeof(size_t)

it's theoretically possible that size_t=64
and ssize_t=32, and then the macro would break.

this new version uses SIZE_MAX instead, without
subtraction, but halves it using a bit shift.

this may still break, but it should work nicely.

Signed-off-by: Leah Rowe <leah@libreboot.org>
This commit is contained in:
Leah Rowe
2026-03-10 06:55:04 +00:00
parent a6d0146a3b
commit 978c30a961
+1 -1
View File
@@ -289,7 +289,7 @@ static const char *fname;
static const char *argv0;
#ifndef SSIZE_MAX
#define SSIZE_MAX ((ssize_t)((size_t)-1 >> 1))
#define SSIZE_MAX ((ssize_t)(SIZE_MAX >> 1))
#endif
/*