]> git.puffer.fish Git - mirror/frr.git/commitdiff
tools: Add coccinelle script for hash compare functions NULL values 9171/head
authorDonatas Abraitis <donatas.abraitis@gmail.com>
Tue, 13 Jul 2021 05:48:11 +0000 (08:48 +0300)
committermergify-bot <noreply@mergify.io>
Sat, 24 Jul 2021 16:12:52 +0000 (16:12 +0000)
Signed-off-by: Donatas Abraitis <donatas.abraitis@gmail.com>
(cherry picked from commit 107df351c6f95ef15a045cde85697c0ee3b222b2)

tools/coccinelle/hash_compare_null_values_check.cocci [new file with mode: 0644]

diff --git a/tools/coccinelle/hash_compare_null_values_check.cocci b/tools/coccinelle/hash_compare_null_values_check.cocci
new file mode 100644 (file)
index 0000000..38649a2
--- /dev/null
@@ -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 ...;
+...
+}