diff options
author | anlan_cs <vic.lan@pica8.com> | 2022-04-21 08:37:12 +0200 |
---|---|---|
committer | anlan_cs <vic.lan@pica8.com> | 2022-05-02 18:41:48 +0200 |
commit | 8e3aae66cec563cee0add26482f279c4aae67cb1 (patch) | |
tree | 8edfdd068eeabbd142cfc7c47a56fcec542110fc /zebra/zebra_evpn_mac.c | |
parent | bgpd: fix memory leak for evpn (diff) | |
download | frr-8e3aae66cec563cee0add26482f279c4aae67cb1.tar.xz frr-8e3aae66cec563cee0add26482f279c4aae67cb1.zip |
*: remove the checking returned value for hash_get()
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>
Diffstat (limited to 'zebra/zebra_evpn_mac.c')
-rw-r--r-- | zebra/zebra_evpn_mac.c | 1 |
1 files changed, 0 insertions, 1 deletions
diff --git a/zebra/zebra_evpn_mac.c b/zebra/zebra_evpn_mac.c index 128d23396..5a1f5af5d 100644 --- a/zebra/zebra_evpn_mac.c +++ b/zebra/zebra_evpn_mac.c @@ -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; |