mirror of
https://codeberg.org/libreboot/lbmk.git
synced 2026-07-11 14:02:52 +02:00
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:
@@ -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
|
||||
|
||||
/*
|
||||
|
||||
Reference in New Issue
Block a user