From 221e74c27c195d021572b03df540d9f131f1bb45 Mon Sep 17 00:00:00 2001 From: Michael Holzheu Date: Tue, 5 Sep 2017 15:52:54 +0200 Subject: [PATCH] Get rid of gcc 7 "fall through" warnings With gcc 7 we get warnings like the following: fdasd.c: In function 'main': fdasd.c:3055:4: warning: this statement may fall through [-Wimplicit-fallthrough=] fdasd_exit(&anchor, 0); ^~~~~~~~~~~~~~~~~~~~~~ fdasd.c:3056:3: note: here default: ^~~~~~~ Fix this by marking functions with "__noreturn" to help gcc. Signed-off-by: Michael Holzheu --- fdasd/fdasd.c | 2 +- hyptop/hyptop.c | 2 +- hyptop/hyptop.h | 2 +- ipl_tools/cmd_chreipl.c | 2 +- ipl_tools/cmd_chshut.c | 2 +- ipl_tools/cmd_lsreipl.c | 2 +- ipl_tools/cmd_lsshut.c | 2 +- ipl_tools/ipl_tools.h | 6 ++++-- ipl_tools/main.c | 4 ++-- iucvterm/src/getopt.c | 6 +++--- iucvterm/src/ttyrun.c | 4 ++-- zdump/opts.c | 6 +++--- 12 files changed, 21 insertions(+), 19 deletions(-) diff --git a/fdasd/fdasd.c b/fdasd/fdasd.c index 67e36b9f..1d24dd52 100644 --- a/fdasd/fdasd.c +++ b/fdasd/fdasd.c @@ -308,7 +308,7 @@ static void fdasd_cleanup(fdasd_anchor_t *anchor) /* * Exit fdasd. */ -static void fdasd_exit(fdasd_anchor_t *anchor, int rc) +static void __noreturn fdasd_exit(fdasd_anchor_t *anchor, int rc) { fdasd_cleanup(anchor); exit(rc); diff --git a/hyptop/hyptop.c b/hyptop/hyptop.c index 2de33e89..29dbb14e 100644 --- a/hyptop/hyptop.c +++ b/hyptop/hyptop.c @@ -348,7 +348,7 @@ void hyptop_text_mode(void) /* * Exit hyptop */ -void hyptop_exit(int rc) +void __noreturn hyptop_exit(int rc) { hyptop_text_mode(); exit(rc); diff --git a/hyptop/hyptop.h b/hyptop/hyptop.h index 1c500b7e..7648bbf4 100644 --- a/hyptop/hyptop.h +++ b/hyptop/hyptop.h @@ -216,7 +216,7 @@ extern void win_cpu_types_init(void); * Misc functions */ extern void hyptop_update_term(void); -extern void hyptop_exit(int rc); +extern void __noreturn hyptop_exit(int rc); extern void hyptop_text_mode(void); #endif /* HYPTOP_H */ diff --git a/ipl_tools/cmd_chreipl.c b/ipl_tools/cmd_chreipl.c index 13893884..75fa3980 100644 --- a/ipl_tools/cmd_chreipl.c +++ b/ipl_tools/cmd_chreipl.c @@ -97,7 +97,7 @@ static struct locals { enum reipl_type reipl_type; /* CCW, FCP, NSS */ } l; -static void print_usage_chreipl_exit(void) +static void __noreturn print_usage_chreipl_exit(void) { printf(usage_chreipl, g.prog_name); exit(0); diff --git a/ipl_tools/cmd_chshut.c b/ipl_tools/cmd_chshut.c index 82777a7c..73b8a182 100644 --- a/ipl_tools/cmd_chshut.c +++ b/ipl_tools/cmd_chshut.c @@ -34,7 +34,7 @@ static const char *const usage_chshut = " -h, --help Print this help, then exit\n" " -v, --version Print version information, then exit\n"; -static void print_usage_chshut_exit(void) +static void __noreturn print_usage_chshut_exit(void) { printf(usage_chshut, g.prog_name); exit(0); diff --git a/ipl_tools/cmd_lsreipl.c b/ipl_tools/cmd_lsreipl.c index f5c432af..c906f839 100644 --- a/ipl_tools/cmd_lsreipl.c +++ b/ipl_tools/cmd_lsreipl.c @@ -25,7 +25,7 @@ static const char *const usage_lsreipl = " -h, --help Print this help, then exit\n" " -v, --version Print version information, then exit\n"; -static void print_usage_lsreipl_exit(void) +static void __noreturn print_usage_lsreipl_exit(void) { printf(usage_lsreipl, g.prog_name); exit(0); diff --git a/ipl_tools/cmd_lsshut.c b/ipl_tools/cmd_lsshut.c index 4489eff8..164567e4 100644 --- a/ipl_tools/cmd_lsshut.c +++ b/ipl_tools/cmd_lsshut.c @@ -20,7 +20,7 @@ static const char *const usage_lsshut = " -h, --help Print this help, then exit\n" " -v, --version Print version information, then exit\n"; -static void print_usage_lsshut_exit(void) +static __noreturn void print_usage_lsshut_exit(void) { printf(usage_lsshut, g.prog_name); exit(0); diff --git a/ipl_tools/ipl_tools.h b/ipl_tools/ipl_tools.h index 7be22d5c..86345031 100644 --- a/ipl_tools/ipl_tools.h +++ b/ipl_tools/ipl_tools.h @@ -24,6 +24,8 @@ #include #include +#include + #define IPL_TYPE_LEN_MAX 100 #define NSS_NAME_LEN_MAX 8 @@ -57,8 +59,8 @@ extern void read_str(char *string, const char *file, size_t len); extern void read_fw_str(char *string, const char *file, size_t len); extern void print_fw_str(const char *fmt, const char *dir, const char *file); -extern void print_version_exit(void); -extern void print_help_hint_exit(void); +extern void __noreturn print_version_exit(void); +extern void __noreturn print_help_hint_exit(void); /* * FCP diff --git a/ipl_tools/main.c b/ipl_tools/main.c index 6a9d3d1c..6a6cc97a 100644 --- a/ipl_tools/main.c +++ b/ipl_tools/main.c @@ -14,14 +14,14 @@ struct globals g; -void print_help_hint_exit(void) +void __noreturn print_help_hint_exit(void) { fprintf(stderr, "Try '%s' --help' for more information.\n", g.prog_name); exit(1); } -void print_version_exit(void) +void __noreturn print_version_exit(void) { printf("%s: Linux on System z shutdown actions version %s\n", g.prog_name, RELEASE_STRING); diff --git a/iucvterm/src/getopt.c b/iucvterm/src/getopt.c index a1bdefe7..503f6dd8 100644 --- a/iucvterm/src/getopt.c +++ b/iucvterm/src/getopt.c @@ -71,8 +71,8 @@ static const struct tool_info iucv_tool[2] = { }; -static void usage_exit(const struct tool_info *prg, int is_error, - const char *msg) +static void __noreturn usage_exit(const struct tool_info *prg, int is_error, + const char *msg) { if (msg != NULL) fprintf(stderr, _("%s: %s\n"), prg->name, msg); @@ -80,7 +80,7 @@ static void usage_exit(const struct tool_info *prg, int is_error, exit(is_error ? 1 : 0); /* rc=1 .. invalid args */ } -static void version_exit(const struct tool_info *prg) +static void __noreturn version_exit(const struct tool_info *prg) { printf(_("%s: IUCV Terminal Applications, version %s\n"), prg->name, RELEASE_STRING); diff --git a/iucvterm/src/ttyrun.c b/iucvterm/src/ttyrun.c index df44984a..4c236ba3 100644 --- a/iucvterm/src/ttyrun.c +++ b/iucvterm/src/ttyrun.c @@ -62,13 +62,13 @@ static const char usage[] = "-h, --help Displays this help, then exits.\n" "-v, --version Displays version information, then exits.\n"; -static void help_exit(const char *prg) +static void __noreturn help_exit(const char *prg) { printf(usage, prg, prg); exit(EXIT_SUCCESS); } -static void version_exit(const char *prg) +static void __noreturn version_exit(const char *prg) { printf("%s: Start a program if a terminal device is available, " "version %s\n", prg, RELEASE_STRING); diff --git a/zdump/opts.c b/zdump/opts.c index a52ebc09..f82f4c19 100644 --- a/zdump/opts.c +++ b/zdump/opts.c @@ -75,7 +75,7 @@ static void init_defaults(void) /* * Print "help" hint */ -static void print_usage_exit(void) +static void __noreturn print_usage_exit(void) { STDERR("Try '%s --help' for more information.\n", g.prog_name); zg_exit(1); @@ -84,7 +84,7 @@ static void print_usage_exit(void) /* * Print help text */ -static void print_help_exit(void) +static void __noreturn print_help_exit(void) { STDOUT("%s", help_text); zg_exit(0); @@ -93,7 +93,7 @@ static void print_help_exit(void) /* * Print version information */ -static void print_version_exit(void) +static void __noreturn print_version_exit(void) { STDOUT("%s: Tool for copying and converting dumps version %s\n", g.prog_name, RELEASE_STRING);