]> git.puffer.fish Git - matthieu/frr.git/commitdiff
*: remove the checking returned value for hash_get()
authoranlan_cs <vic.lan@pica8.com>
Thu, 21 Apr 2022 06:37:12 +0000 (02:37 -0400)
committeranlan_cs <vic.lan@pica8.com>
Mon, 2 May 2022 16:41:48 +0000 (00:41 +0800)
Firstly, *keep no change* for `hash_get()` with NULL
`alloc_func`.

Only focus on cases with non-NULL `alloc_func` of
`hash_get()`.

Since `hash_get()` with non-NULL `alloc_func` parameter
shall not fail, just ignore the returned value of it.
The returned value must not be NULL.
So in this case, remove the unnecessary checking NULL
or not for the returned value and add `void` in front
of it.

Importantly, also *keep no change* for the two cases with
non-NULL `alloc_func` -
1) Use `assert(<returned_data> == <searching_data>)` to
   ensure it is a created node, not a found node.
   Refer to `isis_vertex_queue_insert()` of isisd, there
   are many examples of this case in isid.
2) Use `<returned_data> != <searching_data>` to judge it
   is a found node, then free <searching_data>.
   Refer to `aspath_intern()` of bgpd, there are many
   examples of this case in bgpd.

Here, <returned_data> is the returned value from `hash_get()`,
and <searching_data> is the data, which is to be put into
hash table.

Signed-off-by: anlan_cs <vic.lan@pica8.com>
35 files changed:
bgpd/bgp_aspath.c
bgpd/bgp_clist.c
bgpd/bgp_community_alias.c
bgpd/bgp_evpn.c
bgpd/bgp_fsm.c
bgpd/bgp_keepalives.c
bgpd/bgp_network.c
bgpd/bgp_nexthop.c
bgpd/bgp_pbr.c
bgpd/bgp_updgrp.c
bgpd/bgpd.c
isisd/isis_lfa.c
isisd/isis_spf.c
lib/command.c
lib/ferr.c
lib/frrscript.c
lib/northbound.c
nhrpd/reqid.c
ospf6d/ospf6_asbr.c
ospf6d/ospf6_gr_helper.c
ospfd/ospf_asbr.c
ospfd/ospf_gr_helper.c
ospfd/ospf_sr.c
pbrd/pbr_nht.c
pimd/pim_nht.c
tests/lib/test_srcdest_table.c
vrrpd/vrrp.c
zebra/zebra_evpn.c
zebra/zebra_evpn_mac.c
zebra/zebra_evpn_mh.c
zebra/zebra_evpn_neigh.c
zebra/zebra_fpm.c
zebra/zebra_mpls.c
zebra/zebra_nhg.c
zebra/zebra_vxlan.c

index 880e15fadbd3394d2bdc0f0c01826fc4f7361c17..41166de05056f1cfd40a56fc13071af6bd3d4a49 100644 (file)
@@ -861,9 +861,6 @@ struct aspath *aspath_parse(struct stream *s, size_t length, int use32bit)
        /* If already same aspath exist then return it. */
        find = hash_get(ashash, &as, aspath_hash_alloc);
 
-       /* bug! should not happen, let the daemon crash below */
-       assert(find);
-
        /* if the aspath was already hashed free temporary memory. */
        if (find->refcnt) {
                assegment_free_all(as.segments);
index 0631f8b95af81bd3628c40a63c98dfee7d47b9b7..34d4be8c93a27971ff076f6f8539538081c0379c 100644 (file)
@@ -184,7 +184,7 @@ community_list_insert(struct community_list_handler *ch, const char *name,
        new->name_hash = bgp_clist_hash_key_community_list(new);
 
        /* Save for later */
-       hash_get(cm->hash, new, hash_alloc_intern);
+       (void)hash_get(cm->hash, new, hash_alloc_intern);
 
        /* If name is made by all digit character.  We treat it as
           number. */
index caf469c0f7e8a76434390b83e356762136d6bc7a..431e6e00a4a04b2d01110c08f9a67271b4186aaa 100644 (file)
@@ -106,12 +106,12 @@ int bgp_community_alias_write(struct vty *vty)
 
 void bgp_ca_community_insert(struct community_alias *ca)
 {
-       hash_get(bgp_ca_community_hash, ca, bgp_community_alias_alloc);
+       (void)hash_get(bgp_ca_community_hash, ca, bgp_community_alias_alloc);
 }
 
 void bgp_ca_alias_insert(struct community_alias *ca)
 {
-       hash_get(bgp_ca_alias_hash, ca, bgp_community_alias_alloc);
+       (void)hash_get(bgp_ca_alias_hash, ca, bgp_community_alias_alloc);
 }
 
 void bgp_ca_community_delete(struct community_alias *ca)
index 68004e0fdaf410fee273f013abed0a8a24ff3b39..bfe7452fadb58f87b9d302d8ffc5889b049d7231 100644 (file)
@@ -6208,9 +6208,6 @@ static void bgp_evpn_remote_ip_hash_add(struct bgpevpn *vpn,
        }
 
        ip = hash_get(vpn->remote_ip_hash, &tmp, bgp_evpn_remote_ip_hash_alloc);
-       if (!ip)
-               return;
-
        (void)listnode_add(ip->macip_path_list, pi);
 
        bgp_evpn_remote_ip_process_nexthops(vpn, &ip->addr, true);
@@ -6343,7 +6340,7 @@ static void bgp_evpn_link_to_vni_svi_hash(struct bgp *bgp, struct bgpevpn *vpn)
        if (vpn->svi_ifindex == 0)
                return;
 
-       hash_get(bgp->vni_svi_hash, vpn, hash_alloc_intern);
+       (void)hash_get(bgp->vni_svi_hash, vpn, hash_alloc_intern);
 }
 
 static void bgp_evpn_unlink_from_vni_svi_hash(struct bgp *bgp,
index 6854a6501a8a870e401cbffd70ce87c11416321d..32087d51e9b12d4e3a5d09d9e9f9decf59d40f25 100644 (file)
@@ -2271,7 +2271,7 @@ static int bgp_establish(struct peer *peer)
         * so the hash_release is the same for either.
         */
        hash_release(peer->bgp->peerhash, peer);
-       hash_get(peer->bgp->peerhash, peer, hash_alloc_intern);
+       (void)hash_get(peer->bgp->peerhash, peer, hash_alloc_intern);
 
        /* Start BFD peer if not already running. */
        if (peer->bfd_config)
index 3a5adae8748091c6ba940497e23788934147fbb2..4cb7bd788a0a6d15e3006c533f43fb15b3517039 100644 (file)
@@ -256,7 +256,7 @@ void bgp_keepalives_on(struct peer *peer)
                holder.peer = peer;
                if (!hash_lookup(peerhash, &holder)) {
                        struct pkat *pkat = pkat_new(peer);
-                       hash_get(peerhash, pkat, hash_alloc_intern);
+                       (void)hash_get(peerhash, pkat, hash_alloc_intern);
                        peer_lock(peer);
                }
                SET_FLAG(peer->thread_flags, PEER_THREAD_KEEPALIVES_ON);
index 0c325b67815b699dc956178bbc556bc55f16a781..e702ee4fdddc62e17c3821312affc76eb90feaee 100644 (file)
@@ -539,7 +539,7 @@ static void bgp_accept(struct thread *thread)
        peer = peer_create(&su, peer1->conf_if, peer1->bgp, peer1->local_as,
                           peer1->as, peer1->as_type, NULL);
        hash_release(peer->bgp->peerhash, peer);
-       hash_get(peer->bgp->peerhash, peer, hash_alloc_intern);
+       (void)hash_get(peer->bgp->peerhash, peer, hash_alloc_intern);
 
        peer_xfer_config(peer, peer1);
        bgp_peer_gr_flags_update(peer);
index e7bad42f9741a345f2dfe13470f6fb6626f4a8fd..25174ce654f27b53ec5d19060cd5c6b6ee5787a1 100644 (file)
@@ -191,9 +191,6 @@ void bgp_tip_add(struct bgp *bgp, struct in_addr *tip)
        tmp.addr = *tip;
 
        addr = hash_get(bgp->tip_hash, &tmp, bgp_tip_hash_alloc);
-       if (!addr)
-               return;
-
        addr->refcnt++;
 }
 
index d3609cb017fc660c6e6920b101f9b99bf4d00251..352670e6c1fedac72a6af7f3f6c07ab3a437048f 100644 (file)
@@ -2350,7 +2350,7 @@ static void bgp_pbr_policyroute_add_to_zebra_unit(struct bgp *bgp,
                pbr_rule.action = bpa;
                bpr = hash_get(bgp->pbr_rule_hash, &pbr_rule,
                               bgp_pbr_rule_alloc_intern);
-               if (bpr && bpr->unique == 0) {
+               if (bpr->unique == 0) {
                        bpr->unique = ++bgp_pbr_action_counter_unique;
                        bpr->installed = false;
                        bpr->install_in_progress = false;
@@ -2359,7 +2359,7 @@ static void bgp_pbr_policyroute_add_to_zebra_unit(struct bgp *bgp,
                } else
                        bpr_found = true;
                /* already installed */
-               if (bpr_found && bpr) {
+               if (bpr_found) {
                        struct bgp_path_info_extra *extra =
                                bgp_path_info_extra_get(path);
 
@@ -2376,7 +2376,7 @@ static void bgp_pbr_policyroute_add_to_zebra_unit(struct bgp *bgp,
                bgp_pbr_bpa_add(bpa);
 
                /* ip rule add */
-               if (bpr && !bpr->installed)
+               if (!bpr->installed)
                        bgp_send_pbr_rule_action(bpa, bpr, true);
 
                /* A previous entry may already exist
index e85118e58832290358a649bfa408a1a1fcd827d5..fb3f9aae43d59d56d75608127f14abeaae1b5b0f 100644 (file)
@@ -754,8 +754,6 @@ static struct update_group *update_group_create(struct peer_af *paf)
 
        updgrp = hash_get(paf->peer->bgp->update_groups[paf->afid], &tmp,
                          updgrp_hash_alloc);
-       if (!updgrp)
-               return NULL;
        update_group_checkin(updgrp);
 
        if (BGP_DEBUG(update_groups, UPDATE_GROUPS))
index a2361758dc468a5d951f5602bd5714a2a61eb51a..1dcc0dd5c4fe13184f046940a707ce72d9b8d2c4 100644 (file)
@@ -1650,7 +1650,7 @@ void bgp_peer_conf_if_to_su_update(struct peer *peer)
        /*
         * Since our su changed we need to del/add peer to the peerhash
         */
-       hash_get(peer->bgp->peerhash, peer, hash_alloc_intern);
+       (void)hash_get(peer->bgp->peerhash, peer, hash_alloc_intern);
 }
 
 void bgp_recalculate_afi_safi_bestpaths(struct bgp *bgp, afi_t afi, safi_t safi)
@@ -1737,7 +1737,7 @@ struct peer *peer_create(union sockunion *su, const char *conf_if,
        peer = peer_lock(peer); /* bgp peer list reference */
        peer->group = group;
        listnode_add_sort(bgp->peer, peer);
-       hash_get(bgp->peerhash, peer, hash_alloc_intern);
+       (void)hash_get(bgp->peerhash, peer, hash_alloc_intern);
 
        /* Adjust update-group coalesce timer heuristics for # peers. */
        if (bgp->heuristic_coalesce) {
index 348381ee74404e8a11bc5146dcef9601e15510aa..800cac8521e99c1094567a72139bc65939f15802 100644 (file)
@@ -267,8 +267,8 @@ void isis_lfa_excluded_ifaces_clear(struct isis_circuit *circuit, int level)
 void isis_lfa_excluded_iface_add(struct isis_circuit *circuit, int level,
                                 const char *ifname)
 {
-       hash_get(circuit->lfa_excluded_ifaces[level - 1], (char *)ifname,
-                lfa_excl_interface_hash_alloc);
+       (void)hash_get(circuit->lfa_excluded_ifaces[level - 1], (char *)ifname,
+                      lfa_excl_interface_hash_alloc);
 }
 
 /**
index b5fce35b1e6f2ead7bec360aa8d2ce83a6dc43f0..10ba6a35bbeec880d5860a05d1bcd7d70286c17d 100644 (file)
@@ -527,14 +527,14 @@ static void vertex_add_parent_firsthop(struct hash_bucket *bucket, void *arg)
        struct isis_vertex *vertex = arg;
        struct isis_vertex *hop = bucket->data;
 
-       hash_get(vertex->firsthops, hop, hash_alloc_intern);
+       (void)hash_get(vertex->firsthops, hop, hash_alloc_intern);
 }
 
 static void vertex_update_firsthops(struct isis_vertex *vertex,
                                    struct isis_vertex *parent)
 {
        if (vertex->d_N <= 2)
-               hash_get(vertex->firsthops, vertex, hash_alloc_intern);
+               (void)hash_get(vertex->firsthops, vertex, hash_alloc_intern);
 
        if (vertex->d_N < 2 || !parent)
                return;
@@ -606,8 +606,8 @@ isis_spf_add2tent(struct isis_spftree *spftree, enum vertextype vtype, void *id,
                        if (vertex->N.ip.sr.label != MPLS_INVALID_LABEL)
                                vertex->N.ip.sr.present = true;
 
-                       hash_get(spftree->prefix_sids, vertex,
-                                hash_alloc_intern);
+                       (void)hash_get(spftree->prefix_sids, vertex,
+                                      hash_alloc_intern);
                }
        }
 
index a4295100598b760db2f4053c1faa6a908e801996..c4db0456339312f72a5e741057ef7c2ade4232cc 100644 (file)
@@ -315,7 +315,7 @@ void _install_element(enum node_type ntype, const struct cmd_element *cmd)
                return;
        }
 
-       assert(hash_get(cnode->cmd_hash, (void *)cmd, hash_alloc_intern));
+       (void)hash_get(cnode->cmd_hash, (void *)cmd, hash_alloc_intern);
 
        if (cnode->graph_built || !defer_cli_tree) {
                struct graph *graph = graph_new();
index e5b6d7552d825fc9b83db70040c1efbbba15dfb8..9d79f38b7c02509ccd3fb78cf85138ee03335fc3 100644 (file)
@@ -86,7 +86,7 @@ void log_ref_add(struct log_ref *ref)
 
        frr_with_mutex(&refs_mtx) {
                while (ref[i].code != END_FERR) {
-                       hash_get(refs, &ref[i], hash_alloc_intern);
+                       (void)hash_get(refs, &ref[i], hash_alloc_intern);
                        i++;
                }
        }
index 8add44c19e5fec9fb8f6c24d053c20bc9c233b14..a19bd0c3dba54ac81c5e2db051f687173c48579c 100644 (file)
@@ -333,7 +333,7 @@ void frrscript_register_type_codec(struct frrscript_codec *codec)
                assert(!"Type codec double-registered.");
        }
 
-       assert(hash_get(codec_hash, &c, codec_alloc));
+       (void)hash_get(codec_hash, &c, codec_alloc);
 }
 
 void frrscript_register_type_codecs(struct frrscript_codec *codecs)
@@ -399,7 +399,7 @@ int frrscript_load(struct frrscript *fs, const char *function_name,
        /* Add the Lua function state to frrscript */
        struct lua_function_state key = {.name = function_name, .L = L};
 
-       hash_get(fs->lua_function_hash, &key, lua_function_alloc);
+       (void)hash_get(fs->lua_function_hash, &key, lua_function_alloc);
 
        return 0;
 fail:
index 2cc7ac6ea1ad21cad43ba21d7e5bc3d73f5c873c..ccfc3840ecc4d8a00d5bf7dc07d4878c5077f20e 100644 (file)
@@ -2216,7 +2216,8 @@ void nb_running_move_tree(const char *xpath_from, const char *xpath_to)
                strlcpy(entry->xpath, newpath, sizeof(entry->xpath));
                XFREE(MTYPE_TMP, newpath);
 
-               hash_get(running_config_entries, entry, hash_alloc_intern);
+               (void)hash_get(running_config_entries, entry,
+                              hash_alloc_intern);
        }
 
        list_delete(&entries);
index e56bbe3bf779b238c7598a4c66f1bc100bd8a492..738e935ec24c4110523d33da755d0ed32efe0343 100644 (file)
@@ -29,7 +29,7 @@ uint32_t nhrp_reqid_alloc(struct nhrp_reqid_pool *p, struct nhrp_reqid *r,
                if (++p->next_request_id == 0)
                        p->next_request_id = 1;
                r->cb = cb;
-               hash_get(p->reqid_hash, r, hash_alloc_intern);
+               (void)hash_get(p->reqid_hash, r, hash_alloc_intern);
        }
        return r->request_id;
 }
index 63444f8e57d308d8245e7852e8672913e5bb2860..0ca4eb3d5daf985c80a4ebda6fa5bc844ff3dad5 100644 (file)
@@ -1562,7 +1562,7 @@ static void
 ospf6_link_route_to_aggr(struct ospf6_external_aggr_rt *aggr,
                        struct ospf6_route *rt)
 {
-       hash_get(aggr->match_extnl_hash, rt, hash_alloc_intern);
+       (void)hash_get(aggr->match_extnl_hash, rt, hash_alloc_intern);
        rt->aggr_route = aggr;
 }
 
index 7b5ffc920b7a0af2f24fa2026d505db70d72cdf4..493dc6f0938e6ae26b674d5616cd5713cac7d581 100644 (file)
@@ -831,8 +831,8 @@ static void ospf6_gr_helper_support_set_per_routerid(struct ospf6 *ospf6,
 
        } else {
                /* Add the routerid to the enable router hash table */
-               hash_get(ospf6->ospf6_helper_cfg.enable_rtr_list, &temp,
-                        ospf6_enable_rtr_hash_alloc);
+               (void)hash_get(ospf6->ospf6_helper_cfg.enable_rtr_list, &temp,
+                              ospf6_enable_rtr_hash_alloc);
        }
 }
 
index 70581b9085e54559fb75a3a59549516f17431baa..9d4ce97fa5f98c72a7acf159849a11504a7b85ae 100644 (file)
@@ -595,7 +595,7 @@ static void ospf_link_ei_to_aggr(struct ospf_external_aggr_rt *aggr,
                        "%s: Linking extrenal route(%pI4/%d) to aggregator(%pI4/%d)",
                        __func__, &ei->p.prefix, ei->p.prefixlen,
                        &aggr->p.prefix, aggr->p.prefixlen);
-       hash_get(aggr->match_extnl_hash, ei, hash_alloc_intern);
+       (void)hash_get(aggr->match_extnl_hash, ei, hash_alloc_intern);
        ei->aggr_route = aggr;
 }
 
index 92236cf44f564fa3e18258e36ed04b078006a3b4..624133ad6bd23480aec27270d215bdc12f1beeed 100644 (file)
@@ -933,8 +933,8 @@ void ospf_gr_helper_support_set_per_routerid(struct ospf *ospf,
 
        } else {
                /* Add the routerid to the enable router hash table */
-               hash_get(ospf->enable_rtr_list, &temp,
-                        ospf_enable_rtr_hash_alloc);
+               (void)hash_get(ospf->enable_rtr_list, &temp,
+                              ospf_enable_rtr_hash_alloc);
        }
 }
 
index c861685f4eeeee836187fe122a71abcbf5a1c8b5..090a655cee37e9a386b3f4cc7d67610fb916bc8f 100644 (file)
@@ -1463,14 +1463,6 @@ void ospf_sr_ri_lsa_update(struct ospf_lsa *lsa)
                srn = (struct sr_node *)hash_get(OspfSR.neighbors,
                                                 &lsah->adv_router,
                                                 (void *)sr_node_new);
-               /* Sanity check */
-               if (srn == NULL) {
-                       flog_err(
-                               EC_OSPF_SR_NODE_CREATE,
-                               "SR (%s): Abort! can't create SR node in hash table",
-                               __func__);
-                       return;
-               }
                /* update LSA ID */
                srn->instance = ntohl(lsah->id.s_addr);
                /* Copy SRGB */
@@ -1582,14 +1574,6 @@ void ospf_sr_ext_link_lsa_update(struct ospf_lsa *lsa)
                                         (void *)&(lsah->adv_router),
                                         (void *)sr_node_new);
 
-       /* Sanity check */
-       if (srn == NULL) {
-               flog_err(EC_OSPF_SR_NODE_CREATE,
-                        "SR (%s): Abort! can't create SR node in hash table",
-                        __func__);
-               return;
-       }
-
        /* Initialize TLV browsing */
        length = lsa->size - OSPF_LSA_HEADER_SIZE;
        for (tlvh = TLV_HDR_TOP(lsah); length > 0 && tlvh;
@@ -1814,15 +1798,6 @@ void ospf_sr_ext_prefix_lsa_update(struct ospf_lsa *lsa)
        srn = (struct sr_node *)hash_get(OspfSR.neighbors,
                                         (void *)&(lsah->adv_router),
                                         (void *)sr_node_new);
-
-       /* Sanity check */
-       if (srn == NULL) {
-               flog_err(EC_OSPF_SR_NODE_CREATE,
-                        "SR (%s): Abort! can't create SR node in hash table",
-                        __func__);
-               return;
-       }
-
        /* Initialize TLV browsing */
        length = lsa->size - OSPF_LSA_HEADER_SIZE;
        for (tlvh = TLV_HDR_TOP(lsah); length > 0 && tlvh;
index fb0bd7258593a8d4856b4ed0bd7c4cc635546846..cbff4832a4ead2cf55b9ff1b2e2ad0b96c79c95c 100644 (file)
@@ -1041,8 +1041,9 @@ static int pbr_nht_individual_nexthop_vrf_handle(struct hash_bucket *b,
                                                     nhrcvi.nhrc);
                                        nhrcvi.nhrc->nexthop.vrf_id =
                                                pbr_vrf_id(pnhi->pbr_vrf);
-                                       hash_get(pbr_nhrc_hash, nhrcvi.nhrc,
-                                                hash_alloc_intern);
+                                       (void)hash_get(pbr_nhrc_hash,
+                                                      nhrcvi.nhrc,
+                                                      hash_alloc_intern);
                                        pbr_send_rnh(&nhrcvi.nhrc->nexthop, true);
                                }
                        } while (nhrcvi.nhrc);
@@ -1087,7 +1088,8 @@ static void pbr_nht_nexthop_vrf_handle(struct hash_bucket *b, void *data)
                if (pnhi.pnhc) {
                        pnhi.pnhc->nexthop.vrf_id = pbr_vrf_id(pbr_vrf);
 
-                       hash_get(pnhgc->nhh, pnhi.pnhc, hash_alloc_intern);
+                       (void)hash_get(pnhgc->nhh, pnhi.pnhc,
+                                      hash_alloc_intern);
                } else
                        pnhc->nexthop.vrf_id = pbr_vrf_id(pbr_vrf);
 
@@ -1141,11 +1143,11 @@ static void pbr_nht_nexthop_interface_handle(struct hash_bucket *b, void *data)
                if (nhrc) {
                        hash_release(pbr_nhrc_hash, nhrc);
                        nhrc->nexthop.ifindex = ifp->ifindex;
-                       hash_get(pbr_nhrc_hash, nhrc, hash_alloc_intern);
+                       (void)hash_get(pbr_nhrc_hash, nhrc, hash_alloc_intern);
                }
                pnhi.pnhc->nexthop.ifindex = ifp->ifindex;
 
-               hash_get(pnhgc->nhh, pnhi.pnhc, hash_alloc_intern);
+               (void)hash_get(pnhgc->nhh, pnhi.pnhc, hash_alloc_intern);
 
                pbr_map_check_interface_nh_group_change(pnhgc->name, ifp,
                                                        old_ifindex);
@@ -1290,7 +1292,7 @@ uint32_t pbr_nht_reserve_next_table_id(struct pbr_nexthop_group_cache *nhgc)
        nhgc->table_id = pbr_next_unallocated_table_id;
 
        /* Mark table id as allocated in id-indexed hash */
-       hash_get(pbr_nhg_allocated_id_hash, nhgc, hash_alloc_intern);
+       (void)hash_get(pbr_nhg_allocated_id_hash, nhgc, hash_alloc_intern);
 
        /* Pre-compute the next unallocated table id */
        pbr_nht_update_next_unallocated_table_id();
index eec763a4ff3404269ca51a92fffa564b34160633..c1242e1509b47e4bc7780cb2aba8d6c7da576090 100644 (file)
@@ -151,7 +151,7 @@ int pim_find_or_track_nexthop(struct pim_instance *pim, struct prefix *addr,
        }
 
        if (up != NULL)
-               hash_get(pnc->upstream_hash, up, hash_alloc_intern);
+               (void)hash_get(pnc->upstream_hash, up, hash_alloc_intern);
 
        if (CHECK_FLAG(pnc->flags, PIM_NEXTHOP_VALID)) {
                if (out_pnc)
index 097da113ab0e712f4e3c4b84e5d85810b5c66403..3c3129b9ce9555a66784445b2153fb740ea2dbca 100644 (file)
@@ -160,7 +160,7 @@ static void test_state_add_route(struct test_state *test,
        }
 
        rn->info = (void *)0xdeadbeef;
-       hash_get(test->log, hash_entry, log_alloc);
+       (void)hash_get(test->log, hash_entry, log_alloc);
 };
 
 static void test_state_del_route(struct test_state *test,
index dae1e4894e6b342564f8fee3ed84f8ce28013a3b..3081c0d955bc6701ad33635d45d621810b2cb5e1 100644 (file)
@@ -654,7 +654,7 @@ struct vrrp_vrouter *vrrp_vrouter_create(struct interface *ifp, uint8_t vrid,
 
        vrrp_set_advertisement_interval(vr, vd.advertisement_interval);
 
-       hash_get(vrrp_vrouters_hash, vr, hash_alloc_intern);
+       (void)hash_get(vrrp_vrouters_hash, vr, hash_alloc_intern);
 
        return vr;
 }
index d223a21edaca508b9b1c1fd7b63acaafa8fe5aab..121092a55bd0cd701cf034e1f82778e0d01cd430 100644 (file)
@@ -1022,7 +1022,6 @@ struct zebra_evpn *zebra_evpn_add(vni_t vni)
        memset(&tmp_zevpn, 0, sizeof(struct zebra_evpn));
        tmp_zevpn.vni = vni;
        zevpn = hash_get(zvrf->evpn_table, &tmp_zevpn, zebra_evpn_alloc);
-       assert(zevpn);
 
        zebra_evpn_es_evi_init(zevpn);
 
index 128d23396984a5113585dbbd8753fcdc5ac48362..5a1f5af5d706e182ca3aa7d2706dd561c2aeff68 100644 (file)
@@ -1105,7 +1105,6 @@ struct zebra_mac *zebra_evpn_mac_add(struct zebra_evpn *zevpn,
        memset(&tmp_mac, 0, sizeof(struct zebra_mac));
        memcpy(&tmp_mac.macaddr, macaddr, ETH_ALEN);
        mac = hash_get(zevpn->mac_table, &tmp_mac, zebra_evpn_mac_alloc);
-       assert(mac);
 
        mac->zevpn = zevpn;
        mac->dad_mac_auto_recovery_timer = NULL;
index b1e48374c4d345c0b71cbd18b812566cefcddcfa..7728f5012312c2492b55f56fc71211e2771c049c 100644 (file)
@@ -570,10 +570,7 @@ zebra_evpn_acc_vl_new(vlanid_t vid, struct interface *br_if)
        acc_bd->mbr_zifs = list_new();
 
        /* Add to hash */
-       if (!hash_get(zmh_info->evpn_vlan_table, acc_bd, hash_alloc_intern)) {
-               XFREE(MTYPE_ZACC_BD, acc_bd);
-               return NULL;
-       }
+       (void)hash_get(zmh_info->evpn_vlan_table, acc_bd, hash_alloc_intern);
 
        /* check if an svi exists for the vlan */
        if (br_if) {
@@ -1091,10 +1088,7 @@ static uint32_t zebra_evpn_nhid_alloc(struct zebra_evpn_es *es)
                nh_id = id | EVPN_NHG_ID_TYPE_BIT;
                /* Add to NHG hash */
                es->nhg_id = nh_id;
-               if (!hash_get(zmh_info->nhg_table, es, hash_alloc_intern)) {
-                       bf_release_index(zmh_info->nh_id_bitmap, id);
-                       return 0;
-               }
+               (void)hash_get(zmh_info->nhg_table, es, hash_alloc_intern);
        } else {
                nh_id = id | EVPN_NH_ID_TYPE_BIT;
        }
@@ -1361,10 +1355,7 @@ static struct zebra_evpn_l2_nh *zebra_evpn_l2_nh_alloc(struct in_addr vtep_ip)
 
        nh = XCALLOC(MTYPE_L2_NH, sizeof(*nh));
        nh->vtep_ip = vtep_ip;
-       if (!hash_get(zmh_info->nh_ip_table, nh, hash_alloc_intern)) {
-               XFREE(MTYPE_L2_NH, nh);
-               return NULL;
-       }
+       (void)hash_get(zmh_info->nh_ip_table, nh, hash_alloc_intern);
 
        nh->nh_id = zebra_evpn_nhid_alloc(NULL);
        if (!nh->nh_id) {
index ed224151ba2f6067676d0041ed39e9d8fb2e37b1..734a53c571b8dfa5bfbaf106d874807ec31b5959 100644 (file)
@@ -553,7 +553,6 @@ static struct zebra_neigh *zebra_evpn_neigh_add(struct zebra_evpn *zevpn,
        memset(&tmp_n, 0, sizeof(struct zebra_neigh));
        memcpy(&tmp_n.ip, ip, sizeof(struct ipaddr));
        n = hash_get(zevpn->neigh_table, &tmp_n, zebra_evpn_neigh_alloc);
-       assert(n);
 
        n->state = ZEBRA_NEIGH_INACTIVE;
        n->zevpn = zevpn;
index 6766c752ad7625313c07ce2c0f1e141df6caf93c..7c57dfac6ad30dbb214cafdcae60b2e78b375322 100644 (file)
@@ -1596,12 +1596,9 @@ static int zfpm_trigger_rmac_update(struct zebra_mac *rmac,
                        UNSET_FLAG(fpm_mac->fpm_flags, ZEBRA_MAC_UPDATE_FPM);
                        return 0;
                }
-       } else {
+       } else
                fpm_mac = hash_get(zfpm_g->fpm_mac_info_table, &key,
                                   zfpm_mac_info_alloc);
-               if (!fpm_mac)
-                       return 0;
-       }
 
        fpm_mac->r_vtep_ip.s_addr = rmac->fwd_info.r_vtep_ip.s_addr;
        fpm_mac->zebra_flags = rmac->flags;
index 924a43049be80c4040491b9803687e2a7e682e34..de7b6a177d99170ff87854d5b7f166f9f2c91f28 100644 (file)
@@ -188,8 +188,6 @@ static int lsp_install(struct zebra_vrf *zvrf, mpls_label_t label,
        /* Locate or allocate LSP entry. */
        tmp_ile.in_label = label;
        lsp = hash_get(lsp_table, &tmp_ile, lsp_alloc);
-       if (!lsp)
-               return -1;
 
        /* For each active nexthop, create NHLFE. Note that we deliberately skip
         * recursive nexthops right now, because intermediate hops won't
@@ -2920,8 +2918,6 @@ int mpls_zapi_labels_process(bool add_p, struct zebra_vrf *zvrf,
                /* Find or create LSP object */
                tmp_ile.in_label = zl->local_label;
                lsp = hash_get(lsp_table, &tmp_ile, lsp_alloc);
-               if (!lsp)
-                       return -1;
        }
 
        /* Prep for route/FEC update if requested */
@@ -3199,8 +3195,6 @@ int mpls_lsp_install(struct zebra_vrf *zvrf, enum lsp_types_t type,
        /* Find or create LSP object */
        tmp_ile.in_label = in_label;
        lsp = hash_get(lsp_table, &tmp_ile, lsp_alloc);
-       if (!lsp)
-               return -1;
 
        nhlfe = lsp_add_nhlfe(lsp, type, num_out_labels, out_labels, gtype,
                              gate, ifindex, false /*backup*/);
@@ -3562,8 +3556,6 @@ int zebra_mpls_static_lsp_add(struct zebra_vrf *zvrf, mpls_label_t in_label,
        /* Find or create LSP. */
        tmp_ile.in_label = in_label;
        lsp = hash_get(slsp_table, &tmp_ile, lsp_alloc);
-       if (!lsp)
-               return -1;
 
        nhlfe = nhlfe_find(&lsp->nhlfe_list, ZEBRA_LSP_STATIC, gtype, gate,
                           ifindex);
index 069d35c6a365828db7c2cd67ec24041d09fac697..cf09902d5253cd1ecb3740e5b9642be98d0956b3 100644 (file)
@@ -329,7 +329,7 @@ static int zebra_nhg_insert_id(struct nhg_hash_entry *nhe)
                return -1;
        }
 
-       hash_get(zrouter.nhgs_id, nhe, hash_alloc_intern);
+       (void)hash_get(zrouter.nhgs_id, nhe, hash_alloc_intern);
 
        return 0;
 }
index fc7eb8c87aa259b994958c9800115eadf2540ca9..d883336f004e4f4dd1dee6c66bd25d0b00f8bf0b 100644 (file)
@@ -1189,8 +1189,6 @@ static struct zebra_mac *zl3vni_rmac_add(struct zebra_l3vni *zl3vni,
        memset(&tmp_rmac, 0, sizeof(struct zebra_mac));
        memcpy(&tmp_rmac.macaddr, rmac, ETH_ALEN);
        zrmac = hash_get(zl3vni->rmac_table, &tmp_rmac, zl3vni_rmac_alloc);
-       assert(zrmac);
-
        zrmac->nh_list = list_new();
        zrmac->nh_list->cmp = (int (*)(void *, void *))l3vni_rmac_nh_list_cmp;
        zrmac->nh_list->del = (void (*)(void *))l3vni_rmac_nh_free;
@@ -1466,7 +1464,6 @@ static struct zebra_neigh *zl3vni_nh_add(struct zebra_l3vni *zl3vni,
        memset(&tmp_n, 0, sizeof(struct zebra_neigh));
        memcpy(&tmp_n.ip, ip, sizeof(struct ipaddr));
        n = hash_get(zl3vni->nh_table, &tmp_n, zl3vni_nh_alloc);
-       assert(n);
 
        RB_INIT(host_rb_tree_entry, &n->host_rb);
 
@@ -1696,7 +1693,6 @@ static struct zebra_l3vni *zl3vni_add(vni_t vni, vrf_id_t vrf_id)
        tmp_zl3vni.vni = vni;
 
        zl3vni = hash_get(zrouter.l3vni_table, &tmp_zl3vni, zl3vni_alloc);
-       assert(zl3vni);
 
        zl3vni->vrf_id = vrf_id;
        zl3vni->svi_if = NULL;
@@ -6039,11 +6035,6 @@ static struct zebra_vxlan_sg *zebra_vxlan_sg_add(struct zebra_vrf *zvrf,
        }
 
        vxlan_sg = zebra_vxlan_sg_new(zvrf, sg);
-       if (!vxlan_sg) {
-               if (parent)
-                       zebra_vxlan_sg_do_deref(zvrf, sip, sg->grp);
-               return vxlan_sg;
-       }
 
        zebra_vxlan_sg_send(zvrf, sg, vxlan_sg->sg_str,
                        ZEBRA_VXLAN_SG_ADD);