From 16bf32dcea05c64ff2ab831569be9a91c979a1b6 Mon Sep 17 00:00:00 2001 Message-Id: <16bf32dcea05c64ff2ab831569be9a91c979a1b6.1715429251.git.mdw@distorted.org.uk> From: Mark Wooding Date: Sun, 3 May 2020 16:16:18 +0100 Subject: [PATCH] Mark `help' and `version' functions as not returning. Organization: Straylight/Edgeware From: Mark Wooding They don't; and later versions of GCC complain about potential `switch' fall-through mistakes without this. Fixing this is a simple matter of adding `attribute((noreturn))' in the right places. Note that `server/gstdecode.c' doesn't share the common attribute-macro machinery. --- clients/disorder.c | 6 +++--- clients/disorderfm.c | 2 +- clients/playrtp.c | 2 +- clients/resample.c | 2 +- clients/rtpmon.c | 2 +- disobedience/disobedience.c | 2 +- lib/version.h | 2 +- libtests/test.c | 2 +- server/choose.c | 2 +- server/dbupgrade.c | 2 +- server/deadlock.c | 2 +- server/decode.c | 2 +- server/disorderd.c | 2 +- server/dump.c | 2 +- server/gstdecode.c | 8 +++++--- server/normalize.c | 2 +- server/rescan.c | 2 +- server/speaker.c | 2 +- server/stats.c | 2 +- server/trackname.c | 2 +- tests/udplog.c | 4 ++-- 21 files changed, 28 insertions(+), 26 deletions(-) diff --git a/clients/disorder.c b/clients/disorder.c index b9b2bb2..8fdbc60 100644 --- a/clients/disorder.c +++ b/clients/disorder.c @@ -83,7 +83,7 @@ static const struct option options[] = { }; /* display usage message and terminate */ -static void help(void) { +static void attribute((noreturn)) help(void) { xprintf("Usage:\n" " disorder [OPTIONS] COMMAND ...\n" "Options:\n" @@ -498,7 +498,7 @@ static const struct option setup_guest_options[] = { { 0, 0, 0, 0 } }; -static void help_setup_guest(void) { +static void attribute((noreturn)) help_setup_guest(void) { xprintf("Usage:\n" " disorder setup-guest [OPTIONS]\n" "Options:\n" @@ -844,7 +844,7 @@ static const struct client_command { "Display the server version" }, }; -static void help_commands(void) { +static void attribute((noreturn)) help_commands(void) { unsigned n, max = 0, l; xprintf("Command summary:\n"); diff --git a/clients/disorderfm.c b/clients/disorderfm.c index 14092da..55aff3e 100644 --- a/clients/disorderfm.c +++ b/clients/disorderfm.c @@ -102,7 +102,7 @@ static const struct option options[] = { }; /* display usage message and terminate */ -static void help(void) { +static void attribute((noreturn)) help(void) { xprintf("Usage:\n" " disorderfm [OPTIONS] SOURCE DESTINATION\n" "Options:\n" diff --git a/clients/playrtp.c b/clients/playrtp.c index f6e89d2..d28369f 100644 --- a/clients/playrtp.c +++ b/clients/playrtp.c @@ -500,7 +500,7 @@ struct packet *playrtp_next_packet(void) { } /* display usage message and terminate */ -static void help(void) { +static void attribute((noreturn)) help(void) { xprintf("Usage:\n" " disorder-playrtp [OPTIONS] [[ADDRESS] PORT]\n" "Options:\n" diff --git a/clients/resample.c b/clients/resample.c index 6291c83..f02cde7 100644 --- a/clients/resample.c +++ b/clients/resample.c @@ -59,7 +59,7 @@ static const struct option options[] = { }; /* display usage message and terminate */ -static void help(void) { +static void attribute((noreturn)) help(void) { xprintf("Usage:\n" " resample [OPTIONS] < INPUT > OUTPUT\n" "Options:\n" diff --git a/clients/rtpmon.c b/clients/rtpmon.c index 32974e8..21e451f 100644 --- a/clients/rtpmon.c +++ b/clients/rtpmon.c @@ -77,7 +77,7 @@ static const struct option options[] = { { 0, 0, 0, 0 } }; -static void help(void) { +static void attribute((noreturn)) help(void) { xprintf("Usage:\n" " rtpmon [OPTIONS] [ADDRESS] PORT\n" "Options:\n" diff --git a/disobedience/disobedience.c b/disobedience/disobedience.c index d3e4d35..b988aa8 100644 --- a/disobedience/disobedience.c +++ b/disobedience/disobedience.c @@ -472,7 +472,7 @@ static const struct option options[] = { }; /* display usage message and terminate */ -static void help(void) { +static void attribute((noreturn)) help(void) { xprintf("Disobedience - GUI client for DisOrder\n" "\n" "Usage:\n" diff --git a/lib/version.h b/lib/version.h index b8ee0d5..51a32a0 100644 --- a/lib/version.h +++ b/lib/version.h @@ -21,7 +21,7 @@ #ifndef VERSION_H #define VERSION_H -void version(const char *name); +void attribute((noreturn)) version(const char *name); #endif /* VERSION_H */ diff --git a/libtests/test.c b/libtests/test.c index 3270d47..86a6184 100644 --- a/libtests/test.c +++ b/libtests/test.c @@ -148,7 +148,7 @@ static const struct option options[] = { }; /* display usage message and terminate */ -static void help(void) { +static void attribute((noreturn)) help(void) { xprintf("Usage:\n" " %s [OPTIONS]\n" "Options:\n" diff --git a/server/choose.c b/server/choose.c index 4b2d94f..ab24e2d 100644 --- a/server/choose.c +++ b/server/choose.c @@ -42,7 +42,7 @@ static const struct option options[] = { }; /* display usage message and terminate */ -static void help(void) { +static void attribute((noreturn)) help(void) { xprintf("Usage:\n" " disorder-choose [OPTIONS]\n" "Options:\n" diff --git a/server/dbupgrade.c b/server/dbupgrade.c index e44b7f5..220fb76 100644 --- a/server/dbupgrade.c +++ b/server/dbupgrade.c @@ -48,7 +48,7 @@ static const struct option options[] = { }; /* display usage message and terminate */ -static void help(void) { +static void attribute((noreturn)) help(void) { xprintf("Usage:\n" " disorder-dbupgrade [OPTIONS]\n" "Options:\n" diff --git a/server/deadlock.c b/server/deadlock.c index 636e382..fdc4f50 100644 --- a/server/deadlock.c +++ b/server/deadlock.c @@ -34,7 +34,7 @@ static const struct option options[] = { }; /* display usage message and terminate */ -static void help(void) { +static void attribute((noreturn)) help(void) { xprintf("Usage:\n" " disorder-deadlock [OPTIONS]\n" "Options:\n" diff --git a/server/decode.c b/server/decode.c index 8a09013..1b2ed41 100644 --- a/server/decode.c +++ b/server/decode.c @@ -95,7 +95,7 @@ static const struct option options[] = { }; /* Display usage message and terminate. */ -static void help(void) { +static void attribute((noreturn)) help(void) { xprintf("Usage:\n" " disorder-decode [OPTIONS] PATH\n" "Options:\n" diff --git a/server/disorderd.c b/server/disorderd.c index 06651a1..a2ed421 100644 --- a/server/disorderd.c +++ b/server/disorderd.c @@ -37,7 +37,7 @@ static const struct option options[] = { }; /* display usage message and terminate */ -static void help(void) { +static void attribute((noreturn)) help(void) { xprintf("Usage:\n" " disorderd [OPTIONS]\n" "Options:\n" diff --git a/server/dump.c b/server/dump.c index 31e08af..85f9349 100644 --- a/server/dump.c +++ b/server/dump.c @@ -40,7 +40,7 @@ static const struct option options[] = { }; /* display usage message and terminate */ -static void help(void) { +static void attribute((noreturn)) help(void) { xprintf("Usage:\n" " disorder-dump [OPTIONS] --dump|--undump PATH\n" " disorder-dump [OPTIONS] --recompute-aliases\n" diff --git a/server/gstdecode.c b/server/gstdecode.c index 42ccd7c..1f4d7a2 100644 --- a/server/gstdecode.c +++ b/server/gstdecode.c @@ -35,11 +35,13 @@ #include #include -/* The only application we have for `attribute' is declaring function +/* The only applications we have for `attribute' is declaring function * arguments as being unused, because we have a lot of callback functions - * which are meant to comply with an externally defined interface. + * which are meant to comply with an externally defined interface; and + * marking `help' as not returning. */ #ifdef __GNUC__ +# define NORETURN __attribute__((noreturn)) # define UNUSED __attribute__((unused)) #endif @@ -533,7 +535,7 @@ static const struct option options[] = { { 0, 0, 0, 0 } }; -static void help(void) +static void NORETURN help(void) { xprintf("Usage:\n" " disorder-gstdecode [OPTIONS] PATH\n" diff --git a/server/normalize.c b/server/normalize.c index 0f97a2f..6875094 100644 --- a/server/normalize.c +++ b/server/normalize.c @@ -40,7 +40,7 @@ static const struct option options[] = { }; /* display usage message and terminate */ -static void help(void) { +static void attribute((noreturn)) help(void) { xprintf("Usage:\n" " disorder-normalize [OPTIONS]\n" "Options:\n" diff --git a/server/rescan.c b/server/rescan.c index bd163b4..3a5a589 100644 --- a/server/rescan.c +++ b/server/rescan.c @@ -39,7 +39,7 @@ static const struct option options[] = { }; /* display usage message and terminate */ -static void help(void) { +static void attribute((noreturn)) help(void) { xprintf("Usage:\n" " disorder-rescan [OPTIONS] [PATH...]\n" "Options:\n" diff --git a/server/speaker.c b/server/speaker.c index a55b074..0cc3ac4 100644 --- a/server/speaker.c +++ b/server/speaker.c @@ -235,7 +235,7 @@ static const struct option options[] = { }; /* Display usage message and terminate. */ -static void help(void) { +static void attribute((noreturn)) help(void) { xprintf("Usage:\n" " disorder-speaker [OPTIONS]\n" "Options:\n" diff --git a/server/stats.c b/server/stats.c index 1ac1cd7..ac37374 100644 --- a/server/stats.c +++ b/server/stats.c @@ -36,7 +36,7 @@ static const struct option options[] = { }; /* display usage message and terminate */ -static void help(void) { +static void attribute((noreturn)) help(void) { xprintf("Usage:\n" " disorder-stats [OPTIONS]\n" "Options:\n" diff --git a/server/trackname.c b/server/trackname.c index 2c62d0c..8deedd3 100644 --- a/server/trackname.c +++ b/server/trackname.c @@ -29,7 +29,7 @@ static const struct option options[] = { }; /* display usage message and terminate */ -static void help(void) { +static void attribute((noreturn)) help(void) { xprintf("Usage:\n" " trackname [OPTIONS] TRACK CONTEXT PART\n" "Options:\n" diff --git a/tests/udplog.c b/tests/udplog.c index 6c817ce..fe0b6ea 100644 --- a/tests/udplog.c +++ b/tests/udplog.c @@ -49,7 +49,7 @@ static const struct option options[] = { }; /* display usage message and terminate */ -static void help(void) { +static void attribute((noreturn)) help(void) { xprintf("Usage:\n" " disorder-udplog [OPTIONS] ADDRESS PORT\n" "Options:\n" @@ -63,7 +63,7 @@ static void help(void) { } /* display version number and terminate */ -static void version(void) { +static void attribute((noreturn)) version(void) { xprintf("%s", disorder_version_string); xfclose(stdout); exit(0); -- [mdw]