From: Lucas De Marchi Date: Wed, 23 May 2012 23:28:53 +0000 (-0300) Subject: Silence clang warnings with __unused__ attribute X-Git-Tag: v9~34 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=9e2eadb1d779c53db08a8b65066388c30d877403;p=thirdparty%2Fkmod.git Silence clang warnings with __unused__ attribute 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. --- diff --git a/libkmod/libkmod-elf.c b/libkmod/libkmod-elf.c index f8a5d15b..38e83c10 100644 --- a/libkmod/libkmod-elf.c +++ b/libkmod/libkmod-elf.c @@ -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); } diff --git a/libkmod/macro.h b/libkmod/macro.h index 8716315b..e5c9763c 100644 --- a/libkmod/macro.h +++ b/libkmod/macro.h @@ -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