Skip to content

Commit

Permalink
tools: Add coccinelle script for hash compare functions NULL values
Browse files Browse the repository at this point in the history
Signed-off-by: Donatas Abraitis <donatas.abraitis@gmail.com>
  • Loading branch information
ton31337 committed Jul 13, 2021
1 parent ce40c62 commit 107df35
Showing 1 changed file with 20 additions and 0 deletions.
20 changes: 20 additions & 0 deletions tools/coccinelle/hash_compare_null_values_check.cocci
Original file line number Diff line number Diff line change
@@ -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 107df35

Please sign in to comment.