summaryrefslogtreecommitdiff
path: root/util
diff options
context:
space:
mode:
authorLeah Rowe <leah@libreboot.org>2026-03-10 06:55:04 +0000
committerLeah Rowe <leah@libreboot.org>2026-03-10 06:56:02 +0000
commit978c30a961adc78bccacf7de2d495fce93eabd3a (patch)
tree613b7a3175d214e9ab382b4678e5c96ff0e59506 /util
parenta6d0146a3bf11b0a2d15eb4324682940bfae4ade (diff)
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>
Diffstat (limited to 'util')
-rw-r--r--util/nvmutil/nvmutil.c2
1 files changed, 1 insertions, 1 deletions
diff --git a/util/nvmutil/nvmutil.c b/util/nvmutil/nvmutil.c
index f5ce6a74..3111be7a 100644
--- a/util/nvmutil/nvmutil.c
+++ b/util/nvmutil/nvmutil.c
@@ -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
/*