]> git.ipfire.org Git - thirdparty/kmod.git/commitdiff
Silence clang warnings with __unused__ attribute
authorLucas De Marchi <lucas.demarchi@profusion.mobi>
Wed, 23 May 2012 23:28:53 +0000 (20:28 -0300)
committerLucas De Marchi <lucas.demarchi@profusion.mobi>
Wed, 23 May 2012 23:31:18 +0000 (20:31 -0300)
I hate this kind of READV and WRITEV macros that Gustavo seems to love.
clang-analyzer hates them as well.

I'm not motivated enough to refactor this, but I want a clean clang
report, so just shut it up.

libkmod/libkmod-elf.c
libkmod/macro.h

index f8a5d15b5a9a34ce483cbc09cc63cefa03119261..38e83c101eb5ec5389dcac2f481e184eae3a906e 100644 (file)
@@ -243,12 +243,12 @@ static inline int elf_get_section_info(const struct kmod_elf *elf, uint16_t idx,
        elf_get_uint(elf, off + offsetof(typeof(*hdr), field), sizeof(hdr->field))
 
        if (elf->class & KMOD_ELF_32) {
-               const Elf32_Shdr *hdr = (const Elf32_Shdr *)p;
+               const Elf32_Shdr *hdr _unused_ = (const Elf32_Shdr *)p;
                *size = READV(sh_size);
                *offset = READV(sh_offset);
                *nameoff = READV(sh_name);
        } else {
-               const Elf64_Shdr *hdr = (const Elf64_Shdr *)p;
+               const Elf64_Shdr *hdr _unused_ = (const Elf64_Shdr *)p;
                *size = READV(sh_size);
                *offset = READV(sh_offset);
                *nameoff = READV(sh_name);
@@ -311,12 +311,12 @@ struct kmod_elf *kmod_elf_new(const void *memory, off_t size)
        elf->header.strings.section = READV(e_shstrndx);        \
        elf->header.machine = READV(e_machine)
        if (elf->class & KMOD_ELF_32) {
-               const Elf32_Ehdr *hdr = elf_get_mem(elf, 0);
+               const Elf32_Ehdr *hdr _unused_ = elf_get_mem(elf, 0);
                LOAD_HEADER;
                hdr_size = sizeof(Elf32_Ehdr);
                shdr_size = sizeof(Elf32_Shdr);
        } else {
-               const Elf64_Ehdr *hdr = elf_get_mem(elf, 0);
+               const Elf64_Ehdr *hdr _unused_ = elf_get_mem(elf, 0);
                LOAD_HEADER;
                hdr_size = sizeof(Elf64_Ehdr);
                shdr_size = sizeof(Elf64_Shdr);
@@ -561,11 +561,11 @@ int kmod_elf_strip_section(struct kmod_elf *elf, const char *section)
 #define WRITEV(field, value)                   \
        elf_set_uint(elf, off + offsetof(typeof(*hdr), field), sizeof(hdr->field), value)
        if (elf->class & KMOD_ELF_32) {
-               const Elf32_Shdr *hdr = buf;
+               const Elf32_Shdr *hdr _unused_ = buf;
                uint32_t val = ~(uint32_t)SHF_ALLOC;
                return WRITEV(sh_flags, val);
        } else {
-               const Elf64_Shdr *hdr = buf;
+               const Elf64_Shdr *hdr _unused_ = buf;
                uint64_t val = ~(uint64_t)SHF_ALLOC;
                return WRITEV(sh_flags, val);
        }
index 8716315be3347c885daf5d987fd1c2409dadbb5e..e5c9763cabd207f7ab48c4f026b279475ab8eb33 100644 (file)
@@ -80,6 +80,7 @@
 
 #define _must_check_ __attribute__((warn_unused_result))
 #define _printf_format_(a,b) __attribute__((format (printf, a, b)))
+#define _unused_ __attribute__((unused))
 #define _always_inline_ __inline__ __attribute__((always_inline))
 
 #endif