diff options
author | Joshua Watt <jpewhacker@gmail.com> | 2018-02-09 10:27:18 -0600 |
---|---|---|
committer | Mark Wielaard <mark@klomp.org> | 2018-02-10 03:19:26 +0100 |
commit | 555e15ebe8bf1eb33d00747173cfc80cc65648a4 (patch) | |
tree | 6aa9cca6e04514cbc45d88f96a873cc6a4767472 /src | |
parent | 240a068fcf3eb6bbcda525f80c8778de62621d9e (diff) | |
download | elfutils-555e15ebe8bf1eb33d00747173cfc80cc65648a4.tar.gz |
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 <JPEWhacker@gmail.com>
Diffstat (limited to 'src')
-rw-r--r-- | src/ChangeLog | 15 | ||||
-rw-r--r-- | src/addr2line.c | 2 | ||||
-rw-r--r-- | src/elfcompress.c | 2 | ||||
-rw-r--r-- | src/elflint.c | 8 | ||||
-rw-r--r-- | src/objdump.c | 2 | ||||
-rw-r--r-- | src/readelf.c | 8 | ||||
-rw-r--r-- | src/strings.c | 2 |
7 files changed, 27 insertions, 12 deletions
diff --git a/src/ChangeLog b/src/ChangeLog index a0bb7a25..a490705f 100644 --- a/src/ChangeLog +++ b/src/ChangeLog @@ -1,3 +1,18 @@ +2018-02-09 Joshua Watt <JPEWhacker@gmail.com> + + * addr2line.c (handle_address): Use FALLTHROUGH macro instead of + comment. + * elfcompress.c (parse_opt): Likewise. + * elflint.c (check_dynamic): Likewise. + (check_sections): Likewise. + (check_note_data): Likewise. + * objdump.c (parse_opt): Likewise. + * readelf.c (parse_opt): Likewise. + (attr_callback): Likewise. + (handle_auxv_note): Likewise. + * strings.c (parse_opt): Likewise. + * backtrace.c (callback_verify): Likewise. + 2018-01-25 Mark Wielaard <mark@klomp.org> * readelf.c (print_debug_ranges_section): Initialize cu to last_cu. diff --git a/src/addr2line.c b/src/addr2line.c index ba414a74..444ee52c 100644 --- a/src/addr2line.c +++ b/src/addr2line.c @@ -618,7 +618,7 @@ handle_address (const char *string, Dwfl *dwfl) case 1: addr = 0; j = i; - /* Fallthrough */ + FALLTHROUGH; case 2: if (string[j] != '\0') break; diff --git a/src/elfcompress.c b/src/elfcompress.c index 8e0d5c55..25378a45 100644 --- a/src/elfcompress.c +++ b/src/elfcompress.c @@ -149,7 +149,7 @@ parse_opt (int key, char *arg __attribute__ ((unused)), N_("Only one input file allowed together with '-o'")); /* We only use this for checking the number of arguments, we don't actually want to consume them. */ - /* Fallthrough */ + FALLTHROUGH; default: return ARGP_ERR_UNKNOWN; } diff --git a/src/elflint.c b/src/elflint.c index 51e53c23..df1b3a03 100644 --- a/src/elflint.c +++ b/src/elflint.c @@ -1764,7 +1764,7 @@ section [%2d] '%s': entry %zu: pointer does not match address of section [%2d] ' if (dyn->d_tag < DT_ADDRRNGLO || dyn->d_tag > DT_ADDRRNGHI) /* Value is no pointer. */ break; - /* FALLTHROUGH */ + FALLTHROUGH; case DT_AUXILIARY: case DT_FILTER: @@ -3993,7 +3993,7 @@ section [%2zu] '%s': merge flag set but entry size is zero\n"), case SHT_NOBITS: if (is_debuginfo) break; - /* Fallthrough */ + FALLTHROUGH; default: ERROR (gettext ("\ section [%2zu] '%s' has unexpected type %d for an executable section\n"), @@ -4137,7 +4137,7 @@ section [%2zu] '%s': ELF header says this is the section header string table but ERROR (gettext ("\ section [%2zu] '%s': relocatable files cannot have dynamic symbol tables\n"), cnt, section_name (ebl, cnt)); - /* FALLTHROUGH */ + FALLTHROUGH; case SHT_SYMTAB: check_symtab (ebl, ehdr, shdr, cnt); break; @@ -4336,7 +4336,7 @@ section [%2d] '%s': unknown core file note type %" PRIu32 if (nhdr.n_namesz == sizeof "Linux" && !memcmp (data->d_buf + name_offset, "Linux", sizeof "Linux")) break; - /* Fallthrough */ + FALLTHROUGH; default: if (shndx == 0) ERROR (gettext ("\ diff --git a/src/objdump.c b/src/objdump.c index 860cfac6..0dd9a6aa 100644 --- a/src/objdump.c +++ b/src/objdump.c @@ -223,7 +223,7 @@ parse_opt (int key, char *arg, } /* We only use this for checking the number of arguments, we don't actually want to consume them. */ - /* Fallthrough */ + FALLTHROUGH; default: return ARGP_ERR_UNKNOWN; } diff --git a/src/readelf.c b/src/readelf.c index 6c49d305..d606cf5a 100644 --- a/src/readelf.c +++ b/src/readelf.c @@ -480,7 +480,7 @@ parse_opt (int key, char *arg, print_string_sections = true; break; } - /* Fall through. */ + FALLTHROUGH; case 'x': add_dump_section (arg, false); any_control_option = true; @@ -6081,7 +6081,7 @@ attr_callback (Dwarf_Attribute *attrp, void *arg) dwarf_form_name (form), (uintmax_t) num); return DWARF_CB_OK; } - /* else fallthrough */ + FALLTHROUGH; /* These cases always take a loclistptr and no constant. */ case DW_AT_location: @@ -6269,7 +6269,7 @@ attr_callback (Dwarf_Attribute *attrp, void *arg) print_block (block.length, block.data); break; } - /* Fall through. */ + FALLTHROUGH; case DW_AT_location: case DW_AT_data_location: @@ -9326,7 +9326,7 @@ handle_auxv_note (Ebl *ebl, Elf *core, GElf_Word descsz, GElf_Off desc_pos) printf (" %s\n", name); break; } - /* Fall through */ + FALLTHROUGH; case 'x': /* hex */ case 'p': /* address */ case 's': /* address of string */ diff --git a/src/strings.c b/src/strings.c index d214356c..03d0f133 100644 --- a/src/strings.c +++ b/src/strings.c @@ -246,7 +246,7 @@ parse_opt (int key, char *arg, case 'b': case 'B': big_endian = true; - /* FALLTHROUGH */ + FALLTHROUGH; case 'l': case 'L': |