Skip to content

Commit 32db86d

Browse files
committed
Add fall-through comments.
This patch adds fall-through comments in some cases where -Wextra produces implicit-fallthrough warnings. The patch is non-exhaustive. Apart from architecture-specific code for non-x86_64 architectures, it does not change sunrpc/xdr.c (legacy code, probably should have such changes, but left to be dealt with separately), or places that already had comments about the fall-through but not matching the form expected by -Wimplicit-fallthrough=3 (the default level with -Wextra; my inclination is to adjust those comments to match rather than downgrading to -Wimplicit-fallthrough=1 to allow any comment), or one place where I thought the implicit fallthrough was not correct and so should be handled separately as a bug fix. I think the key thing to consider in review of this patch is whether the fall-through is indeed intended and correct in each place where such a comment is added. Tested for x86_64. * elf/dl-exception.c (_dl_exception_create_format): Add fall-through comments. * elf/ldconfig.c (parse_conf_include): Likewise. * elf/rtld.c (print_statistics): Likewise. * locale/programs/charmap.c (parse_charmap): Likewise. * misc/mntent_r.c (__getmntent_r): Likewise. * posix/wordexp.c (parse_arith): Likewise. (parse_backtick): Likewise. * resolv/ns_ttl.c (ns_parse_ttl): Likewise. * sysdeps/x86/cpu-features.c (init_cpu_features): Likewise. * sysdeps/x86_64/dl-machine.h (elf_machine_rela): Likewise.
1 parent a51bc4f commit 32db86d

File tree

10 files changed

+33
-0
lines changed

10 files changed

+33
-0
lines changed

ChangeLog

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,17 @@
1+
2019-02-12 Joseph Myers <[email protected]>
2+
3+
* elf/dl-exception.c (_dl_exception_create_format): Add
4+
fall-through comments.
5+
* elf/ldconfig.c (parse_conf_include): Likewise.
6+
* elf/rtld.c (print_statistics): Likewise.
7+
* locale/programs/charmap.c (parse_charmap): Likewise.
8+
* misc/mntent_r.c (__getmntent_r): Likewise.
9+
* posix/wordexp.c (parse_arith): Likewise.
10+
(parse_backtick): Likewise.
11+
* resolv/ns_ttl.c (ns_parse_ttl): Likewise.
12+
* sysdeps/x86/cpu-features.c (init_cpu_features): Likewise.
13+
* sysdeps/x86_64/dl-machine.h (elf_machine_rela): Likewise.
14+
115
2019-02-11 Paul A. Clarke <[email protected]>
216

317
* sysdeps/powerpc/fpu/e_sqrt.c (__slow_ieee754_sqrtf):

elf/dl-exception.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -123,6 +123,7 @@ _dl_exception_create_format (struct dl_exception *exception, const char *objname
123123
++p;
124124
break;
125125
}
126+
/* Fall through. */
126127
case 'x':
127128
length += INT_WIDTH / 4;
128129
break;

elf/ldconfig.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1228,6 +1228,7 @@ parse_conf_include (const char *config_file, unsigned int lineno,
12281228

12291229
case GLOB_NOSPACE:
12301230
errno = ENOMEM;
1231+
/* Fall through. */
12311232
case GLOB_ABORTED:
12321233
if (opt_verbose)
12331234
error (0, errno, _("%s:%u: cannot read directory %s"),

elf/rtld.c

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2738,8 +2738,10 @@ print_statistics (hp_timing_t *rtld_total_timep)
27382738
{
27392739
case 3:
27402740
*wp++ = *cp++;
2741+
/* Fall through. */
27412742
case 2:
27422743
*wp++ = *cp++;
2744+
/* Fall through. */
27432745
case 1:
27442746
*wp++ = '.';
27452747
*wp++ = *cp++;
@@ -2801,8 +2803,10 @@ print_statistics (hp_timing_t *rtld_total_timep)
28012803
{
28022804
case 3:
28032805
*wp++ = *cp++;
2806+
/* Fall through. */
28042807
case 2:
28052808
*wp++ = *cp++;
2809+
/* Fall through. */
28062810
case 1:
28072811
*wp++ = '.';
28082812
*wp++ = *cp++;

locale/programs/charmap.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -713,6 +713,7 @@ only WIDTH definitions are allowed to follow the CHARMAP definition"));
713713
state = 95;
714714
continue;
715715
}
716+
/* Fall through. */
716717

717718
case 96:
718719
if (nowtok != tok_number)

misc/mntent_r.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -174,8 +174,10 @@ __getmntent_r (FILE *stream, struct mntent *mp, char *buffer, int bufsiz)
174174
{
175175
case 0:
176176
mp->mnt_freq = 0;
177+
/* Fall through. */
177178
case 1:
178179
mp->mnt_passno = 0;
180+
/* Fall through. */
179181
case 2:
180182
break;
181183
}

posix/wordexp.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -799,6 +799,7 @@ parse_arith (char **word, size_t *word_length, size_t *max_length,
799799

800800
case '(':
801801
++paren_depth;
802+
/* Fall through. */
802803
default:
803804
expr = w_addchar (expr, &expr_length, &expr_maxlen, words[*offset]);
804805
if (expr == NULL)
@@ -2127,6 +2128,7 @@ parse_backtick (char **word, size_t *word_length, size_t *max_length,
21272128

21282129
case '\'':
21292130
squoting = 1 - squoting;
2131+
/* Fall through. */
21302132
default:
21312133
comm = w_addchar (comm, &comm_length, &comm_maxlen, words[*offset]);
21322134
if (comm == NULL)

resolv/ns_ttl.c

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -113,9 +113,13 @@ ns_parse_ttl(const char *src, u_long *dst) {
113113
ch = toupper(ch);
114114
switch (ch) {
115115
case 'W': tmp *= 7;
116+
/* Fall through. */
116117
case 'D': tmp *= 24;
118+
/* Fall through. */
117119
case 'H': tmp *= 60;
120+
/* Fall through. */
118121
case 'M': tmp *= 60;
122+
/* Fall through. */
119123
case 'S': break;
120124
default: goto einval;
121125
}

sysdeps/x86/cpu-features.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -375,6 +375,7 @@ init_cpu_features (struct cpu_features *cpu_features)
375375
of Core i3/i5/i7 processors if AVX is available. */
376376
if (!CPU_FEATURES_CPU_P (cpu_features, AVX))
377377
break;
378+
/* Fall through. */
378379

379380
case 0x1a:
380381
case 0x1e:
@@ -402,6 +403,7 @@ init_cpu_features (struct cpu_features *cpu_features)
402403
/* Xeon E7 v3 with stepping >= 4 has working TSX. */
403404
if (stepping >= 4)
404405
break;
406+
/* Fall through. */
405407
case 0x3c:
406408
case 0x45:
407409
case 0x46:

sysdeps/x86_64/dl-machine.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -347,6 +347,7 @@ elf_machine_rela (struct link_map *map, const ElfW(Rela) *reloc,
347347
/* Set to symbol size plus addend. */
348348
value = sym->st_size;
349349
# endif
350+
/* Fall through. */
350351
case R_X86_64_GLOB_DAT:
351352
case R_X86_64_JUMP_SLOT:
352353
*reloc_addr = value + reloc->r_addend;
@@ -460,6 +461,7 @@ elf_machine_rela (struct link_map *map, const ElfW(Rela) *reloc,
460461
/* Set to symbol size plus addend. */
461462
value = sym->st_size;
462463
# endif
464+
/* Fall through. */
463465
case R_X86_64_32:
464466
value += reloc->r_addend;
465467
*(unsigned int *) reloc_addr = value;

0 commit comments

Comments
 (0)