rjw | 1f88458 | 2022-01-06 17:20:42 +0800 | [diff] [blame^] | 1 | From d70d92889c4a8b0781207343a73b1dc4eccdffd3 Mon Sep 17 00:00:00 2001 |
| 2 | From: Khem Raj <raj.khem@gmail.com> |
| 3 | Date: Tue, 25 Apr 2017 15:50:55 -0700 |
| 4 | Subject: [PATCH 1/2] Fix fallthrough warnings |
| 5 | |
| 6 | Upstream-Status: Pending |
| 7 | |
| 8 | Signed-off-by: Khem Raj <raj.khem@gmail.com> |
| 9 | --- |
| 10 | backends/i386_regs.c | 1 + |
| 11 | backends/i386_retval.c | 1 + |
| 12 | backends/linux-core-note.c | 4 ++-- |
| 13 | backends/mips_retval.c | 2 +- |
| 14 | backends/parisc_retval.c | 2 +- |
| 15 | backends/ppc_regs.c | 2 +- |
| 16 | backends/x86_64_regs.c | 1 + |
| 17 | libcpu/i386_disasm.c | 2 +- |
| 18 | libdw/cfi.c | 3 +++ |
| 19 | libdw/encoded-value.h | 1 + |
| 20 | libdwfl/dwfl_report_elf.c | 1 + |
| 21 | src/addr2line.c | 1 + |
| 22 | src/elflint.c | 4 +++- |
| 23 | src/objdump.c | 2 +- |
| 24 | 14 files changed, 19 insertions(+), 8 deletions(-) |
| 25 | |
| 26 | diff --git a/backends/i386_regs.c b/backends/i386_regs.c |
| 27 | index 5cf0d81..11b0bcb 100644 |
| 28 | --- a/backends/i386_regs.c |
| 29 | +++ b/backends/i386_regs.c |
| 30 | @@ -89,6 +89,7 @@ i386_register_info (Ebl *ebl __attribute__ ((unused)), |
| 31 | case 5: |
| 32 | case 8: |
| 33 | *type = DW_ATE_address; |
| 34 | + /* fallthru */ |
| 35 | case 0 ... 3: |
| 36 | case 6 ... 7: |
| 37 | name[0] = 'e'; |
| 38 | diff --git a/backends/i386_retval.c b/backends/i386_retval.c |
| 39 | index c3bab10..ffbf901 100644 |
| 40 | --- a/backends/i386_retval.c |
| 41 | +++ b/backends/i386_retval.c |
| 42 | @@ -137,6 +137,7 @@ i386_return_value_location (Dwarf_Die *functypedie, const Dwarf_Op **locp) |
| 43 | |
| 44 | /* Else fall through. */ |
| 45 | } |
| 46 | + /* fallthru */ |
| 47 | |
| 48 | case DW_TAG_structure_type: |
| 49 | case DW_TAG_class_type: |
| 50 | diff --git a/backends/linux-core-note.c b/backends/linux-core-note.c |
| 51 | index 9d01219..a6cd5ab 100644 |
| 52 | --- a/backends/linux-core-note.c |
| 53 | +++ b/backends/linux-core-note.c |
| 54 | @@ -194,8 +194,8 @@ EBLHOOK(core_note) (nhdr, name, regs_offset, nregloc, reglocs, nitems, items) |
| 55 | case sizeof "CORE": |
| 56 | if (memcmp (name, "CORE", nhdr->n_namesz) == 0) |
| 57 | break; |
| 58 | - /* Buggy old Linux kernels didn't terminate "LINUX". |
| 59 | - Fall through. */ |
| 60 | + /* Buggy old Linux kernels didn't terminate "LINUX". */ |
| 61 | + /* fallthru */ |
| 62 | |
| 63 | case sizeof "LINUX": |
| 64 | if (memcmp (name, "LINUX", nhdr->n_namesz) == 0) |
| 65 | diff --git a/backends/mips_retval.c b/backends/mips_retval.c |
| 66 | index 33f12a7..b25b1b7 100644 |
| 67 | --- a/backends/mips_retval.c |
| 68 | +++ b/backends/mips_retval.c |
| 69 | @@ -300,7 +300,7 @@ mips_return_value_location (Dwarf_Die *functypedie, const Dwarf_Op **locp) |
| 70 | |
| 71 | /* Else fall through. Shouldn't happen though (at least with gcc) */ |
| 72 | } |
| 73 | - |
| 74 | + /* fallthrough */ |
| 75 | case DW_TAG_structure_type: |
| 76 | case DW_TAG_class_type: |
| 77 | case DW_TAG_union_type: |
| 78 | diff --git a/backends/parisc_retval.c b/backends/parisc_retval.c |
| 79 | index 592a702..7aa5b17 100644 |
| 80 | --- a/backends/parisc_retval.c |
| 81 | +++ b/backends/parisc_retval.c |
| 82 | @@ -167,7 +167,7 @@ parisc_return_value_location_ (Dwarf_Die *functypedie, const Dwarf_Op **locp, in |
| 83 | |
| 84 | /* Else fall through. */ |
| 85 | } |
| 86 | - |
| 87 | + /* fallthru */ |
| 88 | case DW_TAG_structure_type: |
| 89 | case DW_TAG_class_type: |
| 90 | case DW_TAG_union_type: |
| 91 | diff --git a/backends/ppc_regs.c b/backends/ppc_regs.c |
| 92 | index 637c25d..8277c54 100644 |
| 93 | --- a/backends/ppc_regs.c |
| 94 | +++ b/backends/ppc_regs.c |
| 95 | @@ -137,7 +137,7 @@ ppc_register_info (Ebl *ebl __attribute__ ((unused)), |
| 96 | case 100: |
| 97 | if (*bits == 32) |
| 98 | return stpcpy (name, "mq") + 1 - name; |
| 99 | - |
| 100 | + /* fallthru */ |
| 101 | case 102 ... 107: |
| 102 | name[0] = 's'; |
| 103 | name[1] = 'p'; |
| 104 | diff --git a/backends/x86_64_regs.c b/backends/x86_64_regs.c |
| 105 | index 8eb0d33..e941cf3 100644 |
| 106 | --- a/backends/x86_64_regs.c |
| 107 | +++ b/backends/x86_64_regs.c |
| 108 | @@ -84,6 +84,7 @@ x86_64_register_info (Ebl *ebl __attribute__ ((unused)), |
| 109 | |
| 110 | case 6 ... 7: |
| 111 | *type = DW_ATE_address; |
| 112 | + /* fallthru */ |
| 113 | case 0 ... 5: |
| 114 | name[0] = 'r'; |
| 115 | name[1] = baseregs[regno][0]; |
| 116 | diff --git a/libcpu/i386_disasm.c b/libcpu/i386_disasm.c |
| 117 | index 0eabe0a..84b85d0 100644 |
| 118 | --- a/libcpu/i386_disasm.c |
| 119 | +++ b/libcpu/i386_disasm.c |
| 120 | @@ -788,7 +788,7 @@ i386_disasm (const uint8_t **startp, const uint8_t *end, GElf_Addr addr, |
| 121 | ++param_start; |
| 122 | break; |
| 123 | } |
| 124 | - |
| 125 | + /* fallthru */ |
| 126 | default: |
| 127 | assert (! "INVALID not handled"); |
| 128 | abort (); |
| 129 | diff --git a/libdw/cfi.c b/libdw/cfi.c |
| 130 | index aeb48e6..38b3050 100644 |
| 131 | --- a/libdw/cfi.c |
| 132 | +++ b/libdw/cfi.c |
| 133 | @@ -143,6 +143,7 @@ execute_cfi (Dwarf_CFI *cache, |
| 134 | |
| 135 | case DW_CFA_advance_loc1: |
| 136 | operand = *program++; |
| 137 | + /* fallthru */ |
| 138 | case DW_CFA_advance_loc + 0 ... DW_CFA_advance_loc + CFI_PRIMARY_MAX: |
| 139 | advance_loc: |
| 140 | loc += operand * cie->code_alignment_factor; |
| 141 | @@ -227,6 +228,7 @@ execute_cfi (Dwarf_CFI *cache, |
| 142 | |
| 143 | case DW_CFA_offset_extended: |
| 144 | get_uleb128 (operand, program); |
| 145 | + cfi_assert (program < end); |
| 146 | case DW_CFA_offset + 0 ... DW_CFA_offset + CFI_PRIMARY_MAX: |
| 147 | get_uleb128 (offset, program); |
| 148 | offset *= cie->data_alignment_factor; |
| 149 | @@ -290,6 +292,7 @@ execute_cfi (Dwarf_CFI *cache, |
| 150 | |
| 151 | case DW_CFA_restore_extended: |
| 152 | get_uleb128 (operand, program); |
| 153 | + /* fallthru */ |
| 154 | case DW_CFA_restore + 0 ... DW_CFA_restore + CFI_PRIMARY_MAX: |
| 155 | |
| 156 | if (unlikely (abi_cfi) && likely (opcode == DW_CFA_restore)) |
| 157 | diff --git a/libdw/encoded-value.h b/libdw/encoded-value.h |
| 158 | index e118a1c..17190c8 100644 |
| 159 | --- a/libdw/encoded-value.h |
| 160 | +++ b/libdw/encoded-value.h |
| 161 | @@ -82,6 +82,7 @@ encoded_value_size (const Elf_Data *data, const unsigned char e_ident[], |
| 162 | if (*end++ & 0x80u) |
| 163 | return end - p; |
| 164 | } |
| 165 | + return 0; |
| 166 | |
| 167 | default: |
| 168 | abort (); |
| 169 | diff --git a/libdwfl/dwfl_report_elf.c b/libdwfl/dwfl_report_elf.c |
| 170 | index 062a647..8a30816 100644 |
| 171 | --- a/libdwfl/dwfl_report_elf.c |
| 172 | +++ b/libdwfl/dwfl_report_elf.c |
| 173 | @@ -185,6 +185,7 @@ __libdwfl_report_elf (Dwfl *dwfl, const char *name, const char *file_name, |
| 174 | case ET_CORE: |
| 175 | /* An assigned base address is meaningless for these. */ |
| 176 | base = 0; |
| 177 | + /* fallthru */ |
| 178 | |
| 179 | case ET_DYN: |
| 180 | default:; |
| 181 | diff --git a/src/addr2line.c b/src/addr2line.c |
| 182 | index 48f017b..4a2cc5b 100644 |
| 183 | --- a/src/addr2line.c |
| 184 | +++ b/src/addr2line.c |
| 185 | @@ -457,6 +457,7 @@ handle_address (const char *string, Dwfl *dwfl) |
| 186 | case 1: |
| 187 | addr = 0; |
| 188 | j = i; |
| 189 | + /* fallthru */ |
| 190 | case 2: |
| 191 | if (string[j] != '\0') |
| 192 | break; |
| 193 | diff --git a/src/elflint.c b/src/elflint.c |
| 194 | index a25af97..3d75391 100644 |
| 195 | --- a/src/elflint.c |
| 196 | +++ b/src/elflint.c |
| 197 | @@ -218,6 +218,7 @@ parse_opt (int key, char *arg __attribute__ ((unused)), |
| 198 | |
| 199 | case 'd': |
| 200 | is_debuginfo = true; |
| 201 | + break; |
| 202 | |
| 203 | case ARGP_gnuld: |
| 204 | gnuld = true; |
| 205 | @@ -3735,6 +3736,7 @@ section [%2zu] '%s': merge flag set but entry size is zero\n"), |
| 206 | case SHT_NOBITS: |
| 207 | if (is_debuginfo) |
| 208 | break; |
| 209 | + /* fallthru */ |
| 210 | default: |
| 211 | ERROR (gettext ("\ |
| 212 | section [%2zu] '%s' has unexpected type %d for an executable section\n"), |
| 213 | @@ -4036,7 +4038,7 @@ section [%2d] '%s': unknown core file note type %" PRIu32 |
| 214 | if (nhdr.n_namesz == sizeof "Linux" |
| 215 | && !memcmp (data->d_buf + name_offset, "Linux", sizeof "Linux")) |
| 216 | break; |
| 217 | - |
| 218 | + /* fallthru */ |
| 219 | default: |
| 220 | if (shndx == 0) |
| 221 | ERROR (gettext ("\ |
| 222 | diff --git a/src/objdump.c b/src/objdump.c |
| 223 | index 1234c79..8c39a5b 100644 |
| 224 | --- a/src/objdump.c |
| 225 | +++ b/src/objdump.c |
| 226 | @@ -238,7 +238,7 @@ parse_opt (int key, char *arg, |
| 227 | program_invocation_short_name); |
| 228 | exit (EXIT_FAILURE); |
| 229 | } |
| 230 | - |
| 231 | + /* fallthru */ |
| 232 | default: |
| 233 | return ARGP_ERR_UNKNOWN; |
| 234 | } |
| 235 | -- |
| 236 | 2.12.2 |
| 237 | |