Merge pull request #18720 from mjstapp/compile_wnoreturn

*: enable the missing-noreturn compiler warning
This commit is contained in:
Donald Sharp 2025-04-25 09:35:27 -04:00 committed by GitHub
commit 217a90ee09
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
27 changed files with 42 additions and 45 deletions

View file

@ -34,9 +34,9 @@ Copyright 2011 by Matthieu Boutier and Juliusz Chroboczek
#include "babel_zebra.h" #include "babel_zebra.h"
#include "babel_errors.h" #include "babel_errors.h"
static void babel_fail(void); static FRR_NORETURN void babel_fail(void);
static void babel_init_random(void); static void babel_init_random(void);
static void babel_exit_properly(void); static FRR_NORETURN void babel_exit_properly(void);
static void babel_save_state_file(void); static void babel_save_state_file(void);
@ -85,8 +85,7 @@ struct zebra_privs_t babeld_privs =
.cap_num_i = 0 .cap_num_i = 0
}; };
static void static FRR_NORETURN void babel_sigexit(void)
babel_sigexit(void)
{ {
zlog_notice("Terminating on signal"); zlog_notice("Terminating on signal");
@ -208,8 +207,7 @@ main(int argc, char **argv)
return 0; return 0;
} }
static void static FRR_NORETURN void babel_fail(void)
babel_fail(void)
{ {
exit(1); exit(1);
} }
@ -297,8 +295,7 @@ fini:
return ; return ;
} }
static void static FRR_NORETURN void babel_exit_properly(void)
babel_exit_properly(void)
{ {
debugf(BABEL_DEBUG_COMMON, "Exiting..."); debugf(BABEL_DEBUG_COMMON, "Exiting...");
usleep(roughly(10000)); usleep(roughly(10000));

View file

@ -57,7 +57,7 @@ static void sigusr1_handler(void)
zlog_rotate(); zlog_rotate();
} }
static void sigterm_handler(void) static FRR_NORETURN void sigterm_handler(void)
{ {
bglobal.bg_shutdown = true; bglobal.bg_shutdown = true;

View file

@ -468,9 +468,9 @@ AC_C_FLAG([-Wwrite-strings])
AC_C_FLAG([-Wundef]) AC_C_FLAG([-Wundef])
AC_C_FLAG([-Wimplicit-fallthrough]) AC_C_FLAG([-Wimplicit-fallthrough])
AC_C_FLAG([-Wshadow]) AC_C_FLAG([-Wshadow])
AC_C_FLAG([-Wmissing-noreturn])
if test "$enable_gcc_ultra_verbose" = "yes" ; then if test "$enable_gcc_ultra_verbose" = "yes" ; then
AC_C_FLAG([-Wcast-qual]) AC_C_FLAG([-Wcast-qual])
AC_C_FLAG([-Wmissing-noreturn])
AC_C_FLAG([-Wmissing-format-attribute]) AC_C_FLAG([-Wmissing-format-attribute])
AC_C_FLAG([-Wunreachable-code]) AC_C_FLAG([-Wunreachable-code])
AC_C_FLAG([-Wpacked]) AC_C_FLAG([-Wpacked])

View file

@ -92,7 +92,7 @@ static void sighup(void)
} }
/* SIGINT / SIGTERM handler. */ /* SIGINT / SIGTERM handler. */
static void sigint(void) static FRR_NORETURN void sigint(void)
{ {
zlog_notice("Terminating on signal"); zlog_notice("Terminating on signal");

View file

@ -176,8 +176,7 @@ lde_init(struct ldpd_init *init)
zclient_sync_init(); zclient_sync_init();
} }
static void static FRR_NORETURN void lde_shutdown(void)
lde_shutdown(void)
{ {
/* close pipes */ /* close pipes */
if (iev_ldpe) { if (iev_ldpe) {

View file

@ -443,8 +443,7 @@ main(int argc, char *argv[])
return (0); return (0);
} }
static void static FRR_NORETURN void ldpd_shutdown(void)
ldpd_shutdown(void)
{ {
pid_t pid; pid_t pid;
int status; int status;

View file

@ -25,7 +25,7 @@
#include "libfrr.h" #include "libfrr.h"
#include "zlog_live.h" #include "zlog_live.h"
static void ldpe_shutdown(void); static FRR_NORETURN void ldpe_shutdown(void);
static void ldpe_dispatch_main(struct event *thread); static void ldpe_dispatch_main(struct event *thread);
static void ldpe_dispatch_lde(struct event *thread); static void ldpe_dispatch_lde(struct event *thread);
#ifdef __OpenBSD__ #ifdef __OpenBSD__
@ -66,8 +66,7 @@ struct zebra_privs_t ldpe_privs =
}; };
/* SIGINT / SIGTERM handler. */ /* SIGINT / SIGTERM handler. */
static void static FRR_NORETURN void sigint(void)
sigint(void)
{ {
ldpe_shutdown(); ldpe_shutdown();
} }
@ -182,8 +181,7 @@ ldpe_init(struct ldpd_init *init)
accept_init(); accept_init();
} }
static void static FRR_NORETURN void ldpe_shutdown(void)
ldpe_shutdown(void)
{ {
struct if_addr *if_addr; struct if_addr *if_addr;
struct adj *adj; struct adj *adj;

View file

@ -18,6 +18,7 @@
/* ignore harmless bugs in old versions of flex */ /* ignore harmless bugs in old versions of flex */
#pragma GCC diagnostic ignored "-Wsign-compare" #pragma GCC diagnostic ignored "-Wsign-compare"
#pragma GCC diagnostic ignored "-Wmissing-prototypes" #pragma GCC diagnostic ignored "-Wmissing-prototypes"
#pragma GCC diagnostic ignored "-Wmissing-noreturn"
#include "lib/command_parse.h" #include "lib/command_parse.h"

View file

@ -461,6 +461,9 @@ _Static_assert(sizeof(_uint64_t) == 8 && sizeof(_int64_t) == 8,
#define _DATA_SECTION(name) __attribute__((section(".data." name))) #define _DATA_SECTION(name) __attribute__((section(".data." name)))
#endif #endif
/* Wrapper for the 'noreturn' metadata */
#define FRR_NORETURN __attribute__((noreturn))
#ifdef __cplusplus #ifdef __cplusplus
} }
#endif #endif

View file

@ -29,6 +29,7 @@
/* ignore harmless bugs in old versions of flex */ /* ignore harmless bugs in old versions of flex */
#pragma GCC diagnostic ignored "-Wsign-compare" #pragma GCC diagnostic ignored "-Wsign-compare"
#pragma GCC diagnostic ignored "-Wunused-value" #pragma GCC diagnostic ignored "-Wunused-value"
#pragma GCC diagnostic ignored "-Wmissing-noreturn"
#include "config.h" #include "config.h"
#include <Python.h> #include <Python.h>

View file

@ -868,7 +868,7 @@ static void rcv_signal(int signum)
/* poll() is interrupted by the signal; handled below */ /* poll() is interrupted by the signal; handled below */
} }
static void frr_daemon_wait(int fd) static FRR_NORETURN void frr_daemon_wait(int fd)
{ {
struct pollfd pfd[1]; struct pollfd pfd[1];
int ret; int ret;

View file

@ -183,8 +183,7 @@ typedef int qmem_walk_fn(void *arg, struct memgroup *mg, struct memtype *mt);
extern int qmem_walk(qmem_walk_fn *func, void *arg); extern int qmem_walk(qmem_walk_fn *func, void *arg);
extern int log_memstats(const char *daemon_name, bool enabled); extern int log_memstats(const char *daemon_name, bool enabled);
extern __attribute__((__noreturn__)) void memory_oom(size_t size, extern FRR_NORETURN void memory_oom(size_t size, const char *name);
const char *name);
#ifdef __cplusplus #ifdef __cplusplus
} }

View file

@ -206,8 +206,8 @@ static void *program_counter(void *context)
return NULL; return NULL;
} }
static void __attribute__((noreturn)) static void FRR_NORETURN exit_handler(int signo, siginfo_t *siginfo,
exit_handler(int signo, siginfo_t *siginfo, void *context) void *context)
{ {
void *pc = program_counter(context); void *pc = program_counter(context);
@ -215,8 +215,8 @@ exit_handler(int signo, siginfo_t *siginfo, void *context)
_exit(128 + signo); _exit(128 + signo);
} }
static void __attribute__((noreturn)) static void FRR_NORETURN core_handler(int signo, siginfo_t *siginfo,
core_handler(int signo, siginfo_t *siginfo, void *context) void *context)
{ {
void *pc = program_counter(context); void *pc = program_counter(context);

View file

@ -2030,7 +2030,7 @@ void mgmt_fe_adapter_init(struct event_loop *tm)
} }
} }
static void mgmt_fe_abort_if_session(void *data) static FRR_NORETURN void mgmt_fe_abort_if_session(void *data)
{ {
struct mgmt_fe_session_ctx *session = data; struct mgmt_fe_session_ctx *session = data;

View file

@ -78,7 +78,7 @@ static void nhrp_sigusr1(void)
zlog_rotate(); zlog_rotate();
} }
static void nhrp_request_stop(void) static FRR_NORETURN void nhrp_request_stop(void)
{ {
debugf(NHRP_DEBUG_COMMON, "Exiting..."); debugf(NHRP_DEBUG_COMMON, "Exiting...");
frr_early_fini(); frr_early_fini();

View file

@ -125,14 +125,14 @@ static void sighup(void)
} }
/* SIGINT handler. */ /* SIGINT handler. */
static void sigint(void) static FRR_NORETURN void sigint(void)
{ {
zlog_notice("Terminating on signal SIGINT"); zlog_notice("Terminating on signal SIGINT");
ospf6_exit(0); ospf6_exit(0);
} }
/* SIGTERM handler. */ /* SIGTERM handler. */
static void sigterm(void) static FRR_NORETURN void sigterm(void)
{ {
zlog_notice("Terminating on signal SIGTERM"); zlog_notice("Terminating on signal SIGTERM");
ospf6_exit(0); ospf6_exit(0);

View file

@ -99,7 +99,7 @@ static void sighup(void)
} }
/* SIGINT / SIGTERM handler. */ /* SIGINT / SIGTERM handler. */
static void sigint(void) static FRR_NORETURN void sigint(void)
{ {
zlog_notice("Terminating on signal"); zlog_notice("Terminating on signal");
bfd_protocol_integration_set_shutdown(true); bfd_protocol_integration_set_shutdown(true);

View file

@ -55,7 +55,7 @@ static void sighup(void)
} }
/* SIGINT / SIGTERM handler. */ /* SIGINT / SIGTERM handler. */
static void sigint(void) static FRR_NORETURN void sigint(void)
{ {
zlog_notice("Terminating on signal"); zlog_notice("Terminating on signal");
zlog_notice("Unregister from opaque,etc "); zlog_notice("Unregister from opaque,etc ");

View file

@ -65,7 +65,7 @@ static void sighup(void)
} }
/* SIGINT / SIGTERM handler. */ /* SIGINT / SIGTERM handler. */
static void sigint(void) static FRR_NORETURN void sigint(void)
{ {
zlog_notice("Terminating on signal"); zlog_notice("Terminating on signal");

View file

@ -56,14 +56,14 @@ static void pim6_sighup(void)
zlog_info("SIGHUP received, ignoring"); zlog_info("SIGHUP received, ignoring");
} }
static void pim6_sigint(void) static FRR_NORETURN void pim6_sigint(void)
{ {
zlog_notice("Terminating on signal SIGINT"); zlog_notice("Terminating on signal SIGINT");
pim6_terminate(); pim6_terminate();
exit(1); exit(1);
} }
static void pim6_sigterm(void) static FRR_NORETURN void pim6_sigterm(void)
{ {
zlog_notice("Terminating on signal SIGTERM"); zlog_notice("Terminating on signal SIGTERM");
pim6_terminate(); pim6_terminate();

View file

@ -25,14 +25,14 @@ static void pim_sighup(void)
zlog_info("SIGHUP received, ignoring"); zlog_info("SIGHUP received, ignoring");
} }
static void pim_sigint(void) static FRR_NORETURN void pim_sigint(void)
{ {
zlog_notice("Terminating on signal SIGINT"); zlog_notice("Terminating on signal SIGINT");
pim_terminate(); pim_terminate();
exit(1); exit(1);
} }
static void pim_sigterm(void) static FRR_NORETURN void pim_sigterm(void)
{ {
zlog_notice("Terminating on signal SIGTERM"); zlog_notice("Terminating on signal SIGTERM");
pim_terminate(); pim_terminate();

View file

@ -69,7 +69,7 @@ static void sighup(void)
} }
/* SIGINT handler. */ /* SIGINT handler. */
static void sigint(void) static FRR_NORETURN void sigint(void)
{ {
struct vrf *vrf; struct vrf *vrf;

View file

@ -67,7 +67,7 @@ static void sighup(void)
} }
/* SIGINT handler. */ /* SIGINT handler. */
static void sigint(void) static FRR_NORETURN void sigint(void)
{ {
struct vrf *vrf; struct vrf *vrf;

View file

@ -90,7 +90,7 @@ static void sighup(void)
} }
/* SIGINT / SIGTERM handler. */ /* SIGINT / SIGTERM handler. */
static void sigint(void) static FRR_NORETURN void sigint(void)
{ {
zlog_notice("Terminating on signal"); zlog_notice("Terminating on signal");

View file

@ -65,7 +65,7 @@ static void sighup(void)
} }
/* SIGINT / SIGTERM handler. */ /* SIGINT / SIGTERM handler. */
static void sigint(void) static FRR_NORETURN void sigint(void)
{ {
zlog_notice("Terminating on signal"); zlog_notice("Terminating on signal");

View file

@ -156,7 +156,7 @@ static void vtysh_signal_init(void)
} }
/* Help information display. */ /* Help information display. */
static void usage(int status) static FRR_NORETURN void usage(int status)
{ {
if (status != 0) if (status != 0)
fprintf(stderr, "Try `%s --help' for more information.\n", fprintf(stderr, "Try `%s --help' for more information.\n",

View file

@ -1090,7 +1090,7 @@ void watchfrr_status(struct vty *vty)
} }
} }
static void sigint(void) static FRR_NORETURN void sigint(void)
{ {
zlog_notice("Terminating on signal"); zlog_notice("Terminating on signal");
systemd_send_stopping(); systemd_send_stopping();
@ -1268,7 +1268,7 @@ static void netns_setup(const char *nsname)
#else /* !GNU_LINUX */ #else /* !GNU_LINUX */
static void netns_setup(const char *nsname) static FRR_NORETURN void netns_setup(const char *nsname)
{ {
fprintf(stderr, "network namespaces are only available on Linux\n"); fprintf(stderr, "network namespaces are only available on Linux\n");
exit(1); exit(1);