Skip to content

Commit

Permalink
Merge pull request #9171 from FRRouting/mergify/bp/stable/8.0/pr-9039
Browse files Browse the repository at this point in the history
bgpd: Do not check for NULL values for vni_hash_cmp() (backport #9039)
  • Loading branch information
mwinter-osr committed Jul 24, 2021
2 parents b5a02be + 10b6a06 commit a6128c9
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 5 deletions.
6 changes: 1 addition & 5 deletions bgpd/bgp_evpn.c
Expand Up @@ -88,11 +88,7 @@ static bool vni_hash_cmp(const void *p1, const void *p2)
const struct bgpevpn *vpn1 = p1;
const struct bgpevpn *vpn2 = p2;

if (!vpn1 && !vpn2)
return true;
if (!vpn1 || !vpn2)
return false;
return (vpn1->vni == vpn2->vni);
return vpn1->vni == vpn2->vni;
}

int vni_list_cmp(void *p1, void *p2)
Expand Down
20 changes: 20 additions & 0 deletions tools/coccinelle/hash_compare_null_values_check.cocci
@@ -0,0 +1,20 @@
// There is no need to test for null values in the hash compare
// function as that we are guaranteed to send in data in
// the hash compare functions.
@@
identifier fn =~ "_hash_cmp";
type T;
identifier p1;
identifier p2;
@@

?static
T fn(...)
{
...
- if (p1 == NULL && p2 == NULL)
- return ...;
- if (p1 == NULL || p2 == NULL)
- return ...;
...
}

0 comments on commit a6128c9

Please sign in to comment.