From 8e3aae66cec563cee0add26482f279c4aae67cb1 Mon Sep 17 00:00:00 2001 From: anlan_cs Date: Thu, 21 Apr 2022 02:37:12 -0400 Subject: *: 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( == )` 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 ` != ` to judge it is a found node, then free . Refer to `aspath_intern()` of bgpd, there are many examples of this case in bgpd. Here, is the returned value from `hash_get()`, and is the data, which is to be put into hash table. Signed-off-by: anlan_cs --- nhrpd/reqid.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'nhrpd') diff --git a/nhrpd/reqid.c b/nhrpd/reqid.c index e56bbe3bf7..738e935ec2 100644 --- a/nhrpd/reqid.c +++ b/nhrpd/reqid.c @@ -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; } -- cgit v1.2.3