From 7fe96307ee288bd28a54ba4ddfa559a1cf07bb7f Mon Sep 17 00:00:00 2001 From: "F. Aragon" Date: Thu, 13 Sep 2018 17:37:08 +0200 Subject: [PATCH] bgpd lib ospf6d pbrd tests zebra: shadowing fixes This fixes all remaining local variable shadowing cases Signed-off-by: F. Aragon --- bgpd/bgp_vty.c | 4 ++-- bgpd/rfapi/bgp_rfapi_cfg.c | 34 +++++++++++++++++----------------- bgpd/rfapi/vnc_import_bgp.c | 6 +++--- lib/plist.c | 6 +++--- lib/termtable.c | 6 +++--- lib/vrf.h | 8 ++++---- lib/zebra.h | 12 ++++++------ ospf6d/ospf6d.h | 6 +++--- pbrd/pbr_nht.c | 8 ++++---- tests/lib/cli/test_commands.c | 6 +++--- tests/lib/test_srcdest_table.c | 1 - zebra/interface.c | 6 +++--- 12 files changed, 51 insertions(+), 52 deletions(-) diff --git a/bgpd/bgp_vty.c b/bgpd/bgp_vty.c index 3669ea7736..e6c7ebd45f 100644 --- a/bgpd/bgp_vty.c +++ b/bgpd/bgp_vty.c @@ -7367,7 +7367,7 @@ DEFUN (show_bgp_vrfs, for (ALL_LIST_ELEMENTS_RO(inst, node, bgp)) { const char *name, *type; struct peer *peer; - struct listnode *node, *nnode; + struct listnode *node2, *nnode2; int peers_cfg, peers_estb; json_object *json_vrf = NULL; @@ -7387,7 +7387,7 @@ DEFUN (show_bgp_vrfs, json_vrf = json_object_new_object(); - for (ALL_LIST_ELEMENTS(bgp->peer, node, nnode, peer)) { + for (ALL_LIST_ELEMENTS(bgp->peer, node2, nnode2, peer)) { if (!CHECK_FLAG(peer->flags, PEER_FLAG_CONFIG_NODE)) continue; peers_cfg++; diff --git a/bgpd/rfapi/bgp_rfapi_cfg.c b/bgpd/rfapi/bgp_rfapi_cfg.c index f1dd08fda0..15e3974248 100644 --- a/bgpd/rfapi/bgp_rfapi_cfg.c +++ b/bgpd/rfapi/bgp_rfapi_cfg.c @@ -4015,21 +4015,21 @@ int bgp_rfapi_cfg_write(struct vty *vty, struct bgp *bgp) vty_out(vty, "!\n"); if (hc->l2_groups) { - struct rfapi_l2_group_cfg *rfg = NULL; + struct rfapi_l2_group_cfg *rfgc = NULL; struct listnode *gnode; - for (ALL_LIST_ELEMENTS_RO(hc->l2_groups, gnode, rfg)) { + for (ALL_LIST_ELEMENTS_RO(hc->l2_groups, gnode, rfgc)) { struct listnode *lnode; void *data; ++write; - vty_out(vty, " vnc l2-group %s\n", rfg->name); - if (rfg->logical_net_id != 0) + vty_out(vty, " vnc l2-group %s\n", rfgc->name); + if (rfgc->logical_net_id != 0) vty_out(vty, " logical-network-id %u\n", - rfg->logical_net_id); - if (rfg->labels != NULL - && listhead(rfg->labels) != NULL) { + rfgc->logical_net_id); + if (rfgc->labels != NULL + && listhead(rfgc->labels) != NULL) { vty_out(vty, " labels "); - for (ALL_LIST_ELEMENTS_RO(rfg->labels, + for (ALL_LIST_ELEMENTS_RO(rfgc->labels, lnode, data)) { vty_out(vty, "%hu ", @@ -4040,28 +4040,28 @@ int bgp_rfapi_cfg_write(struct vty *vty, struct bgp *bgp) vty_out(vty, "\n"); } - if (rfg->rt_import_list && rfg->rt_export_list - && ecommunity_cmp(rfg->rt_import_list, - rfg->rt_export_list)) { + if (rfgc->rt_import_list && rfgc->rt_export_list + && ecommunity_cmp(rfgc->rt_import_list, + rfgc->rt_export_list)) { char *b = ecommunity_ecom2str( - rfg->rt_import_list, + rfgc->rt_import_list, ECOMMUNITY_FORMAT_ROUTE_MAP, ECOMMUNITY_ROUTE_TARGET); vty_out(vty, " rt both %s\n", b); XFREE(MTYPE_ECOMMUNITY_STR, b); } else { - if (rfg->rt_import_list) { + if (rfgc->rt_import_list) { char *b = ecommunity_ecom2str( - rfg->rt_import_list, + rfgc->rt_import_list, ECOMMUNITY_FORMAT_ROUTE_MAP, ECOMMUNITY_ROUTE_TARGET); vty_out(vty, " rt import %s\n", b); XFREE(MTYPE_ECOMMUNITY_STR, b); } - if (rfg->rt_export_list) { + if (rfgc->rt_export_list) { char *b = ecommunity_ecom2str( - rfg->rt_export_list, + rfgc->rt_export_list, ECOMMUNITY_FORMAT_ROUTE_MAP, ECOMMUNITY_ROUTE_TARGET); vty_out(vty, " rt export %s\n", @@ -4074,7 +4074,7 @@ int bgp_rfapi_cfg_write(struct vty *vty, struct bgp *bgp) .cfg_group_cb)( vty, bgp->rfapi->rfp, RFAPI_RFP_CFG_GROUP_L2, - rfg->name, rfg->rfp_cfg); + rfgc->name, rfgc->rfp_cfg); vty_out(vty, " exit-vnc\n"); vty_out(vty, "!\n"); } diff --git a/bgpd/rfapi/vnc_import_bgp.c b/bgpd/rfapi/vnc_import_bgp.c index dc37ff89b5..74dc20a93c 100644 --- a/bgpd/rfapi/vnc_import_bgp.c +++ b/bgpd/rfapi/vnc_import_bgp.c @@ -2398,11 +2398,11 @@ void vnc_import_bgp_exterior_add_route_interior( } if (list_adopted) { struct listnode *node; - struct agg_node *bi_exterior; + struct agg_node *an_bi_exterior; - for (ALL_LIST_ELEMENTS_RO(list_adopted, node, bi_exterior)) { + for (ALL_LIST_ELEMENTS_RO(list_adopted, node, an_bi_exterior)) { skiplist_delete(it->monitor_exterior_orphans, - bi_exterior, NULL); + an_bi_exterior, NULL); } list_delete_and_null(&list_adopted); } diff --git a/lib/plist.c b/lib/plist.c index f8dd7df0be..ee68fbc0f1 100644 --- a/lib/plist.c +++ b/lib/plist.c @@ -1252,13 +1252,13 @@ static int vty_show_prefix_list_prefix(struct vty *vty, afi_t afi, if (pentry->any) vty_out(vty, "any"); else { - struct prefix *p = &pentry->prefix; + struct prefix *pf = &pentry->prefix; char buf[BUFSIZ]; vty_out(vty, "%s/%d", - inet_ntop(p->family, p->u.val, buf, + inet_ntop(pf->family, pf->u.val, buf, BUFSIZ), - p->prefixlen); + pf->prefixlen); if (pentry->ge) vty_out(vty, " ge %d", pentry->ge); diff --git a/lib/termtable.c b/lib/termtable.c index 7bdb1ff873..4f5f9ff218 100644 --- a/lib/termtable.c +++ b/lib/termtable.c @@ -140,8 +140,8 @@ static struct ttable_cell *ttable_insert_row_va(struct ttable *tt, int i, int ncols = 0; /* count how many columns we have */ - for (int i = 0; format[i]; i++) - ncols += !!(format[i] == '|'); + for (int j = 0; format[j]; j++) + ncols += !!(format[j] == '|'); ncols++; if (tt->ncols == 0) @@ -459,7 +459,7 @@ char *ttable_dump(struct ttable *tt, const char *newline) memcpy(&buf[pos], left, lsize); pos += lsize; - for (size_t i = 0; i < width - lsize - rsize; i++) + for (size_t l = 0; l < width - lsize - rsize; l++) buf[pos++] = row[0].style.border.bottom; pos -= width - lsize - rsize; diff --git a/lib/vrf.h b/lib/vrf.h index c962ac4c69..f0dabf5b24 100644 --- a/lib/vrf.h +++ b/lib/vrf.h @@ -111,8 +111,8 @@ extern vrf_id_t vrf_name_to_id(const char *); #define VRF_GET_ID(V, NAME, USE_JSON) \ do { \ - struct vrf *vrf; \ - if (!(vrf = vrf_lookup_by_name(NAME))) { \ + struct vrf *_vrf; \ + if (!(_vrf = vrf_lookup_by_name(NAME))) { \ if (USE_JSON) { \ vty_out(vty, "{}\n"); \ } else { \ @@ -120,7 +120,7 @@ extern vrf_id_t vrf_name_to_id(const char *); } \ return CMD_WARNING; \ } \ - if (vrf->vrf_id == VRF_UNKNOWN) { \ + if (_vrf->vrf_id == VRF_UNKNOWN) { \ if (USE_JSON) { \ vty_out(vty, "{}\n"); \ } else { \ @@ -128,7 +128,7 @@ extern vrf_id_t vrf_name_to_id(const char *); } \ return CMD_WARNING; \ } \ - (V) = vrf->vrf_id; \ + (V) = _vrf->vrf_id; \ } while (0) /* diff --git a/lib/zebra.h b/lib/zebra.h index d80aa06935..4e0e408ea6 100644 --- a/lib/zebra.h +++ b/lib/zebra.h @@ -333,18 +333,18 @@ struct in_pktinfo { #endif #define MAX(a, b) \ ({ \ - typeof(a) _a = (a); \ - typeof(b) _b = (b); \ - _a > _b ? _a : _b; \ + typeof(a) _max_a = (a); \ + typeof(b) _max_b = (b); \ + _max_a > _max_b ? _max_a : _max_b; \ }) #ifdef MIN #undef MIN #endif #define MIN(a, b) \ ({ \ - typeof(a) _a = (a); \ - typeof(b) _b = (b); \ - _a < _b ? _a : _b; \ + typeof(a) _min_a = (a); \ + typeof(b) _min_b = (b); \ + _min_a < _min_b ? _min_a : _min_b; \ }) #ifndef offsetof diff --git a/ospf6d/ospf6d.h b/ospf6d/ospf6d.h index f95381084d..36f3c2233f 100644 --- a/ospf6d/ospf6d.h +++ b/ospf6d/ospf6d.h @@ -72,12 +72,12 @@ extern struct thread_master *master; #define threadtimer_string(now, t, buf, size) \ do { \ - struct timeval result; \ + struct timeval _result; \ if (!t) \ snprintf(buf, size, "inactive"); \ else { \ - timersub(&t->u.sands, &now, &result); \ - timerstring(&result, buf, size); \ + timersub(&t->u.sands, &now, &_result); \ + timerstring(&_result, buf, size); \ } \ } while (0) diff --git a/pbrd/pbr_nht.c b/pbrd/pbr_nht.c index a8cefce84f..7376e3e95b 100644 --- a/pbrd/pbr_nht.c +++ b/pbrd/pbr_nht.c @@ -586,13 +586,13 @@ struct pbr_nexthop_group_cache *pbr_nht_add_group(const char *name) pnhgc); for (ALL_NEXTHOPS(nhgc->nhg, nhop)) { - struct pbr_nexthop_cache lookup; + struct pbr_nexthop_cache lookupc; struct pbr_nexthop_cache *pnhc; - lookup.nexthop = nhop; - pnhc = hash_lookup(pnhgc->nhh, &lookup); + lookupc.nexthop = nhop; + pnhc = hash_lookup(pnhgc->nhh, &lookupc); if (!pnhc) { - pnhc = hash_get(pnhgc->nhh, &lookup, pbr_nh_alloc); + pnhc = hash_get(pnhgc->nhh, &lookupc, pbr_nh_alloc); pnhc->parent = pnhgc; } } diff --git a/tests/lib/cli/test_commands.c b/tests/lib/cli/test_commands.c index 2a8d263175..a8b42ba789 100644 --- a/tests/lib/cli/test_commands.c +++ b/tests/lib/cli/test_commands.c @@ -265,10 +265,10 @@ static void test_run(struct prng *prng, struct vty *vty, const char *cmd, if (descriptions != NULL) { for (j = 0; j < vector_active(descriptions); j++) { - struct cmd_token *cmd = + struct cmd_token *ct = vector_slot(descriptions, j); - printf(" '%s' '%s'\n", cmd->text, - cmd->desc); + printf(" '%s' '%s'\n", ct->text, + ct->desc); } vector_free(descriptions); } diff --git a/tests/lib/test_srcdest_table.c b/tests/lib/test_srcdest_table.c index e717da15b3..70db69aadf 100644 --- a/tests/lib/test_srcdest_table.c +++ b/tests/lib/test_srcdest_table.c @@ -289,7 +289,6 @@ static void test_state_verify(struct test_state *test) expected_lock++; if (rn->lock != expected_lock) { - const struct prefix_ipv6 *dst_p, *src_p; srcdest_rnode_prefixes( rn, (const struct prefix **)&dst_p, (const struct prefix **)&src_p); diff --git a/zebra/interface.c b/zebra/interface.c index 488980c46f..b4882edb9c 100644 --- a/zebra/interface.c +++ b/zebra/interface.c @@ -2901,13 +2901,13 @@ static int link_params_config_write(struct vty *vty, struct interface *ifp) static int if_config_write(struct vty *vty) { - struct vrf *vrf; + struct vrf *vrf0; struct interface *ifp; zebra_ptm_write(vty); - RB_FOREACH (vrf, vrf_name_head, &vrfs_by_name) - FOR_ALL_INTERFACES (vrf, ifp) { + RB_FOREACH (vrf0, vrf_name_head, &vrfs_by_name) + FOR_ALL_INTERFACES (vrf0, ifp) { struct zebra_if *if_data; struct listnode *addrnode; struct connected *ifc;