]> git.ipfire.org Git - thirdparty/kmod.git/commitdiff
libkmod: Add elf_get_u32() helper
authorLucas De Marchi <demarchi@kernel.org>
Thu, 23 Apr 2026 19:43:10 +0000 (14:43 -0500)
committerLucas De Marchi <demarchi@kernel.org>
Sat, 20 Jun 2026 16:09:52 +0000 (11:09 -0500)
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 <demarchi@kernel.org>
Reviewed-by: Emil Velikov <emil.l.velikov@gmail.com>
Link: https://github.com/kmod-project/kmod/pull/432
libkmod/libkmod-elf.c

index 99563ff89d0797afba71e89d328574a0a83a3d6f..7fe6a29c91bf92884cda2344d7ea8ae9c60cb8a7 100644 (file)
@@ -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;
 }