]> git.puffer.fish Git - matthieu/frr.git/commitdiff
pimd: clean up clang warnings
authorMark Stapp <mjs@cisco.com>
Wed, 16 Apr 2025 15:38:35 +0000 (11:38 -0400)
committerMark Stapp <mjs@cisco.com>
Wed, 16 Apr 2025 17:50:21 +0000 (13:50 -0400)
Clean up clang warnings in pimd; mostly address-of-packed
issues (removed some ugly casts too).

Signed-off-by: Mark Stapp <mjs@cisco.com>
pimd/pim_autorp.c
pimd/pim_bsm.c
pimd/pim_bsr_rpdb.c

index d3f3517efdad052b83b12b9896abb4f54f790a4a..85a6737d4c1892b08cd37ff0119d305148397ff0 100644 (file)
@@ -283,8 +283,8 @@ static bool autorp_recv_announcement(struct pim_autorp *autorp, uint8_t rpcnt, u
                /* Ignore RP's limited to PIM version 1 or with an unknown version */
                if (rp->pimver == AUTORP_PIM_V1 || rp->pimver == AUTORP_PIM_VUNKNOWN) {
                        if (PIM_DEBUG_AUTORP)
-                               zlog_debug("%s: Ignoring unsupported PIM version (%u) in AutoRP Announcement for RP %pI4",
-                                          __func__, rp->pimver, (in_addr_t *)&(rp->addr));
+                               zlog_debug("%s: Ignoring unsupported PIM version (%u) in AutoRP Announcement for RP %pPA",
+                                          __func__, rp->pimver, &rp_addr);
                        /* Update the offset to skip past the groups advertised for this RP */
                        offset += (AUTORP_GRPLEN * rp->grpcnt);
                        continue;
@@ -293,14 +293,14 @@ static bool autorp_recv_announcement(struct pim_autorp *autorp, uint8_t rpcnt, u
                if (rp->grpcnt == 0) {
                        /* No groups?? */
                        if (PIM_DEBUG_AUTORP)
-                               zlog_debug("%s: Announcement message has no groups for RP %pI4",
-                                          __func__, (in_addr_t *)&(rp->addr));
+                               zlog_debug("%s: Announcement message has no groups for RP %pPA",
+                                          __func__, &rp_addr);
                        continue;
                }
 
                if ((buf_size - offset) < AUTORP_GRPLEN) {
-                       zlog_warn("%s: Buffer underrun parsing groups for RP %pI4", __func__,
-                                 (in_addr_t *)&(rp->addr));
+                       zlog_warn("%s: Buffer underrun parsing groups for RP %pPA", __func__,
+                                 &rp_addr);
                        return false;
                }
 
@@ -765,14 +765,14 @@ static bool autorp_recv_discovery(struct pim_autorp *autorp, uint8_t rpcnt, uint
                rp_addr.s_addr = rp->addr;
 
                if (PIM_DEBUG_AUTORP)
-                       zlog_debug("%s: Parsing RP %pI4 (grpcnt=%u)", __func__,
-                                  (in_addr_t *)&rp->addr, rp->grpcnt);
+                       zlog_debug("%s: Parsing RP %pPA (grpcnt=%u)", __func__, &rp_addr,
+                                  rp->grpcnt);
 
                /* Ignore RP's limited to PIM version 1 or with an unknown version */
                if (rp->pimver == AUTORP_PIM_V1 || rp->pimver == AUTORP_PIM_VUNKNOWN) {
                        if (PIM_DEBUG_AUTORP)
                                zlog_debug("%s: Ignoring unsupported PIM version in AutoRP Discovery for RP %pI4",
-                                          __func__, (in_addr_t *)&(rp->addr));
+                                          __func__, &rp_addr);
                        /* Update the offset to skip past the groups advertised for this RP */
                        offset += (AUTORP_GRPLEN * rp->grpcnt);
                        continue;
@@ -781,17 +781,16 @@ static bool autorp_recv_discovery(struct pim_autorp *autorp, uint8_t rpcnt, uint
                if (rp->grpcnt == 0) {
                        /* No groups?? */
                        if (PIM_DEBUG_AUTORP)
-                               zlog_debug("%s: Discovery message has no groups for RP %pI4",
-                                          __func__, (in_addr_t *)&(rp->addr));
+                               zlog_debug("%s: Discovery message has no groups for RP %pPA",
+                                          __func__, &rp_addr);
                        continue;
                }
 
                /* Make sure there is enough buffer to parse all the groups */
                if ((buf_size - offset) < (AUTORP_GRPLEN * rp->grpcnt)) {
                        if (PIM_DEBUG_AUTORP)
-                               zlog_debug("%s: Buffer underrun parsing groups for RP %pI4 (%u < %u)",
-                                          __func__, (in_addr_t *)&(rp->addr),
-                                          (uint32_t)(buf_size - offset),
+                               zlog_debug("%s: Buffer underrun parsing groups for RP %pPA (%u < %u)",
+                                          __func__, &rp_addr, (uint32_t)(buf_size - offset),
                                           (uint32_t)(AUTORP_GRPLEN * rp->grpcnt));
                        return false;
                }
@@ -809,8 +808,7 @@ static bool autorp_recv_discovery(struct pim_autorp *autorp, uint8_t rpcnt, uint
 
                        if (PIM_DEBUG_AUTORP)
                                zlog_debug("%s: Parsing group %s%pFX for RP %pI4", __func__,
-                                          (grp->negprefix ? "!" : ""), &grppfix,
-                                          (in_addr_t *)&rp->addr);
+                                          (grp->negprefix ? "!" : ""), &grppfix, &rp_addr);
 
                        if (!pim_autorp_add_rp(autorp, rp_addr, grppfix, NULL, holdtime))
                                success = false;
@@ -856,9 +854,9 @@ static bool autorp_recv_discovery(struct pim_autorp *autorp, uint8_t rpcnt, uint
                                prefix_list_entry_update_finish(ple);
 
                                if (PIM_DEBUG_AUTORP)
-                                       zlog_debug("%s: Parsing group %s%pFX for RP %pI4", __func__,
+                                       zlog_debug("%s: Parsing group %s%pFX for RP %pPA", __func__,
                                                   (grp->negprefix ? "!" : ""), &ple->prefix,
-                                                  (in_addr_t *)&rp->addr);
+                                                  &rp_addr);
                        }
 
                        if (!pim_autorp_add_rp(autorp, rp_addr, grppfix, plname, holdtime))
index 50fe543b23cec76f59c559472543d6b84877e458..845467755ab2b904dd25ad10c223c782fd9bf44b 100644 (file)
@@ -1562,8 +1562,7 @@ int pim_bsm_process(struct interface *ifp, pim_sgaddr *sg, uint8_t *buf,
                    (buf + PIM_BSM_HDR_LEN + PIM_MSG_HEADER_LEN),
                    (buf_size - PIM_BSM_HDR_LEN - PIM_MSG_HEADER_LEN),
                    frag_tag)) {
-               zlog_warn("BSM from %pPA failed to parse",
-                         (pim_addr *)&bshdr->bsr_addr.addr);
+               zlog_warn("BSM from %pPA failed to parse", &bsr_addr);
                pim->bsm_dropped++;
                return -1;
        }
@@ -1802,7 +1801,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))
index 860009312d9618b3704065a8bc17fae23deea263..03ceabd733d56b6f2052fbd3eb0707c13d377e4a 100644 (file)
@@ -455,6 +455,8 @@ int pim_crp_process(struct interface *ifp, pim_sgaddr *src_dst, uint8_t *buf,
        struct pim_interface *pim_ifp = NULL;
        struct pim_instance *pim;
        struct bsm_scope *scope;
+       size_t ngroups;
+       pim_addr rpaddr = {};
 
        pim_ifp = ifp->info;
        if (!pim_ifp) {
@@ -505,20 +507,19 @@ int pim_crp_process(struct interface *ifp, pim_sgaddr *src_dst, uint8_t *buf,
        /* ignore trailing data */
        (void)buf;
 
-       size_t ngroups = crp_hdr->prefix_cnt;
+       ngroups = crp_hdr->prefix_cnt;
+       rpaddr = crp_hdr->rp_addr.addr;
 
        if (remain < ngroups * sizeof(struct pim_encoded_group_ipv4)) {
                if (PIM_DEBUG_BSM)
                        zlog_debug("truncated Candidate-RP advertisement for RP %pPA from %pPA (too short for %zu groups)",
-                                  (pim_addr *)&crp_hdr->rp_addr.addr,
-                                  &src_dst->src, ngroups);
+                                  &rpaddr, &src_dst->src, ngroups);
                return -1;
        }
 
        if (PIM_DEBUG_BSM)
                zlog_debug("Candidate-RP: %pPA, prio=%u (from %pPA, %zu groups)",
-                          (pim_addr *)&crp_hdr->rp_addr.addr, crp_hdr->rp_prio,
-                          &src_dst->src, ngroups);
+                          (pim_addr *)&rpaddr, crp_hdr->rp_prio, &src_dst->src, ngroups);
 
 
        struct bsr_crp_rp *rp, ref;
@@ -529,16 +530,14 @@ int pim_crp_process(struct interface *ifp, pim_sgaddr *src_dst, uint8_t *buf,
        if (!rp) {
                if (bsr_crp_rps_count(scope->ebsr_rps) >= bsr_max_rps) {
                        zlog_err("BSR: number of tracked Candidate RPs (%zu) exceeds DoS-protection limit (%zu), dropping advertisement for RP %pPA (packet source %pPA)",
-                                bsr_crp_rps_count(scope->ebsr_rps),
-                                bsr_max_rps, (pim_addr *)&crp_hdr->rp_addr.addr,
-                                &src_dst->src);
+                                bsr_crp_rps_count(scope->ebsr_rps), bsr_max_rps,
+                                (pim_addr *)&rpaddr, &src_dst->src);
                        return -1;
                }
 
                if (PIM_DEBUG_BSM)
                        zlog_debug("new Candidate-RP: %pPA (from %pPA)",
-                                  (pim_addr *)&crp_hdr->rp_addr.addr,
-                                  &src_dst->src);
+                                  (pim_addr *)&rpaddr, &src_dst->src);
 
                rp = XCALLOC(MTYPE_PIM_BSR_CRP, sizeof(*rp));
                rp->scope = scope;