diff options
author | Sami Kerola | 2017-05-16 10:18:24 +0200 |
---|---|---|
committer | Karel Zak | 2017-06-14 11:48:22 +0200 |
commit | b1557fe98120132e6671924af4ed69f4e21d3de4 (patch) | |
tree | 5b7a0e689fd4a09288f57c3a8eb4f24075ca65a3 /sys-utils | |
parent | libblkid: fix gcc-7 warning -Wint-in-bool-context (diff) | |
download | kernel-qcow2-util-linux-b1557fe98120132e6671924af4ed69f4e21d3de4.tar.gz kernel-qcow2-util-linux-b1557fe98120132e6671924af4ed69f4e21d3de4.tar.xz kernel-qcow2-util-linux-b1557fe98120132e6671924af4ed69f4e21d3de4.zip |
misc: fix ggc-7 fallthrough warnings
(Original patch and commit message edited by Rudi.)
gcc-7 adds -Wimplicit-fallthrough=3 to our default flag -Wextra.
This warning can be silenced by using comment /* fallthrough */
which is also recognized by other tools like coverity. There are
also other valid comments (see man gcc-7) but we consolidate this
style now.
We could have also used __attribute__((fallthrough)) but the comment
looks nice and does not need to be ifdef'ed for compatibility.
Reference: https://gcc.gnu.org/bugzilla/show_bug.cgi?id=7652
Reference: https://developers.redhat.com/blog/2017/03/10/wimplicit-fallthrough-in-gcc-7/
Reviewed-by: Ruediger Meier <ruediger.meier@ga-group.nl>
Suggested-by: Karel Zak <kzak@redhat.com>
Signed-off-by: Sami Kerola <kerolasa@iki.fi>
Diffstat (limited to 'sys-utils')
-rw-r--r-- | sys-utils/flock.c | 2 | ||||
-rw-r--r-- | sys-utils/hwclock.c | 3 | ||||
-rw-r--r-- | sys-utils/ipcrm.c | 3 | ||||
-rw-r--r-- | sys-utils/nsenter.c | 2 | ||||
-rw-r--r-- | sys-utils/unshare.c | 2 |
5 files changed, 8 insertions, 4 deletions
diff --git a/sys-utils/flock.c b/sys-utils/flock.c index 8af1e8ade..50194bdb9 100644 --- a/sys-utils/flock.c +++ b/sys-utils/flock.c @@ -305,7 +305,7 @@ int main(int argc, char *argv[]) if (open_flags & O_RDWR) break; } - /* go through */ + /* fallthrough */ default: /* Other errors */ if (filename) diff --git a/sys-utils/hwclock.c b/sys-utils/hwclock.c index cfb6bcd6b..55f54f5ee 100644 --- a/sys-utils/hwclock.c +++ b/sys-utils/hwclock.c @@ -1209,7 +1209,8 @@ static void out_version(void) * fmt, ... ), show a usage information and terminate the program * afterwards. */ -static void usage(const struct hwclock_control *ctl, const char *fmt, ...) +static void __attribute__((__noreturn__)) +usage(const struct hwclock_control *ctl, const char *fmt, ...) { FILE *usageto; va_list ap; diff --git a/sys-utils/ipcrm.c b/sys-utils/ipcrm.c index 0432b224f..5b71f7d81 100644 --- a/sys-utils/ipcrm.c +++ b/sys-utils/ipcrm.c @@ -346,6 +346,7 @@ int main(int argc, char **argv) ret++; break; } + /* fallthrough */ case 'm': if (!iskey) id = strtos32_or_err(optarg, _("failed to parse argument")); @@ -359,6 +360,7 @@ int main(int argc, char **argv) ret++; break; } + /* fallthrough */ case 'q': if (!iskey) id = strtos32_or_err(optarg, _("failed to parse argument")); @@ -372,6 +374,7 @@ int main(int argc, char **argv) ret++; break; } + /* fallthrough */ case 's': if (!iskey) id = strtos32_or_err(optarg, _("failed to parse argument")); diff --git a/sys-utils/nsenter.c b/sys-utils/nsenter.c index afa1b9c50..6ad0b0fe0 100644 --- a/sys-utils/nsenter.c +++ b/sys-utils/nsenter.c @@ -65,7 +65,7 @@ static struct namespace_file { { .nstype = 0, .name = NULL, .fd = -1 } }; -static void usage(int status) +static void __attribute__((__noreturn__)) usage(int status) { FILE *out = status == EXIT_SUCCESS ? stdout : stderr; diff --git a/sys-utils/unshare.c b/sys-utils/unshare.c index bccd75f3a..6c5c2e2f9 100644 --- a/sys-utils/unshare.c +++ b/sys-utils/unshare.c @@ -238,7 +238,7 @@ static void bind_ns_files_from_child(pid_t *child, int fds[2]) } } -static void usage(int status) +static void __attribute__((__noreturn__)) usage(int status) { FILE *out = status == EXIT_SUCCESS ? stdout : stderr; |