]> git.puffer.fish Git - mirror/frr.git/commitdiff
ldpd: clean up warnings from -Wshadow
authorMark Stapp <mjs@cisco.com>
Fri, 24 Jan 2025 20:13:37 +0000 (15:13 -0500)
committerMark Stapp <mjs@cisco.com>
Tue, 8 Apr 2025 18:41:27 +0000 (14:41 -0400)
Clean up various variable-shadow warnings in ldpd.

Signed-off-by: Mark Stapp <mjs@cisco.com>
ldpd/lde.c
ldpd/ldp_snmp.c
ldpd/ldp_vty_exec.c
ldpd/ldp_zebra.c
ldpd/ldpd.c
ldpd/ldpd.h
ldpd/ldpe.c

index 876dd4163099492227395dec37d974e264f76a1d..b0f9e5191f87e4def0e0ca1a475525cedd7121bf 100644 (file)
@@ -538,8 +538,8 @@ static void lde_dispatch_parent(struct event *thread)
                            sizeof(struct ldpd_init))
                                fatalx("INIT imsg with wrong len");
 
-                       memcpy(&init, imsg.data, sizeof(init));
-                       lde_init(&init);
+                       memcpy(&ldp_init, imsg.data, sizeof(ldp_init));
+                       lde_init(&ldp_init);
                        break;
                case IMSG_AGENTX_ENABLED:
                        ldp_agentx_enabled();
index ed391ac6003b8f340e794e207c96414faf05ece3..2e7933f95c941b3acde806dce19577ae93446e2c 100644 (file)
@@ -620,10 +620,10 @@ static uint8_t *ldpHelloAdjacencyTable(struct variable *v, oid name[], size_t *l
                memcpy(name, v->name, v->namelen * sizeof(oid));
 
                /* Append index */
-               struct in_addr entityLdpId = {.s_addr = 0};
+               entityLdpId.s_addr = 0;
                entityLdpId.s_addr = ldp_rtr_id_get(leconf);
 
-               struct in_addr peerLdpId = ctl_adj->id;
+               peerLdpId = ctl_adj->id;
 
                oid_copy_in_addr(name + v->namelen, &entityLdpId);
                name[v->namelen + 4] = 0;
index f3bcd1b254c86ff8b5c9ee8364fa02983c900c7e..20b60bd37367991da0b950f80a4a7305b9845418 100644 (file)
@@ -1954,10 +1954,9 @@ ldp_vty_show_interface(struct vty *vty, const char *af_str, const char *json)
        return (ldp_vty_dispatch(vty, &ibuf, SHOW_IFACE, &params));
 }
 
-int
-ldp_vty_show_capabilities(struct vty *vty, const char *json)
+int ldp_vty_show_capabilities(struct vty *vty, const char *use_json)
 {
-       if (json) {
+       if (use_json) {
                json_object     *json;
                json_object     *json_array;
                json_object     *json_cap;
index df682a1347be6d15d102c53f17d12d53b936729e..cf7ebdff41cd3aa01aea59490afcecab5b029ba7 100644 (file)
@@ -38,7 +38,7 @@ static int    ldp_sync_zebra_send_announce(void);
 static int     ldp_zebra_opaque_msg_handler(ZAPI_CALLBACK_ARGS);
 static void    ldp_sync_zebra_init(void);
 
-static struct zclient  *zclient;
+static struct zclient *ldp_zclient;
 extern struct zclient *zclient_sync;
 static bool zebra_registered = false;
 
@@ -100,23 +100,23 @@ pw2zpw(struct l2vpn_pw *pw, struct zapi_pw *zpw)
 static void
 ldp_zebra_opaque_register(void)
 {
-       zclient_register_opaque(zclient, LDP_IGP_SYNC_IF_STATE_REQUEST);
-       zclient_register_opaque(zclient, LDP_RLFA_REGISTER);
-       zclient_register_opaque(zclient, LDP_RLFA_UNREGISTER_ALL);
+       zclient_register_opaque(ldp_zclient, LDP_IGP_SYNC_IF_STATE_REQUEST);
+       zclient_register_opaque(ldp_zclient, LDP_RLFA_REGISTER);
+       zclient_register_opaque(ldp_zclient, LDP_RLFA_UNREGISTER_ALL);
 }
 
 static void
 ldp_zebra_opaque_unregister(void)
 {
-       zclient_unregister_opaque(zclient, LDP_IGP_SYNC_IF_STATE_REQUEST);
-       zclient_unregister_opaque(zclient, LDP_RLFA_REGISTER);
-       zclient_unregister_opaque(zclient, LDP_RLFA_UNREGISTER_ALL);
+       zclient_unregister_opaque(ldp_zclient, LDP_IGP_SYNC_IF_STATE_REQUEST);
+       zclient_unregister_opaque(ldp_zclient, LDP_RLFA_REGISTER);
+       zclient_unregister_opaque(ldp_zclient, LDP_RLFA_UNREGISTER_ALL);
 }
 
 int
 ldp_sync_zebra_send_state_update(struct ldp_igp_sync_if_state *state)
 {
-       if (zclient_send_opaque(zclient, LDP_IGP_SYNC_IF_STATE_UPDATE,
+       if (zclient_send_opaque(ldp_zclient, LDP_IGP_SYNC_IF_STATE_UPDATE,
                                (const uint8_t *)state, sizeof(*state))
            == ZCLIENT_SEND_FAILURE)
                return -1;
@@ -130,9 +130,9 @@ ldp_sync_zebra_send_announce(void)
        struct ldp_igp_sync_announce announce;
        announce.proto = ZEBRA_ROUTE_LDP;
 
-       if (zclient_send_opaque(zclient, LDP_IGP_SYNC_ANNOUNCE_UPDATE,
-                               (const uint8_t *)&announce, sizeof(announce))
-           == ZCLIENT_SEND_FAILURE)
+       if (zclient_send_opaque(ldp_zclient, LDP_IGP_SYNC_ANNOUNCE_UPDATE,
+                               (const uint8_t *)&announce,
+                               sizeof(announce)) == ZCLIENT_SEND_FAILURE)
                return -1;
        else
                return 0;
@@ -142,7 +142,7 @@ int ldp_zebra_send_rlfa_labels(struct zapi_rlfa_response *rlfa_labels)
 {
        int ret;
 
-       ret = zclient_send_opaque(zclient, LDP_RLFA_LABELS,
+       ret = zclient_send_opaque(ldp_zclient, LDP_RLFA_LABELS,
                                  (const uint8_t *)rlfa_labels,
                                  sizeof(*rlfa_labels));
        if (ret == ZCLIENT_SEND_FAILURE) {
@@ -271,7 +271,7 @@ ldp_zebra_send_mpls_labels(int cmd, struct kroute *kr)
        znh->label_num = 1;
        znh->labels[0] = kr->remote_label;
 
-       if (zebra_send_mpls_labels(zclient, cmd, &zl) == ZCLIENT_SEND_FAILURE)
+       if (zebra_send_mpls_labels(ldp_zclient, cmd, &zl) == ZCLIENT_SEND_FAILURE)
                return -1;
 
        return 0;
@@ -295,7 +295,7 @@ kmpw_add(struct zapi_pw *zpw)
        debug_zebra_out("pseudowire %s nexthop %s (add)",
            zpw->ifname, log_addr(zpw->af, (union ldpd_addr *)&zpw->nexthop));
 
-       return zebra_send_pw(zclient, ZEBRA_PW_ADD, zpw) == ZCLIENT_SEND_FAILURE;
+       return zebra_send_pw(ldp_zclient, ZEBRA_PW_ADD, zpw) == ZCLIENT_SEND_FAILURE;
 }
 
 int
@@ -304,7 +304,7 @@ kmpw_del(struct zapi_pw *zpw)
        debug_zebra_out("pseudowire %s nexthop %s (del)",
            zpw->ifname, log_addr(zpw->af, (union ldpd_addr *)&zpw->nexthop));
 
-       return zebra_send_pw(zclient, ZEBRA_PW_DELETE, zpw) == ZCLIENT_SEND_FAILURE;
+       return zebra_send_pw(ldp_zclient, ZEBRA_PW_DELETE, zpw) == ZCLIENT_SEND_FAILURE;
 }
 
 int
@@ -314,7 +314,7 @@ kmpw_set(struct zapi_pw *zpw)
            zpw->ifname, log_addr(zpw->af, (union ldpd_addr *)&zpw->nexthop),
            zpw->local_label, zpw->remote_label);
 
-       return zebra_send_pw(zclient, ZEBRA_PW_SET, zpw) == ZCLIENT_SEND_FAILURE;
+       return zebra_send_pw(ldp_zclient, ZEBRA_PW_SET, zpw) == ZCLIENT_SEND_FAILURE;
 }
 
 int
@@ -323,7 +323,7 @@ kmpw_unset(struct zapi_pw *zpw)
        debug_zebra_out("pseudowire %s nexthop %s (unset)",
            zpw->ifname, log_addr(zpw->af, (union ldpd_addr *)&zpw->nexthop));
 
-       return zebra_send_pw(zclient, ZEBRA_PW_UNSET, zpw) == ZCLIENT_SEND_FAILURE;
+       return zebra_send_pw(ldp_zclient, ZEBRA_PW_UNSET, zpw) == ZCLIENT_SEND_FAILURE;
 }
 
 void
@@ -620,18 +620,18 @@ void ldp_zebra_regdereg_zebra_info(bool want_register)
                  want_register ? "Register" : "De-register");
 
        if (want_register) {
-               zclient_send_reg_requests(zclient, VRF_DEFAULT);
-               zebra_redistribute_send(ZEBRA_REDISTRIBUTE_ADD, zclient, AFI_IP,
+               zclient_send_reg_requests(ldp_zclient, VRF_DEFAULT);
+               zebra_redistribute_send(ZEBRA_REDISTRIBUTE_ADD, ldp_zclient, AFI_IP,
                                        ZEBRA_ROUTE_ALL, 0, VRF_DEFAULT);
-               zebra_redistribute_send(ZEBRA_REDISTRIBUTE_ADD, zclient,
+               zebra_redistribute_send(ZEBRA_REDISTRIBUTE_ADD, ldp_zclient,
                                        AFI_IP6, ZEBRA_ROUTE_ALL, 0,
                                        VRF_DEFAULT);
        } else {
-               zclient_send_dereg_requests(zclient, VRF_DEFAULT);
-               zebra_redistribute_send(ZEBRA_REDISTRIBUTE_DELETE, zclient,
+               zclient_send_dereg_requests(ldp_zclient, VRF_DEFAULT);
+               zebra_redistribute_send(ZEBRA_REDISTRIBUTE_DELETE, ldp_zclient,
                                        AFI_IP, ZEBRA_ROUTE_ALL, 0,
                                        VRF_DEFAULT);
-               zebra_redistribute_send(ZEBRA_REDISTRIBUTE_DELETE, zclient,
+               zebra_redistribute_send(ZEBRA_REDISTRIBUTE_DELETE, ldp_zclient,
                                        AFI_IP6, ZEBRA_ROUTE_ALL, 0,
                                        VRF_DEFAULT);
        }
@@ -678,7 +678,7 @@ static zclient_handler *const ldp_handlers[] = {
        [ZEBRA_OPAQUE_MESSAGE] = ldp_zebra_opaque_msg_handler,
 };
 
-void ldp_zebra_init(struct event_loop *master)
+void ldp_zebra_init(struct event_loop *mst)
 {
        hook_register_prio(if_real, 0, ldp_ifp_create);
        hook_register_prio(if_up, 0, ldp_ifp_up);
@@ -686,12 +686,12 @@ void ldp_zebra_init(struct event_loop *master)
        hook_register_prio(if_unreal, 0, ldp_ifp_destroy);
 
        /* Set default values. */
-       zclient = zclient_new(master, &zclient_options_default, ldp_handlers,
-                             array_size(ldp_handlers));
-       zclient_init(zclient, ZEBRA_ROUTE_LDP, 0, &ldpd_privs);
+       ldp_zclient = zclient_new(mst, &zclient_options_default, ldp_handlers,
+                                 array_size(ldp_handlers));
+       zclient_init(ldp_zclient, ZEBRA_ROUTE_LDP, 0, &ldpd_privs);
 
        /* set callbacks */
-       zclient->zebra_connected = ldp_zebra_connected;
+       ldp_zclient->zebra_connected = ldp_zebra_connected;
 
        /* Access list initialize. */
        access_list_add_hook(ldp_zebra_filter_update);
@@ -702,9 +702,9 @@ void
 ldp_zebra_destroy(void)
 {
        ldp_zebra_opaque_unregister();
-       zclient_stop(zclient);
-       zclient_free(zclient);
-       zclient = NULL;
+       zclient_stop(ldp_zclient);
+       zclient_free(ldp_zclient);
+       ldp_zclient = NULL;
 
        if (zclient_sync == NULL)
                return;
index 4d38fdcd02c958b025a80aafd0f87f743cd020b6..e4e1dc6fecfbfb80ca0f3382fc1b55306b93ff81 100644 (file)
@@ -74,7 +74,7 @@ DEFINE_QOBJ_TYPE(ldpd_conf);
 const char             *log_procname;
 
 struct ldpd_global      global;
-struct ldpd_init        init;
+struct ldpd_init ldp_init;
 struct ldpd_conf       *ldpd_conf, *vty_conf;
 
 static struct imsgev   *iev_ldpe, *iev_ldpe_sync;
@@ -272,8 +272,8 @@ main(int argc, char *argv[])
                                 "%s/" LDPD_SOCK_NAME, optarg);
                        break;
                case 'n':
-                       init.instance = atoi(optarg);
-                       if (init.instance < 1)
+                       ldp_init.instance = atoi(optarg);
+                       if (ldp_init.instance < 1)
                                exit(0);
                        break;
                case 'L':
@@ -291,11 +291,11 @@ main(int argc, char *argv[])
                snprintf(ctl_sock_path, sizeof(ctl_sock_path),
                         "%s/" LDPD_SOCK_NAME, frr_runstatedir);
 
-       strlcpy(init.user, ldpd_privs.user, sizeof(init.user));
-       strlcpy(init.group, ldpd_privs.group, sizeof(init.group));
-       strlcpy(init.ctl_sock_path, ctl_sock_path, sizeof(init.ctl_sock_path));
-       strlcpy(init.zclient_serv_path, frr_zclientpath,
-           sizeof(init.zclient_serv_path));
+       strlcpy(ldp_init.user, ldpd_privs.user, sizeof(ldp_init.user));
+       strlcpy(ldp_init.group, ldpd_privs.group, sizeof(ldp_init.group));
+       strlcpy(ldp_init.ctl_sock_path, ctl_sock_path, sizeof(ldp_init.ctl_sock_path));
+       strlcpy(ldp_init.zclient_serv_path, frr_zclientpath,
+               sizeof(ldp_init.zclient_serv_path));
 
        argc -= optind;
        if (argc > 0 || (lflag && eflag))
@@ -428,7 +428,7 @@ main(int argc, char *argv[])
                fatal("could not establish imsg links");
 
        main_imsg_compose_both(IMSG_DEBUG_UPDATE, &ldp_debug, sizeof(ldp_debug));
-       main_imsg_compose_both(IMSG_INIT, &init, sizeof(init));
+       main_imsg_compose_both(IMSG_INIT, &ldp_init, sizeof(ldp_init));
        main_imsg_send_config(ldpd_conf);
 
        if (CHECK_FLAG(ldpd_conf->ipv4.flags, F_LDPD_AF_ENABLED))
index ad831a6ea358f2dc457619c8afe1098a3eba4ae9..700c388724f9d8d135a853bd09efbe551ba8d44c 100644 (file)
@@ -739,7 +739,7 @@ struct ctl_ldp_sync {
 
 extern struct ldpd_conf                *ldpd_conf, *vty_conf;
 extern struct ldpd_global       global;
-extern struct ldpd_init                 init;
+extern struct ldpd_init ldp_init;
 
 /* parse.y */
 struct ldpd_conf       *parse_config(char *);
index 0a3a03bc38de091e269fedf515e6510474b5080c..50875e644d8ac460aa4e5f852054e3007a80fa4e 100644 (file)
@@ -373,8 +373,8 @@ static void ldpe_dispatch_main(struct event *thread)
                        if (imsg.hdr.len != IMSG_HEADER_SIZE + sizeof(struct ldpd_init))
                                fatalx("INIT imsg with wrong len");
 
-                       memcpy(&init, imsg.data, sizeof(init));
-                       ldpe_init(&init);
+                       memcpy(&ldp_init, imsg.data, sizeof(ldp_init));
+                       ldpe_init(&ldp_init);
                        break;
                case IMSG_AGENTX_ENABLED:
                        ldp_agentx_enabled();