From e92a7e9c147cbac94aae44bb81f245bf99220a11 Mon Sep 17 00:00:00 2001 From: Donald Sharp Date: Fri, 5 Jan 2024 12:53:34 -0500 Subject: [PATCH 1/5] bgpd: Clean up issues found in SA with clang 14 3 different issues: a) length never used b) safi never used c) length never used. Signed-off-by: Donald Sharp --- bgpd/bgp_snmp_bgp4v2.c | 8 -------- 1 file changed, 8 deletions(-) diff --git a/bgpd/bgp_snmp_bgp4v2.c b/bgpd/bgp_snmp_bgp4v2.c index 48db73a343ca..0c8ed33d43ae 100644 --- a/bgpd/bgp_snmp_bgp4v2.c +++ b/bgpd/bgp_snmp_bgp4v2.c @@ -436,7 +436,6 @@ bgp4v2PathAttrLookup(struct variable *v, oid name[], size_t *length, struct bgp_path_info *path, *min; struct bgp_dest *dest; union sockunion su; - unsigned int len; struct ipaddr paddr = {}; size_t namelen = v ? v->namelen : BGP4V2_NLRI_ENTRY_OFFSET; sa_family_t family; @@ -544,11 +543,9 @@ bgp4v2PathAttrLookup(struct variable *v, oid name[], size_t *length, /* Set OID offset for prefix type */ offset = name + namelen; offsetlen = *length - namelen; - len = offsetlen; if (offsetlen == 0) { dest = bgp_table_top(bgp->rib[afi][SAFI_UNICAST]); - safi = SAFI_UNICAST; } else { /* bgp4V2NlriAfi is already get */ @@ -595,11 +592,6 @@ bgp4v2PathAttrLookup(struct variable *v, oid name[], size_t *length, return NULL; if (offsetlen > 0) { - len = offsetlen; - if (len > afi_len) - len = afi_len; - - /* get bgp4V2PeerRemoteAddrType */ peer_addr_type = *offset; if (peer_addr_type == IANA_AFI_IPV4) From be80dbc826e47429d09c502e681a9f72b457a551 Mon Sep 17 00:00:00 2001 From: Donald Sharp Date: Fri, 5 Jan 2024 12:57:06 -0500 Subject: [PATCH 2/5] pimd: Cleanup SA issue with value never used Signed-off-by: Donald Sharp --- pimd/pim_upstream.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pimd/pim_upstream.c b/pimd/pim_upstream.c index 335c8a454bd5..45c4df0e7e1d 100644 --- a/pimd/pim_upstream.c +++ b/pimd/pim_upstream.c @@ -909,7 +909,7 @@ static struct pim_upstream *pim_upstream_new(struct pim_instance *pim, * Set the right RPF so that future changes will * be right */ - rpf_result = pim_rpf_update(pim, up, NULL, __func__); + (void)pim_rpf_update(pim, up, NULL, __func__); pim_upstream_keep_alive_timer_start( up, pim->keep_alive_time); } From 84877e60db54ec04fb09d3f628d8eabdfa8fdea8 Mon Sep 17 00:00:00 2001 From: Donald Sharp Date: Fri, 5 Jan 2024 12:59:53 -0500 Subject: [PATCH 3/5] ospf6d: Value set is never used Signed-off-by: Donald Sharp --- ospf6d/ospf6_neighbor.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ospf6d/ospf6_neighbor.c b/ospf6d/ospf6_neighbor.c index 0cf3aade10a5..a6089b264195 100644 --- a/ospf6d/ospf6_neighbor.c +++ b/ospf6d/ospf6_neighbor.c @@ -741,7 +741,7 @@ DEFPY(ipv6_ospf6_p2xp_neigh, ipv6_ospf6_p2xp_neigh_cmd, return CMD_SUCCESS; } - p2xp_cfg = ospf6_if_p2xp_get(oi, &neighbor); + (void)ospf6_if_p2xp_get(oi, &neighbor); return CMD_SUCCESS; } From 3f03ec1021600ee24e1654443f00a57facab62d6 Mon Sep 17 00:00:00 2001 From: Donald Sharp Date: Fri, 5 Jan 2024 13:02:16 -0500 Subject: [PATCH 4/5] bgpd: data is set but never used I've kept the assignment in a comment because I am concerned about new code being added later that the data pointer would not be set correctly. Next coder can see the commented out line and uncomment it. Signed-off-by: Donald Sharp --- bgpd/bgp_packet.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/bgpd/bgp_packet.c b/bgpd/bgp_packet.c index ca8dade8e8b8..f94b64d0bda4 100644 --- a/bgpd/bgp_packet.c +++ b/bgpd/bgp_packet.c @@ -3349,7 +3349,7 @@ static void bgp_dynamic_capability_fqdn(uint8_t *pnt, int action, memcpy(&str, data, len); str[len] = '\0'; } - data += len; + /* data += len; In case new code is ever added */ if (len) { XFREE(MTYPE_BGP_PEER_HOST, peer->domainname); From 54ed53f36f42b52fd84ad010d31031454f20bd13 Mon Sep 17 00:00:00 2001 From: Donald Sharp Date: Fri, 5 Jan 2024 13:24:59 -0500 Subject: [PATCH 5/5] zebra: SA incorrectly believes a NULL pointer SA has decided that old_re could be a NULL pointer even though the zebra_redistribute_check function checks for NULL and returns false that would not allow a NULL pointer deref. Signed-off-by: Donald Sharp --- zebra/redistribute.c | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/zebra/redistribute.c b/zebra/redistribute.c index 18eac0044a12..70ace35a86f0 100644 --- a/zebra/redistribute.c +++ b/zebra/redistribute.c @@ -332,6 +332,14 @@ void redistribute_delete(const struct route_node *rn, /* Send a delete for the 'old' re to any subscribed client. */ if (zebra_redistribute_check(rn, old_re, client)) { + /* + * SA is complaining that old_re could be false + * SA is wrong because old_re is checked for NULL + * in zebra_redistribute_check and false is + * returned in that case. Let's just make SA + * happy. + */ + assert(old_re); is_table_direct = zebra_redistribute_is_table_direct(old_re); zsend_redistribute_route(ZEBRA_REDISTRIBUTE_ROUTE_DEL, client, rn, old_re,