From 978c30a961adc78bccacf7de2d495fce93eabd3a Mon Sep 17 00:00:00 2001 From: Leah Rowe Date: Tue, 10 Mar 2026 06:55:04 +0000 Subject: 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 --- util/nvmutil/nvmutil.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) 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 /* -- cgit v1.2.1