b1dca6
commit 32db86d558193ad4ad5a00926ce3c350c89eb8df
b1dca6
Author: Joseph Myers <joseph@codesourcery.com>
b1dca6
Date:   Tue Feb 12 10:30:34 2019 +0000
b1dca6
b1dca6
    Add fall-through comments.
b1dca6
    
b1dca6
    This patch adds fall-through comments in some cases where -Wextra
b1dca6
    produces implicit-fallthrough warnings.
b1dca6
    
b1dca6
    The patch is non-exhaustive.  Apart from architecture-specific code
b1dca6
    for non-x86_64 architectures, it does not change sunrpc/xdr.c (legacy
b1dca6
    code, probably should have such changes, but left to be dealt with
b1dca6
    separately), or places that already had comments about the
b1dca6
    fall-through but not matching the form expected by
b1dca6
    -Wimplicit-fallthrough=3 (the default level with -Wextra; my
b1dca6
    inclination is to adjust those comments to match rather than
b1dca6
    downgrading to -Wimplicit-fallthrough=1 to allow any comment), or one
b1dca6
    place where I thought the implicit fallthrough was not correct and so
b1dca6
    should be handled separately as a bug fix.  I think the key thing to
b1dca6
    consider in review of this patch is whether the fall-through is indeed
b1dca6
    intended and correct in each place where such a comment is added.
b1dca6
    
b1dca6
    Tested for x86_64.
b1dca6
    
b1dca6
            * elf/dl-exception.c (_dl_exception_create_format): Add
b1dca6
            fall-through comments.
b1dca6
            * elf/ldconfig.c (parse_conf_include): Likewise.
b1dca6
            * elf/rtld.c (print_statistics): Likewise.
b1dca6
            * locale/programs/charmap.c (parse_charmap): Likewise.
b1dca6
            * misc/mntent_r.c (__getmntent_r): Likewise.
b1dca6
            * posix/wordexp.c (parse_arith): Likewise.
b1dca6
            (parse_backtick): Likewise.
b1dca6
            * resolv/ns_ttl.c (ns_parse_ttl): Likewise.
b1dca6
            * sysdeps/x86/cpu-features.c (init_cpu_features): Likewise.
b1dca6
            * sysdeps/x86_64/dl-machine.h (elf_machine_rela): Likewise.
b1dca6
b1dca6
diff --git a/elf/dl-exception.c b/elf/dl-exception.c
b1dca6
index 3e8e0ba3f1442005..d24bf30a5cf39bc2 100644
b1dca6
--- a/elf/dl-exception.c
b1dca6
+++ b/elf/dl-exception.c
b1dca6
@@ -123,6 +123,7 @@ _dl_exception_create_format (struct dl_exception *exception, const char *objname
b1dca6
 		  ++p;
b1dca6
 		  break;
b1dca6
 		}
b1dca6
+	      /* Fall through.  */
b1dca6
 	    case 'x':
b1dca6
 	      length += INT_WIDTH / 4;
b1dca6
 	      break;
b1dca6
diff --git a/elf/ldconfig.c b/elf/ldconfig.c
b1dca6
index fbdd814edf59bc77..ed7d9ab0412d93fd 100644
b1dca6
--- a/elf/ldconfig.c
b1dca6
+++ b/elf/ldconfig.c
b1dca6
@@ -1228,6 +1228,7 @@ parse_conf_include (const char *config_file, unsigned int lineno,
b1dca6
 
b1dca6
     case GLOB_NOSPACE:
b1dca6
       errno = ENOMEM;
b1dca6
+      /* Fall through.  */
b1dca6
     case GLOB_ABORTED:
b1dca6
       if (opt_verbose)
b1dca6
 	error (0, errno, _("%s:%u: cannot read directory %s"),
b1dca6
diff --git a/elf/rtld.c b/elf/rtld.c
b1dca6
index 7f030f75a22c532e..8bb5f548a0ff8eb4 100644
b1dca6
--- a/elf/rtld.c
b1dca6
+++ b/elf/rtld.c
b1dca6
@@ -2734,8 +2734,10 @@ print_statistics (hp_timing_t *rtld_total_timep)
b1dca6
 	{
b1dca6
 	case 3:
b1dca6
 	  *wp++ = *cp++;
b1dca6
+	  /* Fall through.  */
b1dca6
 	case 2:
b1dca6
 	  *wp++ = *cp++;
b1dca6
+	  /* Fall through.  */
b1dca6
 	case 1:
b1dca6
 	  *wp++ = '.';
b1dca6
 	  *wp++ = *cp++;
b1dca6
@@ -2797,8 +2799,10 @@ print_statistics (hp_timing_t *rtld_total_timep)
b1dca6
 	{
b1dca6
 	case 3:
b1dca6
 	  *wp++ = *cp++;
b1dca6
+	  /* Fall through.  */
b1dca6
 	case 2:
b1dca6
 	  *wp++ = *cp++;
b1dca6
+	  /* Fall through.  */
b1dca6
 	case 1:
b1dca6
 	  *wp++ = '.';
b1dca6
 	  *wp++ = *cp++;
b1dca6
diff --git a/locale/programs/charmap.c b/locale/programs/charmap.c
b1dca6
index 2d54dd3c027d11d2..8041a0e5d292f3f5 100644
b1dca6
--- a/locale/programs/charmap.c
b1dca6
+++ b/locale/programs/charmap.c
b1dca6
@@ -713,6 +713,7 @@ only WIDTH definitions are allowed to follow the CHARMAP definition"));
b1dca6
 	      state = 95;
b1dca6
 	      continue;
b1dca6
 	    }
b1dca6
+	  /* Fall through.  */
b1dca6
 
b1dca6
 	case 96:
b1dca6
 	  if (nowtok != tok_number)
b1dca6
diff --git a/misc/mntent_r.c b/misc/mntent_r.c
b1dca6
index 7bb224f044150ab4..add39d4537eaccb5 100644
b1dca6
--- a/misc/mntent_r.c
b1dca6
+++ b/misc/mntent_r.c
b1dca6
@@ -167,8 +167,10 @@ get_mnt_entry (FILE *stream, struct mntent *mp, char *buffer, int bufsiz)
b1dca6
     {
b1dca6
     case 0:
b1dca6
       mp->mnt_freq = 0;
b1dca6
+      /* Fall through.  */
b1dca6
     case 1:
b1dca6
       mp->mnt_passno = 0;
b1dca6
+      /* Fall through.  */
b1dca6
     case 2:
b1dca6
       break;
b1dca6
     }
b1dca6
diff --git a/posix/wordexp.c b/posix/wordexp.c
b1dca6
index 7548e0329fdeafaa..048a8068544c81fa 100644
b1dca6
--- a/posix/wordexp.c
b1dca6
+++ b/posix/wordexp.c
b1dca6
@@ -799,6 +799,7 @@ parse_arith (char **word, size_t *word_length, size_t *max_length,
b1dca6
 
b1dca6
 	case '(':
b1dca6
 	  ++paren_depth;
b1dca6
+	  /* Fall through.  */
b1dca6
 	default:
b1dca6
 	  expr = w_addchar (expr, &expr_length, &expr_maxlen, words[*offset]);
b1dca6
 	  if (expr == NULL)
b1dca6
@@ -2127,6 +2128,7 @@ parse_backtick (char **word, size_t *word_length, size_t *max_length,
b1dca6
 
b1dca6
 	case '\'':
b1dca6
 	  squoting = 1 - squoting;
b1dca6
+	  /* Fall through.  */
b1dca6
 	default:
b1dca6
 	  comm = w_addchar (comm, &comm_length, &comm_maxlen, words[*offset]);
b1dca6
 	  if (comm == NULL)
b1dca6
diff --git a/resolv/ns_ttl.c b/resolv/ns_ttl.c
b1dca6
index 079948790b94b05e..d29d9dc00cfcab2c 100644
b1dca6
--- a/resolv/ns_ttl.c
b1dca6
+++ b/resolv/ns_ttl.c
b1dca6
@@ -113,9 +113,13 @@ ns_parse_ttl(const char *src, u_long *dst) {
b1dca6
 			ch = toupper(ch);
b1dca6
 		switch (ch) {
b1dca6
 		case 'W':  tmp *= 7;
b1dca6
+		  /* Fall through.  */
b1dca6
 		case 'D':  tmp *= 24;
b1dca6
+		  /* Fall through.  */
b1dca6
 		case 'H':  tmp *= 60;
b1dca6
+		  /* Fall through.  */
b1dca6
 		case 'M':  tmp *= 60;
b1dca6
+		  /* Fall through.  */
b1dca6
 		case 'S':  break;
b1dca6
 		default:   goto einval;
b1dca6
 		}
b1dca6
diff --git a/sysdeps/x86/cpu-features.c b/sysdeps/x86/cpu-features.c
b1dca6
index 3a02a9c7d08f9603..ade37a9bb3de86cc 100644
b1dca6
--- a/sysdeps/x86/cpu-features.c
b1dca6
+++ b/sysdeps/x86/cpu-features.c
b1dca6
@@ -374,6 +374,7 @@ init_cpu_features (struct cpu_features *cpu_features)
b1dca6
 		 of Core i3/i5/i7 processors if AVX is available.  */
b1dca6
 	      if (!CPU_FEATURES_CPU_P (cpu_features, AVX))
b1dca6
 		break;
b1dca6
+	      /* Fall through.  */
b1dca6
 
b1dca6
 	    case 0x1a:
b1dca6
 	    case 0x1e:
b1dca6
@@ -401,6 +402,7 @@ init_cpu_features (struct cpu_features *cpu_features)
b1dca6
 	      /* Xeon E7 v3 with stepping >= 4 has working TSX.  */
b1dca6
 	      if (stepping >= 4)
b1dca6
 		break;
b1dca6
+	      /* Fall through.  */
b1dca6
 	    case 0x3c:
b1dca6
 	    case 0x45:
b1dca6
 	    case 0x46:
b1dca6
diff --git a/sysdeps/x86_64/dl-machine.h b/sysdeps/x86_64/dl-machine.h
b1dca6
index 1942ed5061d18c68..23afb3c05dbe17d6 100644
b1dca6
--- a/sysdeps/x86_64/dl-machine.h
b1dca6
+++ b/sysdeps/x86_64/dl-machine.h
b1dca6
@@ -347,6 +347,7 @@ elf_machine_rela (struct link_map *map, const ElfW(Rela) *reloc,
b1dca6
 	  /* Set to symbol size plus addend.  */
b1dca6
 	  value = sym->st_size;
b1dca6
 # endif
b1dca6
+	  /* Fall through.  */
b1dca6
 	case R_X86_64_GLOB_DAT:
b1dca6
 	case R_X86_64_JUMP_SLOT:
b1dca6
 	  *reloc_addr = value + reloc->r_addend;
b1dca6
@@ -460,6 +461,7 @@ elf_machine_rela (struct link_map *map, const ElfW(Rela) *reloc,
b1dca6
 	  /* Set to symbol size plus addend.  */
b1dca6
 	  value = sym->st_size;
b1dca6
 #  endif
b1dca6
+	  /* Fall through.  */
b1dca6
 	case R_X86_64_32:
b1dca6
 	  value += reloc->r_addend;
b1dca6
 	  *(unsigned int *) reloc_addr = value;