summaryrefslogtreecommitdiffstats
path: root/tools/coccinelle
diff options
context:
space:
mode:
authorDonatas Abraitis <donatas.abraitis@gmail.com>2021-07-13 07:48:11 +0200
committerDonatas Abraitis <donatas.abraitis@gmail.com>2021-07-13 07:49:38 +0200
commit107df351c6f95ef15a045cde85697c0ee3b222b2 (patch)
tree78e2f5363addc5ad0ffa6625b52415d9360d0356 /tools/coccinelle
parentbgpd: Do not check for NULL values for vni_hash_cmp() (diff)
downloadfrr-107df351c6f95ef15a045cde85697c0ee3b222b2.tar.xz
frr-107df351c6f95ef15a045cde85697c0ee3b222b2.zip
tools: Add coccinelle script for hash compare functions NULL values
Signed-off-by: Donatas Abraitis <donatas.abraitis@gmail.com>
Diffstat (limited to 'tools/coccinelle')
-rw-r--r--tools/coccinelle/hash_compare_null_values_check.cocci20
1 files changed, 20 insertions, 0 deletions
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 000000000..38649a228
--- /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 ...;
+...
+}