From 19f888d52ddd9ae0cd0d6fff4a28e7a37421e8c1 Mon Sep 17 00:00:00 2001 From: Leah Rowe Date: Fri, 13 Mar 2026 19:45:55 +0000 Subject: util/nvmutil: fix int assert it can be higher than 32-bit, it's fine the current check breaks some newer systems accordingly, u32 becomes ux, x meaning x bits Signed-off-by: Leah Rowe --- util/nvmutil/nvmutil.c | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) (limited to 'util') diff --git a/util/nvmutil/nvmutil.c b/util/nvmutil/nvmutil.c index c9026b7e..0f7f891d 100644 --- a/util/nvmutil/nvmutil.c +++ b/util/nvmutil/nvmutil.c @@ -22,7 +22,7 @@ * Make most of nvmutil a *library* for re-use * * TODO: gettimeofday not posible - use portable functions. - * TODO: u32 fallback: modify the program instead + * TODO: ux fallback: modify the program instead * to run on 16-bit systems: smaller buffers, and do * operations byte-based instead of word-based. * @@ -165,7 +165,7 @@ also consider: typedef unsigned char u8; typedef unsigned short u16; -typedef unsigned int u32; +typedef unsigned int ux; /* type asserts */ typedef char static_assert_char_is_8_bits[(CHAR_BIT == 8) ? 1 : -1]; @@ -173,7 +173,7 @@ typedef char static_assert_char_is_1[(sizeof(char) == 1) ? 1 : -1]; typedef char static_assert_uint8_is_1[(sizeof(u8) == 1) ? 1 : -1]; typedef char static_assert_uint16_is_2[(sizeof(u16) == 2) ? 1 : -1]; typedef char static_assert_short_is_2[(sizeof(short) == 2) ? 1 : -1]; -typedef char static_assert_uint32_is_4[(sizeof(u32) == 4) ? 1 : -1]; +typedef char static_assert_uint32_is_4[(sizeof(ux) >= 4) ? 1 : -1]; typedef char static_assert_int_ge_32[(sizeof(int) >= 4) ? 1 : -1]; typedef char static_assert_twos_complement[ ((-1 & 3) == 3) ? 1 : -1 @@ -1418,10 +1418,10 @@ static u16 calculated_checksum(size_t p) { size_t c; - u32 val16 = 0; + ux val16 = 0; for (c = 0; c < NVM_CHECKSUM_WORD; c++) - val16 += (u32)nvm_word(c, p); + val16 += (ux)nvm_word(c, p); return (u16)((NVM_CHECKSUM - val16) & 0xffff); } -- cgit v1.2.1