From: Donatas Abraitis Date: Tue, 13 Jul 2021 05:48:11 +0000 (+0300) Subject: tools: Add coccinelle script for hash compare functions NULL values X-Git-Tag: base_8.1~327^2 X-Git-Url: https://git.puffer.fish/?a=commitdiff_plain;h=refs%2Fpull%2F9039%2Fhead;p=mirror%2Ffrr.git tools: Add coccinelle script for hash compare functions NULL values Signed-off-by: Donatas Abraitis --- diff --git a/tools/coccinelle/hash_compare_null_values_check.cocci b/tools/coccinelle/hash_compare_null_values_check.cocci new file mode 100644 index 0000000000..38649a2282 --- /dev/null +++ b/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 ...; +... +}