From: Lucas De Marchi Date: Thu, 23 Apr 2026 19:43:10 +0000 (-0500) Subject: libkmod: Add elf_get_u32() helper X-Git-Url: http://git.ipfire.org/gitweb/?a=commitdiff_plain;h=0da79e0ab322298e2af0bd754b5970f2fd474dce;p=thirdparty%2Fkmod.git libkmod: Add elf_get_u32() helper Shortcut to the size. Keep this wrapper inline even after the previous de-inlining change: it is a tiny typed helper around elf_get_uint() that avoids repeating the uint32_t size at call sites, while the larger helpers can still be left to the compiler. Signed-off-by: Lucas De Marchi Reviewed-by: Emil Velikov Link: https://github.com/kmod-project/kmod/pull/432 --- diff --git a/libkmod/libkmod-elf.c b/libkmod/libkmod-elf.c index 99563ff..7fe6a29 100644 --- a/libkmod/libkmod-elf.c +++ b/libkmod/libkmod-elf.c @@ -162,6 +162,11 @@ static uint64_t elf_get_uint(const struct kmod_elf *elf, uint64_t offset, uint16 return ret; } +static inline uint32_t elf_get_u32(const struct kmod_elf *elf, uint64_t offset) +{ + return elf_get_uint(elf, offset, sizeof(uint32_t)); +} + static int elf_set_uint(const struct kmod_elf *elf, uint64_t offset, uint64_t size, uint64_t value, uint8_t *changed) { @@ -791,7 +796,8 @@ static uint64_t kmod_elf_resolve_crc(const struct kmod_elf *elf, uint64_t crc, return (uint64_t)-1; } - crc = elf_get_uint(elf, off + crc, sizeof(uint32_t)); + crc = elf_get_u32(elf, off + crc); + return crc; }