Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.kernel.org/pub/scm/git/git.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorElia Pinto <gitter.spiros@gmail.com>2022-04-30 07:13:44 +0300
committerJunio C Hamano <gitster@pobox.com>2022-05-02 19:47:55 +0300
commit7a618493facb79639231f797e492fab51fac2ba4 (patch)
treea0ac00b8127b53f4bfde35abf82118afefd8762d /contrib/coccinelle
parent2f0dde7852b7866bb044926f73334ff3fc30654b (diff)
contrib/coccinnelle: add equals-null.cocci
Add a coccinelle semantic patch necessary to reinforce the git coding style guideline: "Do not explicitly compute an integral value with constant 0 or '\ 0', or a pointer value with constant NULL." Signed-off-by: Elia Pinto <gitter.spiros@gmail.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>
Diffstat (limited to 'contrib/coccinelle')
-rw-r--r--contrib/coccinelle/equals-null.cocci30
1 files changed, 30 insertions, 0 deletions
diff --git a/contrib/coccinelle/equals-null.cocci b/contrib/coccinelle/equals-null.cocci
new file mode 100644
index 0000000000..92c7054013
--- /dev/null
+++ b/contrib/coccinelle/equals-null.cocci
@@ -0,0 +1,30 @@
+/* SPDX-License-Identifier: LGPL-2.1-or-later */
+@@
+expression e;
+statement s;
+@@
+if (
+(
+!e
+|
+- e == NULL
++ !e
+)
+ )
+ {...}
+else s
+
+@@
+expression e;
+statement s;
+@@
+if (
+(
+e
+|
+- e != NULL
++ e
+)
+ )
+ {...}
+else s