From 5be982966c7d252c9279c1f9e3d1ada1235820f5 Mon Sep 17 00:00:00 2001 From: Mark Stapp Date: Thu, 23 Jan 2025 15:42:52 -0500 Subject: [PATCH] ospf6: clean up -Wshadow warnings Clean up various "shadow" warnings. Signed-off-by: Mark Stapp --- ospf6d/ospf6_abr.c | 2 -- ospf6d/ospf6_area.h | 12 ++++---- ospf6d/ospf6_asbr.c | 4 +-- ospf6d/ospf6_bfd.c | 4 +-- ospf6d/ospf6_main.c | 6 ++-- ospf6d/ospf6_snmp.c | 4 +-- ospf6d/ospf6_top.c | 12 ++++---- ospf6d/ospf6_top.h | 1 - ospf6d/ospf6_zebra.c | 70 ++++++++++++++++++++++---------------------- ospf6d/ospf6_zebra.h | 4 +-- ospf6d/ospf6d.c | 4 +-- 11 files changed, 59 insertions(+), 64 deletions(-) diff --git a/ospf6d/ospf6_abr.c b/ospf6d/ospf6_abr.c index 343dfefcec..2cb63d8a29 100644 --- a/ospf6d/ospf6_abr.c +++ b/ospf6d/ospf6_abr.c @@ -515,8 +515,6 @@ int ospf6_abr_originate_summary_to_area(struct ospf6_route *route, summary->path.origin.id = ADV_ROUTER_IN_PREFIX(&route->prefix); } else { - struct ospf6_lsa *old; - summary->path.origin.type = htons(OSPF6_LSTYPE_INTER_PREFIX); diff --git a/ospf6d/ospf6_area.h b/ospf6d/ospf6_area.h index 2ed69cc597..16049427ac 100644 --- a/ospf6d/ospf6_area.h +++ b/ospf6d/ospf6_area.h @@ -123,16 +123,16 @@ struct ospf6_area { #define OSPF6_CMD_AREA_GET(str, oa, ospf6) \ { \ - uint32_t area_id; \ - int format, ret; \ - ret = str2area_id(str, &area_id, &format); \ - if (ret) { \ + uint32_t _area_id; \ + int _format, _ret; \ + _ret = str2area_id(str, &_area_id, &_format); \ + if (_ret) { \ vty_out(vty, "Malformed Area-ID: %s\n", str); \ return CMD_WARNING; \ } \ - oa = ospf6_area_lookup(area_id, ospf6); \ + oa = ospf6_area_lookup(_area_id, ospf6); \ if (oa == NULL) \ - oa = ospf6_area_create(area_id, ospf6, format); \ + oa = ospf6_area_create(_area_id, ospf6, _format); \ } /* prototypes */ diff --git a/ospf6d/ospf6_asbr.c b/ospf6d/ospf6_asbr.c index 8fa85badbe..df2758b081 100644 --- a/ospf6d/ospf6_asbr.c +++ b/ospf6d/ospf6_asbr.c @@ -1899,7 +1899,7 @@ static void ospf6_redistribute_default_set(struct ospf6 *ospf6, int originate) break; case DEFAULT_ORIGINATE_ZEBRA: zclient_redistribute_default(ZEBRA_REDISTRIBUTE_DEFAULT_DELETE, - zclient, AFI_IP6, ospf6->vrf_id); + ospf6_zclient, AFI_IP6, ospf6->vrf_id); ospf6_asbr_redistribute_remove(DEFAULT_ROUTE, 0, (struct prefix *)&p, ospf6); @@ -1915,7 +1915,7 @@ static void ospf6_redistribute_default_set(struct ospf6 *ospf6, int originate) break; case DEFAULT_ORIGINATE_ZEBRA: zclient_redistribute_default(ZEBRA_REDISTRIBUTE_DEFAULT_ADD, - zclient, AFI_IP6, ospf6->vrf_id); + ospf6_zclient, AFI_IP6, ospf6->vrf_id); break; case DEFAULT_ORIGINATE_ALWAYS: diff --git a/ospf6d/ospf6_bfd.c b/ospf6d/ospf6_bfd.c index 6379f9d992..0b00558572 100644 --- a/ospf6d/ospf6_bfd.c +++ b/ospf6d/ospf6_bfd.c @@ -27,8 +27,6 @@ #include "ospf6_zebra.h" #include "ospf6_bfd.h" -extern struct zclient *zclient; - /* * ospf6_bfd_trigger_event - Neighbor is registered/deregistered with BFD when * neighbor state is changed to/from 2way. @@ -280,7 +278,7 @@ DEFUN (no_ipv6_ospf6_bfd, void ospf6_bfd_init(void) { - bfd_protocol_integration_init(zclient, master); + bfd_protocol_integration_init(ospf6_zclient, master); /* Install BFD command */ install_element(INTERFACE_NODE, &ipv6_ospf6_bfd_cmd); diff --git a/ospf6d/ospf6_main.c b/ospf6d/ospf6_main.c index 8320f11f6c..e94f2a1c47 100644 --- a/ospf6d/ospf6_main.c +++ b/ospf6d/ospf6_main.c @@ -104,9 +104,9 @@ static void __attribute__((noreturn)) ospf6_exit(int status) vrf_terminate(); - if (zclient) { - zclient_stop(zclient); - zclient_free(zclient); + if (ospf6_zclient) { + zclient_stop(ospf6_zclient); + zclient_free(ospf6_zclient); } ospf6_master_delete(); diff --git a/ospf6d/ospf6_snmp.c b/ospf6d/ospf6_snmp.c index 9ac8b6c1af..037ca9bc0b 100644 --- a/ospf6d/ospf6_snmp.c +++ b/ospf6d/ospf6_snmp.c @@ -1382,9 +1382,9 @@ static int ospf6TrapIfStateChange(struct ospf6_interface *oi, int next_state, } /* Register OSPFv3-MIB. */ -static int ospf6_snmp_init(struct event_loop *master) +static int ospf6_snmp_init(struct event_loop *mstr) { - smux_init(master); + smux_init(mstr); REGISTER_MIB("OSPFv3MIB", ospfv3_variables, variable, ospfv3_oid); return 0; } diff --git a/ospf6d/ospf6_top.c b/ospf6d/ospf6_top.c index ad487f3565..9755cc44cc 100644 --- a/ospf6d/ospf6_top.c +++ b/ospf6d/ospf6_top.c @@ -142,20 +142,20 @@ static void ospf6_set_redist_vrf_bitmaps(struct ospf6 *ospf6, bool set) "%s: setting redist vrf %d bitmap for type %d", __func__, ospf6->vrf_id, type); if (set) - vrf_bitmap_set(&zclient->redist[AFI_IP6][type], + vrf_bitmap_set(&ospf6_zclient->redist[AFI_IP6][type], ospf6->vrf_id); else - vrf_bitmap_unset(&zclient->redist[AFI_IP6][type], + vrf_bitmap_unset(&ospf6_zclient->redist[AFI_IP6][type], ospf6->vrf_id); } red_list = ospf6->redist[DEFAULT_ROUTE]; if (red_list) { if (set) - vrf_bitmap_set(&zclient->default_information[AFI_IP6], + vrf_bitmap_set(&ospf6_zclient->default_information[AFI_IP6], ospf6->vrf_id); else - vrf_bitmap_unset(&zclient->default_information[AFI_IP6], + vrf_bitmap_unset(&ospf6_zclient->default_information[AFI_IP6], ospf6->vrf_id); } } @@ -566,13 +566,13 @@ static void ospf6_disable(struct ospf6 *o) } } -void ospf6_master_init(struct event_loop *master) +void ospf6_master_init(struct event_loop *mst) { memset(&ospf6_master, 0, sizeof(ospf6_master)); om6 = &ospf6_master; om6->ospf6 = list_new(); - om6->master = master; + om6->master = mst; } void ospf6_master_delete(void) diff --git a/ospf6d/ospf6_top.h b/ospf6d/ospf6_top.h index 8288413c10..2b29eeae89 100644 --- a/ospf6d/ospf6_top.h +++ b/ospf6d/ospf6_top.h @@ -231,7 +231,6 @@ DECLARE_QOBJ_TYPE(ospf6); #define OSPF6_STUB_ROUTER 0x02 /* global pointer for OSPF top data structure */ -extern struct ospf6 *ospf6; extern struct ospf6_master *om6; /* prototypes */ diff --git a/ospf6d/ospf6_zebra.c b/ospf6d/ospf6_zebra.c index 466301309f..cfb9bc1c11 100644 --- a/ospf6d/ospf6_zebra.c +++ b/ospf6d/ospf6_zebra.c @@ -36,11 +36,11 @@ DEFINE_MTYPE_STATIC(OSPF6D, OSPF6_DISTANCE, "OSPF6 distance"); unsigned char conf_debug_ospf6_zebra = 0; /* information about zebra. */ -struct zclient *zclient = NULL; +struct zclient *ospf6_zclient = NULL; void ospf6_zebra_vrf_register(struct ospf6 *ospf6) { - if (!zclient || zclient->sock < 0 || !ospf6) + if (!ospf6_zclient || ospf6_zclient->sock < 0 || !ospf6) return; if (ospf6->vrf_id != VRF_UNKNOWN) { @@ -49,13 +49,13 @@ void ospf6_zebra_vrf_register(struct ospf6 *ospf6) ospf6_vrf_id_to_name(ospf6->vrf_id), ospf6->vrf_id); } - zclient_send_reg_requests(zclient, ospf6->vrf_id); + zclient_send_reg_requests(ospf6_zclient, ospf6->vrf_id); } } void ospf6_zebra_vrf_deregister(struct ospf6 *ospf6) { - if (!zclient || zclient->sock < 0 || !ospf6) + if (!ospf6_zclient || ospf6_zclient->sock < 0 || !ospf6) return; if (ospf6->vrf_id != VRF_DEFAULT && ospf6->vrf_id != VRF_UNKNOWN) { @@ -67,7 +67,7 @@ void ospf6_zebra_vrf_deregister(struct ospf6 *ospf6) } /* Deregister for router-id, interfaces, * redistributed routes. */ - zclient_send_dereg_requests(zclient, ospf6->vrf_id); + zclient_send_dereg_requests(ospf6_zclient, ospf6->vrf_id); } } @@ -98,22 +98,22 @@ static int ospf6_router_id_update_zebra(ZAPI_CALLBACK_ARGS) /* redistribute function */ void ospf6_zebra_redistribute(int type, vrf_id_t vrf_id) { - if (vrf_bitmap_check(&zclient->redist[AFI_IP6][type], vrf_id)) + if (vrf_bitmap_check(&ospf6_zclient->redist[AFI_IP6][type], vrf_id)) return; - vrf_bitmap_set(&zclient->redist[AFI_IP6][type], vrf_id); + vrf_bitmap_set(&ospf6_zclient->redist[AFI_IP6][type], vrf_id); - if (zclient->sock > 0) - zebra_redistribute_send(ZEBRA_REDISTRIBUTE_ADD, zclient, + if (ospf6_zclient->sock > 0) + zebra_redistribute_send(ZEBRA_REDISTRIBUTE_ADD, ospf6_zclient, AFI_IP6, type, 0, vrf_id); } void ospf6_zebra_no_redistribute(int type, vrf_id_t vrf_id) { - if (!vrf_bitmap_check(&zclient->redist[AFI_IP6][type], vrf_id)) + if (!vrf_bitmap_check(&ospf6_zclient->redist[AFI_IP6][type], vrf_id)) return; - vrf_bitmap_unset(&zclient->redist[AFI_IP6][type], vrf_id); - if (zclient->sock > 0) - zebra_redistribute_send(ZEBRA_REDISTRIBUTE_DELETE, zclient, + vrf_bitmap_unset(&ospf6_zclient->redist[AFI_IP6][type], vrf_id); + if (ospf6_zclient->sock > 0) + zebra_redistribute_send(ZEBRA_REDISTRIBUTE_DELETE, ospf6_zclient, AFI_IP6, type, 0, vrf_id); } @@ -122,7 +122,7 @@ void ospf6_zebra_import_default_route(struct ospf6 *ospf6, bool unreg) struct prefix prefix = {}; int command; - if (zclient->sock < 0) { + if (ospf6_zclient->sock < 0) { if (IS_OSPF6_DEBUG_ZEBRA(SEND)) zlog_debug(" Not connected to Zebra"); return; @@ -141,7 +141,7 @@ void ospf6_zebra_import_default_route(struct ospf6 *ospf6, bool unreg) zserv_command_string(command), &prefix, ospf6->vrf_id); - if (zclient_send_rnh(zclient, command, &prefix, SAFI_UNICAST, false, + if (zclient_send_rnh(ospf6_zclient, command, &prefix, SAFI_UNICAST, false, true, ospf6->vrf_id) == ZCLIENT_SEND_FAILURE) flog_err(EC_LIB_ZAPI_SOCKET, "%s: zclient_send_rnh() failed", @@ -216,7 +216,7 @@ static int ospf6_zebra_gr_update(struct ospf6 *ospf6, int command, { struct zapi_cap api; - if (!zclient || zclient->sock < 0 || !ospf6) + if (!ospf6_zclient || ospf6_zclient->sock < 0 || !ospf6) return 1; memset(&api, 0, sizeof(api)); @@ -224,7 +224,7 @@ static int ospf6_zebra_gr_update(struct ospf6 *ospf6, int command, api.stale_removal_time = stale_time; api.vrf_id = ospf6->vrf_id; - (void)zclient_capabilities_send(ZEBRA_CLIENT_CAPABILITIES, zclient, + (void)zclient_capabilities_send(ZEBRA_CLIENT_CAPABILITIES, ospf6_zclient, &api); return 0; @@ -313,7 +313,7 @@ DEFUN(show_zebra, json_object *json_zebra; json_object *json_array; - if (zclient == NULL) { + if (ospf6_zclient == NULL) { vty_out(vty, "Not connected to zebra\n"); return CMD_SUCCESS; } @@ -323,13 +323,13 @@ DEFUN(show_zebra, json_zebra = json_object_new_object(); json_array = json_object_new_array(); - json_object_int_add(json_zebra, "fail", zclient->fail); + json_object_int_add(json_zebra, "fail", ospf6_zclient->fail); json_object_int_add( json_zebra, "redistributeDefault", - vrf_bitmap_check(&zclient->default_information[AFI_IP6], + vrf_bitmap_check(&ospf6_zclient->default_information[AFI_IP6], VRF_DEFAULT)); for (i = 0; i < ZEBRA_ROUTE_MAX; i++) { - if (vrf_bitmap_check(&zclient->redist[AFI_IP6][i], + if (vrf_bitmap_check(&ospf6_zclient->redist[AFI_IP6][i], VRF_DEFAULT)) json_object_array_add( json_array, @@ -342,13 +342,13 @@ DEFUN(show_zebra, vty_json(vty, json); } else { vty_out(vty, "Zebra Information\n"); - vty_out(vty, " fail: %d\n", zclient->fail); + vty_out(vty, " fail: %d\n", ospf6_zclient->fail); vty_out(vty, " redistribute default: %d\n", - vrf_bitmap_check(&zclient->default_information[AFI_IP6], + vrf_bitmap_check(&ospf6_zclient->default_information[AFI_IP6], VRF_DEFAULT)); vty_out(vty, " redistribute:"); for (i = 0; i < ZEBRA_ROUTE_MAX; i++) { - if (vrf_bitmap_check(&zclient->redist[AFI_IP6][i], + if (vrf_bitmap_check(&ospf6_zclient->redist[AFI_IP6][i], VRF_DEFAULT)) vty_out(vty, " %s", zebra_route_string(i)); } @@ -403,7 +403,7 @@ static void ospf6_zebra_route_update(int type, struct ospf6_route *request, zlog_debug("Zebra Send %s route: %pFX", (type == REM ? "remove" : "add"), &request->prefix); - if (zclient->sock < 0) { + if (ospf6_zclient->sock < 0) { if (IS_OSPF6_DEBUG_ZEBRA(SEND)) zlog_debug(" Not connected to Zebra"); return; @@ -487,9 +487,9 @@ static void ospf6_zebra_route_update(int type, struct ospf6_route *request, ospf6_zebra_append_opaque_attr(request, &api); if (type == REM) - ret = zclient_route_send(ZEBRA_ROUTE_DELETE, zclient, &api); + ret = zclient_route_send(ZEBRA_ROUTE_DELETE, ospf6_zclient, &api); else - ret = zclient_route_send(ZEBRA_ROUTE_ADD, zclient, &api); + ret = zclient_route_send(ZEBRA_ROUTE_ADD, ospf6_zclient, &api); if (ret == ZCLIENT_SEND_FAILURE) flog_err(EC_LIB_ZAPI_SOCKET, @@ -552,7 +552,7 @@ void ospf6_zebra_add_discard(struct ospf6_route *request, struct ospf6 *ospf6) api.prefix = *dest; zapi_route_set_blackhole(&api, BLACKHOLE_NULL); - zclient_route_send(ZEBRA_ROUTE_ADD, zclient, &api); + zclient_route_send(ZEBRA_ROUTE_ADD, ospf6_zclient, &api); if (IS_OSPF6_DEBUG_ZEBRA(SEND)) zlog_debug("Zebra: Route add discard %pFX", dest); @@ -589,7 +589,7 @@ void ospf6_zebra_delete_discard(struct ospf6_route *request, api.prefix = *dest; zapi_route_set_blackhole(&api, BLACKHOLE_NULL); - zclient_route_send(ZEBRA_ROUTE_DELETE, zclient, &api); + zclient_route_send(ZEBRA_ROUTE_DELETE, ospf6_zclient, &api); if (IS_OSPF6_DEBUG_ZEBRA(SEND)) zlog_debug("Zebra: Route delete discard %pFX", dest); @@ -758,14 +758,14 @@ static zclient_handler *const ospf6_handlers[] = { [ZEBRA_REDISTRIBUTE_ROUTE_DEL] = ospf6_zebra_read_route, }; -void ospf6_zebra_init(struct event_loop *master) +void ospf6_zebra_init(struct event_loop *mst) { /* Allocate zebra structure. */ - zclient = zclient_new(master, &zclient_options_default, ospf6_handlers, - array_size(ospf6_handlers)); - zclient_init(zclient, ZEBRA_ROUTE_OSPF6, 0, &ospf6d_privs); - zclient->zebra_connected = ospf6_zebra_connected; - zclient->nexthop_update = ospf6_zebra_import_check_update; + ospf6_zclient = zclient_new(mst, &zclient_options_default, ospf6_handlers, + array_size(ospf6_handlers)); + zclient_init(ospf6_zclient, ZEBRA_ROUTE_OSPF6, 0, &ospf6d_privs); + ospf6_zclient->zebra_connected = ospf6_zebra_connected; + ospf6_zclient->nexthop_update = ospf6_zebra_import_check_update; /* Install command element for zebra node. */ install_element(VIEW_NODE, &show_ospf6_zebra_cmd); diff --git a/ospf6d/ospf6_zebra.h b/ospf6d/ospf6_zebra.h index 7669b5e2c0..0ad86e8c9a 100644 --- a/ospf6d/ospf6_zebra.h +++ b/ospf6d/ospf6_zebra.h @@ -27,7 +27,7 @@ struct ospf6_distance { char *access_list; }; -extern struct zclient *zclient; +extern struct zclient *ospf6_zclient; struct ospf6; extern void ospf6_zebra_route_update_add(struct ospf6_route *request, @@ -38,7 +38,7 @@ extern void ospf6_zebra_route_update_remove(struct ospf6_route *request, extern void ospf6_zebra_redistribute(int, vrf_id_t vrf_id); extern void ospf6_zebra_no_redistribute(int, vrf_id_t vrf_id); #define ospf6_zebra_is_redistribute(type, vrf_id) \ - vrf_bitmap_check(&zclient->redist[AFI_IP6][type], vrf_id) + vrf_bitmap_check(&ospf6_zclient->redist[AFI_IP6][type], vrf_id) extern void ospf6_zebra_init(struct event_loop *tm); extern void ospf6_zebra_import_default_route(struct ospf6 *ospf6, bool unreg); extern void ospf6_zebra_add_discard(struct ospf6_route *request, diff --git a/ospf6d/ospf6d.c b/ospf6d/ospf6d.c index e4e0354fc9..ddb8a461d5 100644 --- a/ospf6d/ospf6d.c +++ b/ospf6d/ospf6d.c @@ -1408,13 +1408,13 @@ static void install_element_ospf6_debug_event(void) } /* Install ospf related commands. */ -void ospf6_init(struct event_loop *master) +void ospf6_init(struct event_loop *mst) { ospf6_top_init(); ospf6_area_init(); ospf6_interface_init(); ospf6_neighbor_init(); - ospf6_zebra_init(master); + ospf6_zebra_init(mst); ospf6_lsa_init(); ospf6_spf_init(); -- 2.39.5