aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorLucas De Marchi <lucas.demarchi@profusion.mobi>2012-05-23 20:28:53 -0300
committerLucas De Marchi <lucas.demarchi@profusion.mobi>2012-05-23 20:31:18 -0300
commit9e2eadb1d779c53db08a8b65066388c30d877403 (patch)
tree91d059159d943965fa58a43edc79ab9c1fa90db5
parenta70c1e774e595039c321c1c2e99d43e4c9bd0fa8 (diff)
downloadkmod-9e2eadb1d779c53db08a8b65066388c30d877403.tar.gz
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.
-rw-r--r--libkmod/libkmod-elf.c12
-rw-r--r--libkmod/macro.h1
2 files changed, 7 insertions, 6 deletions
diff --git a/libkmod/libkmod-elf.c b/libkmod/libkmod-elf.c
index f8a5d15..38e83c1 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 8716315..e5c9763 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