From a7ec7a773d101059794cc3299dd1f27e9948ec0e Mon Sep 17 00:00:00 2001 From: Donald Sharp Date: Mon, 14 Oct 2024 13:10:20 -0400 Subject: [PATCH 1/3] pimd: Fix dead increment found by clang 19 SA Signed-off-by: Donald Sharp --- pimd/pim_bsr_rpdb.c | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/pimd/pim_bsr_rpdb.c b/pimd/pim_bsr_rpdb.c index 3ec9f99cd198..1aa75c4598d7 100644 --- a/pimd/pim_bsr_rpdb.c +++ b/pimd/pim_bsr_rpdb.c @@ -499,7 +499,12 @@ int pim_crp_process(struct interface *ifp, pim_sgaddr *src_dst, uint8_t *buf, remain -= PIM_MSG_HEADER_LEN; crp_hdr = (struct cand_rp_msg *)buf; - buf += sizeof(*crp_hdr); + /* + * buf += sizeof(*crp_hdr); + * Buff is not used for the remainder of the function + * but if it is we need to uncomment out the above set of the + * ptr for buf + */ remain -= sizeof(*crp_hdr); size_t ngroups = crp_hdr->prefix_cnt; From c5d19e9ffe23c169c2bd0ea8c0e52ff6f5ecbbe2 Mon Sep 17 00:00:00 2001 From: Donald Sharp Date: Mon, 14 Oct 2024 13:17:07 -0400 Subject: [PATCH 2/3] *: Fix clang-19 SA dead initialization found Signed-off-by: Donald Sharp --- bgpd/bgp_fsm.c | 2 +- bgpd/rfapi/bgp_rfapi_cfg.c | 2 +- bgpd/rfapi/rfapi_vty.c | 3 ++- lib/zclient.h | 8 ++++---- lib/zlog_5424_cli.c | 2 +- zebra/zebra_dplane.c | 4 ++-- zebra/zebra_nb_state.c | 2 +- 7 files changed, 12 insertions(+), 11 deletions(-) diff --git a/bgpd/bgp_fsm.c b/bgpd/bgp_fsm.c index cdd9b7ae4d51..13e68c6e3af9 100644 --- a/bgpd/bgp_fsm.c +++ b/bgpd/bgp_fsm.c @@ -2829,7 +2829,7 @@ const char *print_peer_gr_cmd(enum peer_gr_command pr_gr_cmd) const char *print_global_gr_mode(enum global_mode gl_mode) { - const char *global_gr_mode = "???"; + const char *global_gr_mode; switch (gl_mode) { case GLOBAL_HELPER: diff --git a/bgpd/rfapi/bgp_rfapi_cfg.c b/bgpd/rfapi/bgp_rfapi_cfg.c index a452ebe48eb4..fdc5a1494ec0 100644 --- a/bgpd/rfapi/bgp_rfapi_cfg.c +++ b/bgpd/rfapi/bgp_rfapi_cfg.c @@ -4401,7 +4401,7 @@ int bgp_rfapi_cfg_write(struct vty *vty, struct bgp *bgp) if (hc->redist_mode) /* ! default */ { - const char *s = ""; + const char *s; switch (hc->redist_mode) { case VNC_REDIST_MODE_PLAIN: diff --git a/bgpd/rfapi/rfapi_vty.c b/bgpd/rfapi/rfapi_vty.c index 8f1f509bbbe6..ddc1b02d86e6 100644 --- a/bgpd/rfapi/rfapi_vty.c +++ b/bgpd/rfapi/rfapi_vty.c @@ -1256,7 +1256,8 @@ static int rfapiShowRemoteRegistrationsIt(struct bgp *bgp, void *stream, if (!printed_rtlist_hdr) { const char *agetype = ""; char *s; - const char *type = ""; + const char *type; + if (show_imported) { type = "Imported"; } else { diff --git a/lib/zclient.h b/lib/zclient.h index 91c0c9ed6d3d..97878fef8c75 100644 --- a/lib/zclient.h +++ b/lib/zclient.h @@ -251,7 +251,7 @@ enum zebra_error_types { static inline const char *zebra_error_type2str(enum zebra_error_types type) { - const char *ret = "UNKNOWN"; + const char *ret; switch (type) { case ZEBRA_UNKNOWN_ERROR: @@ -780,7 +780,7 @@ enum zclient_send_status { static inline const char * zapi_nhg_notify_owner2str(enum zapi_nhg_notify_owner note) { - const char *ret = "UNKNOWN"; + const char *ret; switch (note) { case ZAPI_NHG_FAIL_INSTALL: @@ -803,7 +803,7 @@ zapi_nhg_notify_owner2str(enum zapi_nhg_notify_owner note) static inline const char * zapi_rule_notify_owner2str(enum zapi_rule_notify_owner note) { - const char *ret = "UNKNOWN"; + const char *ret; switch (note) { case ZAPI_RULE_FAIL_INSTALL: @@ -825,7 +825,7 @@ zapi_rule_notify_owner2str(enum zapi_rule_notify_owner note) static inline const char *zapi_srv6_sid_notify2str(enum zapi_srv6_sid_notify note) { - const char *ret = "UNKNOWN"; + const char *ret; switch (note) { case ZAPI_SRV6_SID_FAIL_ALLOC: diff --git a/lib/zlog_5424_cli.c b/lib/zlog_5424_cli.c index 3003df542f58..72e38e3fbd8b 100644 --- a/lib/zlog_5424_cli.c +++ b/lib/zlog_5424_cli.c @@ -670,7 +670,7 @@ static int log_5424_config_write(struct vty *vty) struct zlog_cfg_5424_user *cfg; frr_each (targets, &targets, cfg) { - const char *fmt_str = ""; + const char *fmt_str; vty_out(vty, "log extended %s\n", cfg->name); diff --git a/zebra/zebra_dplane.c b/zebra/zebra_dplane.c index 00e990e856fd..067ec0c5dfdc 100644 --- a/zebra/zebra_dplane.c +++ b/zebra/zebra_dplane.c @@ -1030,7 +1030,7 @@ enum dplane_op_e dplane_ctx_get_op(const struct zebra_dplane_ctx *ctx) const char *dplane_op2str(enum dplane_op_e op) { - const char *ret = "UNKNOWN"; + const char *ret; switch (op) { case DPLANE_OP_NONE: @@ -1226,7 +1226,7 @@ const char *dplane_op2str(enum dplane_op_e op) const char *dplane_res2str(enum zebra_dplane_result res) { - const char *ret = ""; + const char *ret; switch (res) { case ZEBRA_DPLANE_REQUEST_FAILURE: diff --git a/zebra/zebra_nb_state.c b/zebra/zebra_nb_state.c index 63ac7877d0f9..e55a72dc5199 100644 --- a/zebra/zebra_nb_state.c +++ b/zebra/zebra_nb_state.c @@ -895,7 +895,7 @@ lib_vrf_zebra_ribs_rib_route_route_entry_nexthop_group_nexthop_bh_type_get_elem( struct nb_cb_get_elem_args *args) { struct nexthop *nexthop = (struct nexthop *)args->list_entry; - const char *type_str = ""; + const char *type_str; if (nexthop->type != NEXTHOP_TYPE_BLACKHOLE) return NULL; From 4409dd46d3cbbc7ab0607a67ff0ddef858198de8 Mon Sep 17 00:00:00 2001 From: Donald Sharp Date: Mon, 14 Oct 2024 13:40:56 -0400 Subject: [PATCH 3/3] *: Fix new clang-19 SA `Function call with invalid argument` Signed-off-by: Donald Sharp --- lib/netns_linux.c | 2 +- mgmtd/mgmt_history.c | 3 ++- vtysh/vtysh_main.c | 6 +++--- zebra/zebra_netns_notify.c | 10 +++++++++- 4 files changed, 15 insertions(+), 6 deletions(-) diff --git a/lib/netns_linux.c b/lib/netns_linux.c index 8fa4bc6fe0f7..671df844de5a 100644 --- a/lib/netns_linux.c +++ b/lib/netns_linux.c @@ -194,7 +194,7 @@ static int ns_enable_internal(struct ns *ns, void (*func)(ns_id_t, void *)) if (have_netns()) { ns->fd = open(ns->name, O_RDONLY); } else { - ns->fd = -2; + ns->fd = -1; /* Remember ns_enable_hook has been called */ errno = -ENOTSUP; } diff --git a/mgmtd/mgmt_history.c b/mgmtd/mgmt_history.c index c97cb7f0fdf3..2f2c4634100b 100644 --- a/mgmtd/mgmt_history.c +++ b/mgmtd/mgmt_history.c @@ -154,7 +154,7 @@ static bool mgmt_history_dump_cmt_record_index(void) FILE *fp; int ret = 0; struct mgmt_cmt_info_t *cmt_info; - struct mgmt_cmt_info_t cmt_info_set[10]; + struct mgmt_cmt_info_t cmt_info_set[MGMTD_MAX_COMMIT_LIST]; int cnt = 0; snprintf(index_path, sizeof(index_path), MGMTD_COMMIT_INDEX_FILE_PATH); @@ -166,6 +166,7 @@ static bool mgmt_history_dump_cmt_record_index(void) return false; } + assert(mgmt_cmt_infos_count(&mm->cmts) <= MGMTD_MAX_COMMIT_LIST); FOREACH_CMT_REC (mm, cmt_info) { memcpy(&cmt_info_set[cnt], cmt_info, sizeof(struct mgmt_cmt_info_t)); diff --git a/vtysh/vtysh_main.c b/vtysh/vtysh_main.c index 64198132cc64..555bb1f1d628 100644 --- a/vtysh/vtysh_main.c +++ b/vtysh/vtysh_main.c @@ -350,6 +350,7 @@ int main(int argc, char **argv, char **env) char pathspace[MAXPATHLEN] = ""; const char *histfile = NULL; const char *histfile_env = getenv("VTYSH_HISTFILE"); + const char *logpath; /* SUID: drop down to calling user & go back up when needed */ elevuid = geteuid(); @@ -643,9 +644,8 @@ int main(int argc, char **argv, char **env) } } - if (getenv("VTYSH_LOG")) { - const char *logpath = getenv("VTYSH_LOG"); - + logpath = getenv("VTYSH_LOG"); + if (logpath) { logfile = fopen(logpath, "a"); if (!logfile) { fprintf(stderr, "Failed to open logfile (%s): %s\n", diff --git a/zebra/zebra_netns_notify.c b/zebra/zebra_netns_notify.c index 3ac4fdd73716..8b683c9066a5 100644 --- a/zebra/zebra_netns_notify.c +++ b/zebra/zebra_netns_notify.c @@ -386,11 +386,19 @@ void zebra_ns_notify_parse(void) } while ((dent = readdir(srcdir)) != NULL) { struct stat st; + int dfd; if (strcmp(dent->d_name, ".") == 0 || strcmp(dent->d_name, "..") == 0) continue; - if (fstatat(dirfd(srcdir), dent->d_name, &st, 0) < 0) { + + dfd = dirfd(srcdir); + if (dfd == -1) { + flog_err_sys(EC_LIB_SYSTEM_CALL, "NS parsing directory: %s(%u)", + safe_strerror(errno), errno); + continue; + } + if (fstatat(dfd, dent->d_name, &st, 0) < 0) { flog_err_sys( EC_LIB_SYSTEM_CALL, "NS parsing init: failed to parse entry %s",