summaryrefslogtreecommitdiffstats
path: root/libelf
diff options
context:
space:
mode:
authorJoshua Watt <[email protected]>2018-02-09 10:27:18 -0600
committerMark Wielaard <[email protected]>2018-02-10 03:19:26 +0100
commit555e15ebe8bf1eb33d00747173cfc80cc65648a4 (patch)
tree6aa9cca6e04514cbc45d88f96a873cc6a4767472 /libelf
parent240a068fcf3eb6bbcda525f80c8778de62621d9e (diff)
Use fallthrough attribute.
Use __attribute__ ((fallthrough)) to indicate switch case fall through instead of a comment. This ensures that the fallthrough warning is not triggered even if the file is pre-processed (hence stripping the comments) before it is compiled. The actual fallback implementation is hidden behind a FALLBACK macro in case the compiler doesn't support it. Finally, the -Wimplict-fallthrough warning was upgraded to only allow the attribute to satisfy it; a comment alone is no longer sufficient. Signed-off-by: Joshua Watt <[email protected]>
Diffstat (limited to 'libelf')
-rw-r--r--libelf/ChangeLog8
-rw-r--r--libelf/elf32_updatenull.c2
-rw-r--r--libelf/elf_begin.c4
-rw-r--r--libelf/elf_cntl.c2
4 files changed, 12 insertions, 4 deletions
diff --git a/libelf/ChangeLog b/libelf/ChangeLog
index 6aa1c6f5..55ab25cc 100644
--- a/libelf/ChangeLog
+++ b/libelf/ChangeLog
@@ -1,3 +1,11 @@
+2018-02-09 Joshua Watt <[email protected]>
+
+ * elf32_updatenull.c (updatenull_wrlock): Use FALLTHROUGH macro
+ instead of comment.
+ * elf_begin.c (read_unmmaped_file): Likewise.
+ (elf_begin): Likewise.
+ * elf_cntl.c (elf_cntl): Likewise.
+
2017-10-04 Mark Wielaard <[email protected]>
* elf_begin.c (file_read_elf): Skip sanity checking e_shoff if scncnt
diff --git a/libelf/elf32_updatenull.c b/libelf/elf32_updatenull.c
index d83c0b3f..3e9ef61b 100644
--- a/libelf/elf32_updatenull.c
+++ b/libelf/elf32_updatenull.c
@@ -232,7 +232,7 @@ __elfw2(LIBELFBITS,updatenull_wrlock) (Elf *elf, int *change_bop, size_t shnum)
__libelf_seterrno (ELF_E_GROUP_NOT_REL);
return -1;
}
- /* FALLTHROUGH */
+ FALLTHROUGH;
case SHT_SYMTAB_SHNDX:
sh_entsize = elf_typesize (32, ELF_T_WORD, 1);
break;
diff --git a/libelf/elf_begin.c b/libelf/elf_begin.c
index fb3a5b57..b20ab4f3 100644
--- a/libelf/elf_begin.c
+++ b/libelf/elf_begin.c
@@ -611,7 +611,7 @@ read_unmmaped_file (int fildes, off_t offset, size_t maxsize, Elf_Cmd cmd,
? sizeof (Elf32_Ehdr) : sizeof (Elf64_Ehdr)))
return file_read_elf (fildes, NULL, mem.header, offset, maxsize, cmd,
parent);
- /* FALLTHROUGH */
+ FALLTHROUGH;
default:
break;
@@ -1126,7 +1126,7 @@ elf_begin (int fildes, Elf_Cmd cmd, Elf *ref)
retval = NULL;
break;
}
- /* FALLTHROUGH */
+ FALLTHROUGH;
case ELF_C_READ:
case ELF_C_READ_MMAP:
diff --git a/libelf/elf_cntl.c b/libelf/elf_cntl.c
index ab13ffb6..fd681789 100644
--- a/libelf/elf_cntl.c
+++ b/libelf/elf_cntl.c
@@ -62,7 +62,7 @@ elf_cntl (Elf *elf, Elf_Cmd cmd)
result = -1;
break;
}
- /* FALLTHROUGH */
+ FALLTHROUGH;
case ELF_C_FDDONE:
/* Mark the file descriptor as not usable. */