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: frr-8.0.1~58^2 X-Git-Url: https://git.puffer.fish/?a=commitdiff_plain;h=10b6a06a2395c1fc8af2ba52ba17462765d75de7;p=mirror%2Ffrr.git tools: Add coccinelle script for hash compare functions NULL values Signed-off-by: Donatas Abraitis (cherry picked from commit 107df351c6f95ef15a045cde85697c0ee3b222b2) --- 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 ...; +... +}