diff options
| author | Mark Wielaard <[email protected]> | 2016-11-02 13:29:26 +0100 |
|---|---|---|
| committer | Mark Wielaard <[email protected]> | 2016-11-10 11:59:00 +0100 |
| commit | a3cc8182b2ae05290b0eafa74b70746d7befc0e4 (patch) | |
| tree | 7d1f74f9f464b810a95dc7cd78c73930a938924a /src | |
| parent | 33ca0e1b9dfb47c6f9836c7fc19d04bd34337767 (diff) | |
Add GCC7 -Wimplicit-fallthrough support/fixes.
GCC7 will have a new -Wimplicit-fallthrough warning. It did catch one
small buglet in elflint option procession. So it seems useful to enable
to make sure all swatch case fallthroughs are deliberate.
Add configure check to detect whether gcc support -Wimplicit-fallthrough
and enable it. Add fixes and explicit fallthrough comments where necessary.
Signed-off-by: Mark Wielaard <[email protected]>
Diffstat (limited to 'src')
| -rw-r--r-- | src/ChangeLog | 8 | ||||
| -rw-r--r-- | src/addr2line.c | 1 | ||||
| -rw-r--r-- | src/elfcompress.c | 3 | ||||
| -rw-r--r-- | src/elflint.c | 4 | ||||
| -rw-r--r-- | src/objdump.c | 4 |
5 files changed, 17 insertions, 3 deletions
diff --git a/src/ChangeLog b/src/ChangeLog index ee67cffc..b2909b65 100644 --- a/src/ChangeLog +++ b/src/ChangeLog @@ -1,3 +1,11 @@ +2016-11-02 Mark Wielaard <[email protected]> + + * addr2line.c (handle_address): Add fallthrough comment. + * elfcompress.c (parse_opt): Adjust fallthrough comment. + * elflint.c (parse_opt): Add missing break after 'd' case. + (check_sections): Add fallthrough comments. + * objdump.c (parse_opt): Add explantion for fallthrough comment. + 2016-10-22 Kevin Cernekee <[email protected]> * unstrip.c: Fix "invalid string offset" error caused by using the diff --git a/src/addr2line.c b/src/addr2line.c index 0ce854f6..bea24aea 100644 --- a/src/addr2line.c +++ b/src/addr2line.c @@ -632,6 +632,7 @@ handle_address (const char *string, Dwfl *dwfl) case 1: addr = 0; j = i; + /* Fallthrough */ case 2: if (string[j] != '\0') break; diff --git a/src/elfcompress.c b/src/elfcompress.c index 7392cb76..82ab9655 100644 --- a/src/elfcompress.c +++ b/src/elfcompress.c @@ -155,7 +155,8 @@ parse_opt (int key, char *arg __attribute__ ((unused)), argp_error (state, 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, so fallthrough. */ + actually want to consume them. */ + /* Fallthrough */ default: return ARGP_ERR_UNKNOWN; } diff --git a/src/elflint.c b/src/elflint.c index 8b52ee2b..b304a309 100644 --- a/src/elflint.c +++ b/src/elflint.c @@ -210,6 +210,7 @@ parse_opt (int key, char *arg __attribute__ ((unused)), case 'd': is_debuginfo = true; + break; case ARGP_gnuld: gnuld = true; @@ -3963,6 +3964,7 @@ section [%2zu] '%s': merge flag set but entry size is zero\n"), case SHT_NOBITS: if (is_debuginfo) break; + /* Fallthrough */ default: ERROR (gettext ("\ section [%2zu] '%s' has unexpected type %d for an executable section\n"), @@ -4305,7 +4307,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 */ default: if (shndx == 0) ERROR (gettext ("\ diff --git a/src/objdump.c b/src/objdump.c index 1afcd573..f84513ca 100644 --- a/src/objdump.c +++ b/src/objdump.c @@ -234,7 +234,9 @@ parse_opt (int key, char *arg, program_invocation_short_name); exit (EXIT_FAILURE); } - + /* We only use this for checking the number of arguments, we don't + actually want to consume them. */ + /* Fallthrough */ default: return ARGP_ERR_UNKNOWN; } |
