From 32db86d558193ad4ad5a00926ce3c350c89eb8df Mon Sep 17 00:00:00 2001 From: Joseph Myers Date: Tue, 12 Feb 2019 10:30:34 +0000 Subject: 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. --- elf/dl-exception.c | 1 + elf/ldconfig.c | 1 + elf/rtld.c | 4 ++++ 3 files changed, 6 insertions(+) (limited to 'elf') diff --git a/elf/dl-exception.c b/elf/dl-exception.c index f97d179dd1..7ee19a7fc8 100644 --- a/elf/dl-exception.c +++ b/elf/dl-exception.c @@ -123,6 +123,7 @@ _dl_exception_create_format (struct dl_exception *exception, const char *objname ++p; break; } + /* Fall through. */ case 'x': length += INT_WIDTH / 4; break; diff --git a/elf/ldconfig.c b/elf/ldconfig.c index 206cd51df6..3bc9e61891 100644 --- a/elf/ldconfig.c +++ b/elf/ldconfig.c @@ -1228,6 +1228,7 @@ parse_conf_include (const char *config_file, unsigned int lineno, case GLOB_NOSPACE: errno = ENOMEM; + /* Fall through. */ case GLOB_ABORTED: if (opt_verbose) error (0, errno, _("%s:%u: cannot read directory %s"), diff --git a/elf/rtld.c b/elf/rtld.c index 5a90e78ed6..44361ba605 100644 --- a/elf/rtld.c +++ b/elf/rtld.c @@ -2738,8 +2738,10 @@ print_statistics (hp_timing_t *rtld_total_timep) { case 3: *wp++ = *cp++; + /* Fall through. */ case 2: *wp++ = *cp++; + /* Fall through. */ case 1: *wp++ = '.'; *wp++ = *cp++; @@ -2801,8 +2803,10 @@ print_statistics (hp_timing_t *rtld_total_timep) { case 3: *wp++ = *cp++; + /* Fall through. */ case 2: *wp++ = *cp++; + /* Fall through. */ case 1: *wp++ = '.'; *wp++ = *cp++; -- cgit 1.4.1