From: Emil Velikov Date: Mon, 30 Sep 2024 21:36:29 +0000 (+0100) Subject: shared: s/addu64_overflow/uadd64_overflow/g X-Git-Tag: v34~249 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=b9019723bdfdfa8f34a4a2fe29ea5f2e72f91cde;p=thirdparty%2Fkmod.git shared: s/addu64_overflow/uadd64_overflow/g Rename the helper closer to the actual built-in. Signed-off-by: Emil Velikov Link: https://github.com/kmod-project/kmod/pull/169 Signed-off-by: Lucas De Marchi --- diff --git a/libkmod/libkmod-elf.c b/libkmod/libkmod-elf.c index bea83eca..a8dcdd83 100644 --- a/libkmod/libkmod-elf.c +++ b/libkmod/libkmod-elf.c @@ -243,7 +243,7 @@ static inline int elf_get_section_info(const struct kmod_elf *elf, uint16_t idx, } #undef READV - if (addu64_overflow(*offset, *size, &min_size) || min_size > elf->size) { + if (uadd64_overflow(*offset, *size, &min_size) || min_size > elf->size) { ELFDBG(elf, "out-of-bounds: %" PRIu64 " >= %" PRIu64 " (ELF size)\n", min_size, elf->size); return -EINVAL; @@ -330,7 +330,7 @@ struct kmod_elf *kmod_elf_new(const void *memory, off_t size) goto invalid; } shdrs_size = shdr_size * elf->header.section.count; - if (addu64_overflow(shdrs_size, elf->header.section.offset, &min_size) || + if (uadd64_overflow(shdrs_size, elf->header.section.offset, &min_size) || min_size > elf->size) { ELFDBG(elf, "file is too short to hold sections\n"); goto invalid; diff --git a/shared/util.h b/shared/util.h index 9bea2733..6fa4bf43 100644 --- a/shared/util.h +++ b/shared/util.h @@ -92,7 +92,7 @@ static inline void freep(void *p) } #define _cleanup_free_ _cleanup_(freep) -static inline bool addu64_overflow(uint64_t a, uint64_t b, uint64_t *res) +static inline bool uadd64_overflow(uint64_t a, uint64_t b, uint64_t *res) { #if (HAVE___BUILTIN_UADDL_OVERFLOW && __SIZEOF_LONG__ == 8) return __builtin_uaddl_overflow(a, b, res); diff --git a/testsuite/test-util.c b/testsuite/test-util.c index 2425ff9f..ce246d39 100644 --- a/testsuite/test-util.c +++ b/testsuite/test-util.c @@ -191,22 +191,22 @@ DEFINE_TEST(test_write_str_safe, }, }); -static int test_addu64_overflow(const struct test *t) +static int test_uadd64_overflow(const struct test *t) { uint64_t res; bool overflow; - overflow = addu64_overflow(UINT64_MAX - 1, 1, &res); + overflow = uadd64_overflow(UINT64_MAX - 1, 1, &res); assert_return(!overflow, EXIT_FAILURE); assert_return(res == UINT64_MAX, EXIT_FAILURE); - overflow = addu64_overflow(UINT64_MAX, 1, &res); + overflow = uadd64_overflow(UINT64_MAX, 1, &res); assert_return(overflow, EXIT_FAILURE); return EXIT_SUCCESS; } -DEFINE_TEST(test_addu64_overflow, - .description = "check implementation of addu4_overflow()") +DEFINE_TEST(test_uadd64_overflow, + .description = "check implementation of uadd64_overflow()") static int test_backoff_time(const struct test *t) {