diff --git a/babeld/babel_main.c b/babeld/babel_main.c index ddc75f7182c2..751c541c5432 100644 --- a/babeld/babel_main.c +++ b/babeld/babel_main.c @@ -207,8 +207,7 @@ main(int argc, char **argv) return 0; } -static void -babel_fail(void) +static __attribute__((__noreturn__)) void babel_fail(void) { exit(1); } @@ -296,8 +295,7 @@ babel_load_state_file(void) return ; } -static void -babel_exit_properly(void) +static __attribute__((__noreturn__)) void babel_exit_properly(void) { debugf(BABEL_DEBUG_COMMON, "Exiting..."); usleep(roughly(10000)); diff --git a/bfdd/bfdd.c b/bfdd/bfdd.c index c2d8e926bff6..a91c09d1c542 100644 --- a/bfdd/bfdd.c +++ b/bfdd/bfdd.c @@ -57,7 +57,7 @@ static void sigusr1_handler(void) zlog_rotate(); } -static void sigterm_handler(void) +static __attribute__((__noreturn__)) void sigterm_handler(void) { bglobal.bg_shutdown = true; diff --git a/bgpd/bgp_bmp.c b/bgpd/bgp_bmp.c index e458e5e5acaa..90f9a78d595e 100644 --- a/bgpd/bgp_bmp.c +++ b/bgpd/bgp_bmp.c @@ -3532,7 +3532,6 @@ static int bmp_bgp_attribute_updated(struct bgp *bgp, bool withdraw) struct bmp_targets *bt; struct listnode *node; struct bmp_imported_bgp *bib; - int ret = 0; struct stream *s = bmp_peerstate(bgp->peer_self, withdraw); struct bmp *bmp; afi_t afi; @@ -3543,7 +3542,7 @@ static int bmp_bgp_attribute_updated(struct bgp *bgp, bool withdraw) if (bmpbgp) { frr_each (bmp_targets, &bmpbgp->targets, bt) { - ret = bmp_bgp_attribute_updated_instance(bt, &bmpbgp->vrf_state, bgp, + (void)bmp_bgp_attribute_updated_instance(bt, &bmpbgp->vrf_state, bgp, withdraw, s); if (withdraw) continue; @@ -3565,8 +3564,8 @@ static int bmp_bgp_attribute_updated(struct bgp *bgp, bool withdraw) frr_each (bmp_imported_bgps, &bt->imported_bgps, bib) { if (bgp_lookup_by_name(bib->name) != bgp) continue; - ret += bmp_bgp_attribute_updated_instance(bt, &bib->vrf_state, bgp, - withdraw, s); + (void)bmp_bgp_attribute_updated_instance(bt, &bib->vrf_state, bgp, + withdraw, s); if (withdraw) continue; frr_each (bmp_session, &bt->sessions, bmp) { diff --git a/bgpd/bgp_rpki.c b/bgpd/bgp_rpki.c index 04a709b350e0..4a6d2e273503 100644 --- a/bgpd/bgp_rpki.c +++ b/bgpd/bgp_rpki.c @@ -1553,11 +1553,9 @@ static int bgp_rpki_write_vrf(struct vty *vty, struct vrf *vrf) for (ALL_LIST_ELEMENTS_RO(rpki_vrf->cache_list, cache_node, cache)) { switch (cache->type) { + case TCP: { struct tr_tcp_config *tcp_config; -#if defined(FOUND_SSH) - struct tr_ssh_config *ssh_config; -#endif - case TCP: + tcp_config = cache->tr_config.tcp_config; vty_out(vty, "%s rpki cache tcp %s %s ", sep, tcp_config->host, tcp_config->port); @@ -1565,8 +1563,11 @@ static int bgp_rpki_write_vrf(struct vty *vty, struct vrf *vrf) vty_out(vty, "source %s ", tcp_config->bindaddr); break; + } #if defined(FOUND_SSH) - case SSH: + case SSH: { + struct tr_ssh_config *ssh_config; + ssh_config = cache->tr_config.ssh_config; vty_out(vty, "%s rpki cache ssh %s %u %s %s %s ", sep, ssh_config->host, ssh_config->port, @@ -1579,6 +1580,7 @@ static int bgp_rpki_write_vrf(struct vty *vty, struct vrf *vrf) vty_out(vty, "source %s ", ssh_config->bindaddr); break; + } #endif default: break; diff --git a/bgpd/rfapi/rfapi_import.c b/bgpd/rfapi/rfapi_import.c index 99d8bcfce44e..e3c30cc34bec 100644 --- a/bgpd/rfapi/rfapi_import.c +++ b/bgpd/rfapi/rfapi_import.c @@ -181,9 +181,6 @@ void rfapiCheckRefcount(struct agg_node *rn, safi_t safi, int lockoffset) ++count_monitor; /* rfapi_it_extra */ switch (safi) { - void *cursor; - int rc; - case SAFI_ENCAP: for (hme = RFAPI_MONITOR_ENCAP(rn); hme; hme = hme->next) @@ -196,6 +193,9 @@ void rfapiCheckRefcount(struct agg_node *rn, safi_t safi, int lockoffset) ++count_monitor; if (RFAPI_MONITOR_EXTERIOR(rn)->source) { + void *cursor; + int rc; + ++count_monitor; /* sl */ cursor = NULL; for (rc = skiplist_next( diff --git a/configure.ac b/configure.ac index 09e2d20c3a2c..2970dc709f4a 100644 --- a/configure.ac +++ b/configure.ac @@ -467,6 +467,11 @@ AC_C_FLAG([-Wbad-function-cast]) AC_C_FLAG([-Wwrite-strings]) AC_C_FLAG([-Wundef]) AC_C_FLAG([-Wimplicit-fallthrough]) +AC_C_FLAG([-Werror=implicit]) +AC_C_FLAG([-Werror=int-conversion]) +AC_C_FLAG([-Werror=incompatible-pointer-types]) +AC_C_FLAG([-Wunreachable-code]) +AC_C_FLAG([-Wmissing-noreturn]) if test "$enable_gcc_ultra_verbose" = "yes" ; then AC_C_FLAG([-Wcast-qual]) AC_C_FLAG([-Wmissing-noreturn]) diff --git a/eigrpd/eigrp_main.c b/eigrpd/eigrp_main.c index 319ac925337b..f4a8e9a7db7d 100644 --- a/eigrpd/eigrp_main.c +++ b/eigrpd/eigrp_main.c @@ -92,7 +92,7 @@ static void sighup(void) } /* SIGINT / SIGTERM handler. */ -static void sigint(void) +static __attribute__((__noreturn__)) void sigint(void) { zlog_notice("Terminating on signal"); diff --git a/ldpd/lde.c b/ldpd/lde.c index 876dd4163099..d14555662810 100644 --- a/ldpd/lde.c +++ b/ldpd/lde.c @@ -176,8 +176,7 @@ lde_init(struct ldpd_init *init) zclient_sync_init(); } -static void -lde_shutdown(void) +static __attribute__((__noreturn__)) void lde_shutdown(void) { /* close pipes */ if (iev_ldpe) { diff --git a/ldpd/ldpd.c b/ldpd/ldpd.c index 4d38fdcd02c9..ea8ec1e32c6f 100644 --- a/ldpd/ldpd.c +++ b/ldpd/ldpd.c @@ -443,8 +443,7 @@ main(int argc, char *argv[]) return (0); } -static void -ldpd_shutdown(void) +static __attribute__((__noreturn__)) void ldpd_shutdown(void) { pid_t pid; int status; diff --git a/ldpd/ldpe.c b/ldpd/ldpe.c index 0a3a03bc38de..d1d95992730c 100644 --- a/ldpd/ldpe.c +++ b/ldpd/ldpe.c @@ -182,8 +182,7 @@ ldpe_init(struct ldpd_init *init) accept_init(); } -static void -ldpe_shutdown(void) +static __attribute__((__noreturn__)) void ldpe_shutdown(void) { struct if_addr *if_addr; struct adj *adj; diff --git a/lib/libfrr.c b/lib/libfrr.c index 261d3aa87e6e..ae240c9a1d24 100644 --- a/lib/libfrr.c +++ b/lib/libfrr.c @@ -867,7 +867,7 @@ static void rcv_signal(int signum) /* poll() is interrupted by the signal; handled below */ } -static void frr_daemon_wait(int fd) +static __attribute__((__noreturn__)) void frr_daemon_wait(int fd) { struct pollfd pfd[1]; int ret; @@ -1274,7 +1274,12 @@ void frr_fini(void) master = NULL; zlog_tls_buffer_fini(); - if (0) { + /* + * The extra paranthesis around the 0 is telling the compiler that + * we are intentionally not calling zlog_fini(). So if you see + * this and are going... why.... this is why. + */ + if ((0)) { /* this is intentionally disabled. zlog remains running until * exit(), so even the very last item done during shutdown can * have its zlog() messages written out. diff --git a/mgmtd/mgmt_fe_adapter.c b/mgmtd/mgmt_fe_adapter.c index 8d5919880376..0800c79f5d3e 100644 --- a/mgmtd/mgmt_fe_adapter.c +++ b/mgmtd/mgmt_fe_adapter.c @@ -2018,7 +2018,7 @@ void mgmt_fe_adapter_init(struct event_loop *tm) } } -static void mgmt_fe_abort_if_session(void *data) +static __attribute__((__noreturn__)) void mgmt_fe_abort_if_session(void *data) { struct mgmt_fe_session_ctx *session = data; diff --git a/mgmtd/mgmt_testc.c b/mgmtd/mgmt_testc.c index ab8ea9a04d70..8562ef41ec84 100644 --- a/mgmtd/mgmt_testc.c +++ b/mgmtd/mgmt_testc.c @@ -155,7 +155,7 @@ static void sigusr1(void) zlog_rotate(); } -static void quit(int exit_code) +static __attribute__((__noreturn__)) void quit(int exit_code) { EVENT_OFF(event_timeout); darr_free(__client_cbs.notif_xpaths); @@ -166,19 +166,19 @@ static void quit(int exit_code) exit(exit_code); } -static void sigint(void) +static __attribute__((__noreturn__)) void sigint(void) { zlog_notice("Terminating on signal"); quit(0); } -static void timeout(struct event *event) +static __attribute__((__noreturn__)) void timeout(struct event *event) { zlog_notice("Timeout, exiting"); quit(1); } -static void success(struct event *event) +static __attribute__((__noreturn__)) void success(struct event *event) { zlog_notice("Success, exiting"); quit(0); diff --git a/nhrpd/nhrp_main.c b/nhrpd/nhrp_main.c index adb8be36d303..8f9f5d23de59 100644 --- a/nhrpd/nhrp_main.c +++ b/nhrpd/nhrp_main.c @@ -78,7 +78,7 @@ static void nhrp_sigusr1(void) zlog_rotate(); } -static void nhrp_request_stop(void) +static __attribute__((__noreturn__)) void nhrp_request_stop(void) { debugf(NHRP_DEBUG_COMMON, "Exiting..."); frr_early_fini(); diff --git a/ospf6d/ospf6_main.c b/ospf6d/ospf6_main.c index 8320f11f6cce..9727a254d708 100644 --- a/ospf6d/ospf6_main.c +++ b/ospf6d/ospf6_main.c @@ -125,14 +125,14 @@ static void sighup(void) } /* SIGINT handler. */ -static void sigint(void) +static __attribute__((__noreturn__)) void sigint(void) { zlog_notice("Terminating on signal SIGINT"); ospf6_exit(0); } /* SIGTERM handler. */ -static void sigterm(void) +static __attribute__((__noreturn__)) void sigterm(void) { zlog_notice("Terminating on signal SIGTERM"); ospf6_exit(0); diff --git a/ospfd/ospf_apiserver.c b/ospfd/ospf_apiserver.c index fcc28c6f9f82..4c35dad08361 100644 --- a/ospfd/ospf_apiserver.c +++ b/ospfd/ospf_apiserver.c @@ -2087,6 +2087,8 @@ void ospf_apiserver_flush_opaque_lsa(struct ospf_apiserver *apiserv, struct listnode *node, *nnode; struct ospf *ospf; struct ospf_area *area; + struct route_node *rn; + struct ospf_lsa *lsa; ospf = ospf_lookup_by_vrf_id(VRF_DEFAULT); assert(ospf); @@ -2097,9 +2099,6 @@ void ospf_apiserver_flush_opaque_lsa(struct ospf_apiserver *apiserv, param.opaque_type = opaque_type; switch (lsa_type) { - struct route_node *rn; - struct ospf_lsa *lsa; - case OSPF_OPAQUE_LINK_LSA: for (ALL_LIST_ELEMENTS(ospf->areas, node, nnode, area)) LSDB_LOOP (OPAQUE_LINK_LSDB(area), rn, lsa) diff --git a/ospfd/ospf_main.c b/ospfd/ospf_main.c index 5c11027506dd..e557e529b436 100644 --- a/ospfd/ospf_main.c +++ b/ospfd/ospf_main.c @@ -99,7 +99,7 @@ static void sighup(void) } /* SIGINT / SIGTERM handler. */ -static void sigint(void) +static __attribute__((__noreturn__)) void sigint(void) { zlog_notice("Terminating on signal"); bfd_protocol_integration_set_shutdown(true); diff --git a/pathd/path_main.c b/pathd/path_main.c index 23cbb9ccedc6..60ee5f70d630 100644 --- a/pathd/path_main.c +++ b/pathd/path_main.c @@ -55,7 +55,7 @@ static void sighup(void) } /* SIGINT / SIGTERM handler. */ -static void sigint(void) +static __attribute__((__noreturn__)) void sigint(void) { zlog_notice("Terminating on signal"); zlog_notice("Unregister from opaque,etc "); diff --git a/pbrd/pbr_main.c b/pbrd/pbr_main.c index 6695b537a80c..60f50f77f3e9 100644 --- a/pbrd/pbr_main.c +++ b/pbrd/pbr_main.c @@ -65,7 +65,7 @@ static void sighup(void) } /* SIGINT / SIGTERM handler. */ -static void sigint(void) +static __attribute__((__noreturn__)) void sigint(void) { zlog_notice("Terminating on signal"); diff --git a/pimd/pim6_main.c b/pimd/pim6_main.c index 07b70ae2b3df..ebe0e0c3b9c4 100644 --- a/pimd/pim6_main.c +++ b/pimd/pim6_main.c @@ -56,14 +56,14 @@ static void pim6_sighup(void) zlog_info("SIGHUP received, ignoring"); } -static void pim6_sigint(void) +static __attribute__((__noreturn__)) void pim6_sigint(void) { zlog_notice("Terminating on signal SIGINT"); pim6_terminate(); exit(1); } -static void pim6_sigterm(void) +static __attribute__((__noreturn__)) void pim6_sigterm(void) { zlog_notice("Terminating on signal SIGTERM"); pim6_terminate(); diff --git a/pimd/pim_bsm.c b/pimd/pim_bsm.c index 50fe543b23ce..024c150e2301 100644 --- a/pimd/pim_bsm.c +++ b/pimd/pim_bsm.c @@ -1802,7 +1802,7 @@ bool cand_addrsel_update(struct cand_addrsel *asel, struct vrf *vrf) case CAND_ADDR_ANY: is_any = true; - /* fallthru */ + fallthrough; case CAND_ADDR_LO: FOR_ALL_INTERFACES (vrf, ifp) { if (!if_is_up(ifp)) diff --git a/pimd/pim_signals.c b/pimd/pim_signals.c index 146a4e9e9887..ed3ada209b83 100644 --- a/pimd/pim_signals.c +++ b/pimd/pim_signals.c @@ -25,14 +25,14 @@ static void pim_sighup(void) zlog_info("SIGHUP received, ignoring"); } -static void pim_sigint(void) +static __attribute__((__noreturn__)) void pim_sigint(void) { zlog_notice("Terminating on signal SIGINT"); pim_terminate(); exit(1); } -static void pim_sigterm(void) +static __attribute__((__noreturn__)) void pim_sigterm(void) { zlog_notice("Terminating on signal SIGTERM"); pim_terminate(); diff --git a/ripd/rip_main.c b/ripd/rip_main.c index cfe4a7e43762..602c60fcc403 100644 --- a/ripd/rip_main.c +++ b/ripd/rip_main.c @@ -69,7 +69,7 @@ static void sighup(void) } /* SIGINT handler. */ -static void sigint(void) +static __attribute__((__noreturn__)) void sigint(void) { struct vrf *vrf; diff --git a/ripngd/ripng_main.c b/ripngd/ripng_main.c index b3584b9c3a7e..c45c1fc96a45 100644 --- a/ripngd/ripng_main.c +++ b/ripngd/ripng_main.c @@ -67,7 +67,7 @@ static void sighup(void) } /* SIGINT handler. */ -static void sigint(void) +static __attribute__((__noreturn__)) void sigint(void) { struct vrf *vrf; diff --git a/sharpd/sharp_main.c b/sharpd/sharp_main.c index 2e72a4b99095..b3e4c32922eb 100644 --- a/sharpd/sharp_main.c +++ b/sharpd/sharp_main.c @@ -90,7 +90,7 @@ static void sighup(void) } /* SIGINT / SIGTERM handler. */ -static void sigint(void) +static __attribute__((__noreturn__)) void sigint(void) { zlog_notice("Terminating on signal"); diff --git a/staticd/static_main.c b/staticd/static_main.c index 3b59ca6a7518..a4b3bf3c9080 100644 --- a/staticd/static_main.c +++ b/staticd/static_main.c @@ -65,7 +65,7 @@ static void sighup(void) } /* SIGINT / SIGTERM handler. */ -static void sigint(void) +static __attribute__((__noreturn__)) void sigint(void) { zlog_notice("Terminating on signal"); diff --git a/vtysh/vtysh_main.c b/vtysh/vtysh_main.c index 297d87ec419d..72ed828f5a21 100644 --- a/vtysh/vtysh_main.c +++ b/vtysh/vtysh_main.c @@ -156,7 +156,7 @@ static void vtysh_signal_init(void) } /* Help information display. */ -static void usage(int status) +static __attribute__((__noreturn__)) void usage(int status) { if (status != 0) fprintf(stderr, "Try `%s --help' for more information.\n", diff --git a/watchfrr/watchfrr.c b/watchfrr/watchfrr.c index 611a7872d013..c3fa165b6277 100644 --- a/watchfrr/watchfrr.c +++ b/watchfrr/watchfrr.c @@ -1090,7 +1090,7 @@ void watchfrr_status(struct vty *vty) } } -static void sigint(void) +static __attribute__((__noreturn__)) void sigint(void) { zlog_notice("Terminating on signal"); systemd_send_stopping();