lib,ripd: clean up -Wshadow compiler warnings

Clean up compiler warnings; convert a linklist macro
to an inline to resolve one; clean up a side-effect in isisd.

Signed-off-by: Mark Stapp <mjs@cisco.com>
This commit is contained in:
Mark Stapp 2025-03-26 13:40:59 -04:00
parent 9362c9b370
commit 536944dc53
5 changed files with 32 additions and 26 deletions

View file

@ -26,12 +26,14 @@ long int flags_get_index(struct flags *flags)
{ {
struct listnode *node; struct listnode *node;
long int index; long int index;
const void *ptr;
if (flags->free_idcs == NULL || flags->free_idcs->count == 0) { if (flags->free_idcs == NULL || flags->free_idcs->count == 0) {
index = flags->maxindex++; index = flags->maxindex++;
} else { } else {
node = listhead(flags->free_idcs); node = listhead(flags->free_idcs);
index = (long int)listgetdata(node); ptr = listgetdata(node);
index = (long int)ptr;
listnode_delete(flags->free_idcs, (void *)index); listnode_delete(flags->free_idcs, (void *)index);
index--; index--;
} }

View file

@ -67,7 +67,11 @@ struct list {
#define listcount(X) ((X)->count) #define listcount(X) ((X)->count)
#define list_isempty(X) ((X)->head == NULL && (X)->tail == NULL) #define list_isempty(X) ((X)->head == NULL && (X)->tail == NULL)
/* return X->data only if X and X->data are not NULL */ /* return X->data only if X and X->data are not NULL */
#define listgetdata(X) (assert(X), assert((X)->data != NULL), (X)->data) static inline void *listgetdata(const struct listnode *X)
{
assert((X != NULL) && ((X)->data != NULL));
return X->data;
}
/* App is going to manage listnode memory */ /* App is going to manage listnode memory */
#define listset_app_node_mem(X) ((X)->flags |= LINKLIST_FLAG_NODE_MEM_BY_APP) #define listset_app_node_mem(X) ((X)->flags |= LINKLIST_FLAG_NODE_MEM_BY_APP)
#define listnode_init(X, val) ((X)->data = (val)) #define listnode_init(X, val) ((X)->data = (val))

View file

@ -15,7 +15,7 @@
DEFINE_MTYPE(RIPD, RIP_BFD_PROFILE, "RIP BFD profile name"); DEFINE_MTYPE(RIPD, RIP_BFD_PROFILE, "RIP BFD profile name");
extern struct zclient *zclient; extern struct zclient *ripd_zclient;
static const char *rip_bfd_interface_profile(struct rip_interface *ri) static const char *rip_bfd_interface_profile(struct rip_interface *ri)
{ {
@ -117,5 +117,5 @@ void rip_bfd_instance_update(struct rip *rip)
void rip_bfd_init(struct event_loop *tm) void rip_bfd_init(struct event_loop *tm)
{ {
bfd_protocol_integration_init(zclient, tm); bfd_protocol_integration_init(ripd_zclient, tm);
} }

View file

@ -553,11 +553,11 @@ static uint8_t *rip2PeerTable(struct variable *v, oid name[], size_t *length,
} }
/* Register RIPv2-MIB. */ /* Register RIPv2-MIB. */
static int rip_snmp_init(struct event_loop *master) static int rip_snmp_init(struct event_loop *mstr)
{ {
rip_ifaddr_table = route_table_init(); rip_ifaddr_table = route_table_init();
smux_init(master); smux_init(mstr);
REGISTER_MIB("mibII/rip", rip_variables, variable, rip_oid); REGISTER_MIB("mibII/rip", rip_variables, variable, rip_oid);
return 0; return 0;
} }

View file

@ -21,7 +21,7 @@
#include "ripd/rip_interface.h" #include "ripd/rip_interface.h"
/* All information about zebra. */ /* All information about zebra. */
struct zclient *zclient = NULL; struct zclient *ripd_zclient = NULL;
/* Send ECMP routes to zebra. */ /* Send ECMP routes to zebra. */
static void rip_zebra_ipv4_send(struct rip *rip, struct route_node *rp, static void rip_zebra_ipv4_send(struct rip *rip, struct route_node *rp,
@ -72,7 +72,7 @@ static void rip_zebra_ipv4_send(struct rip *rip, struct route_node *rp,
api.tag = rinfo->tag; api.tag = rinfo->tag;
} }
zclient_route_send(cmd, zclient, &api); zclient_route_send(cmd, ripd_zclient, &api);
if (IS_RIP_DEBUG_ZEBRA) { if (IS_RIP_DEBUG_ZEBRA) {
if (rip->ecmp) if (rip->ecmp)
@ -137,14 +137,14 @@ static int rip_zebra_read_route(ZAPI_CALLBACK_ARGS)
void rip_redistribute_conf_update(struct rip *rip, int type) void rip_redistribute_conf_update(struct rip *rip, int type)
{ {
zebra_redistribute_send(ZEBRA_REDISTRIBUTE_ADD, zclient, AFI_IP, zebra_redistribute_send(ZEBRA_REDISTRIBUTE_ADD, ripd_zclient, AFI_IP,
type, 0, rip->vrf->vrf_id); type, 0, rip->vrf->vrf_id);
} }
void rip_redistribute_conf_delete(struct rip *rip, int type) void rip_redistribute_conf_delete(struct rip *rip, int type)
{ {
if (zclient->sock > 0) if (ripd_zclient->sock > 0)
zebra_redistribute_send(ZEBRA_REDISTRIBUTE_DELETE, zclient, zebra_redistribute_send(ZEBRA_REDISTRIBUTE_DELETE, ripd_zclient,
AFI_IP, type, 0, rip->vrf->vrf_id); AFI_IP, type, 0, rip->vrf->vrf_id);
/* Remove the routes from RIP table. */ /* Remove the routes from RIP table. */
@ -162,7 +162,7 @@ void rip_redistribute_enable(struct rip *rip)
if (!rip_redistribute_check(rip, i)) if (!rip_redistribute_check(rip, i))
continue; continue;
zebra_redistribute_send(ZEBRA_REDISTRIBUTE_ADD, zclient, AFI_IP, zebra_redistribute_send(ZEBRA_REDISTRIBUTE_ADD, ripd_zclient, AFI_IP,
i, 0, rip->vrf->vrf_id); i, 0, rip->vrf->vrf_id);
} }
} }
@ -173,7 +173,7 @@ void rip_redistribute_disable(struct rip *rip)
if (!rip_redistribute_check(rip, i)) if (!rip_redistribute_check(rip, i))
continue; continue;
zebra_redistribute_send(ZEBRA_REDISTRIBUTE_DELETE, zclient, zebra_redistribute_send(ZEBRA_REDISTRIBUTE_DELETE, ripd_zclient,
AFI_IP, i, 0, rip->vrf->vrf_id); AFI_IP, i, 0, rip->vrf->vrf_id);
} }
} }
@ -181,7 +181,7 @@ void rip_redistribute_disable(struct rip *rip)
void rip_show_redistribute_config(struct vty *vty, struct rip *rip) void rip_show_redistribute_config(struct vty *vty, struct rip *rip)
{ {
for (int i = 0; i < ZEBRA_ROUTE_MAX; i++) { for (int i = 0; i < ZEBRA_ROUTE_MAX; i++) {
if (i == zclient->redist_default if (i == ripd_zclient->redist_default
|| !rip_redistribute_check(rip, i)) || !rip_redistribute_check(rip, i))
continue; continue;
@ -198,8 +198,8 @@ void rip_zebra_vrf_register(struct vrf *vrf)
zlog_debug("%s: register VRF %s(%u) to zebra", __func__, zlog_debug("%s: register VRF %s(%u) to zebra", __func__,
vrf->name, vrf->vrf_id); vrf->name, vrf->vrf_id);
zclient_send_reg_requests(zclient, vrf->vrf_id); zclient_send_reg_requests(ripd_zclient, vrf->vrf_id);
bfd_client_sendmsg(zclient, ZEBRA_BFD_CLIENT_REGISTER, vrf->vrf_id); bfd_client_sendmsg(ripd_zclient, ZEBRA_BFD_CLIENT_REGISTER, vrf->vrf_id);
} }
void rip_zebra_vrf_deregister(struct vrf *vrf) void rip_zebra_vrf_deregister(struct vrf *vrf)
@ -211,8 +211,8 @@ void rip_zebra_vrf_deregister(struct vrf *vrf)
zlog_debug("%s: deregister VRF %s(%u) from zebra.", __func__, zlog_debug("%s: deregister VRF %s(%u) from zebra.", __func__,
vrf->name, vrf->vrf_id); vrf->name, vrf->vrf_id);
zclient_send_dereg_requests(zclient, vrf->vrf_id); zclient_send_dereg_requests(ripd_zclient, vrf->vrf_id);
bfd_client_sendmsg(zclient, ZEBRA_BFD_CLIENT_DEREGISTER, vrf->vrf_id); bfd_client_sendmsg(ripd_zclient, ZEBRA_BFD_CLIENT_DEREGISTER, vrf->vrf_id);
} }
static void rip_zebra_connected(struct zclient *zclient) static void rip_zebra_connected(struct zclient *zclient)
@ -233,18 +233,18 @@ static void rip_zebra_capabilities(struct zclient_capabilities *cap)
zebra_ecmp_count = MIN(cap->ecmp, zebra_ecmp_count); zebra_ecmp_count = MIN(cap->ecmp, zebra_ecmp_count);
} }
void rip_zclient_init(struct event_loop *master) void rip_zclient_init(struct event_loop *mst)
{ {
/* Set default value to the zebra client structure. */ /* Set default value to the zebra client structure. */
zclient = zclient_new(master, &zclient_options_default, rip_handlers, ripd_zclient = zclient_new(mst, &zclient_options_default, rip_handlers,
array_size(rip_handlers)); array_size(rip_handlers));
zclient_init(zclient, ZEBRA_ROUTE_RIP, 0, &ripd_privs); zclient_init(ripd_zclient, ZEBRA_ROUTE_RIP, 0, &ripd_privs);
zclient->zebra_connected = rip_zebra_connected; ripd_zclient->zebra_connected = rip_zebra_connected;
zclient->zebra_capabilities = rip_zebra_capabilities; ripd_zclient->zebra_capabilities = rip_zebra_capabilities;
} }
void rip_zclient_stop(void) void rip_zclient_stop(void)
{ {
zclient_stop(zclient); zclient_stop(ripd_zclient);
zclient_free(zclient); zclient_free(ripd_zclient);
} }