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>

Elia Pinto committed Apr 30, 2022 at 04:13 UTC 7a618493facb79639231f797e492fab51fac2ba4
1 file changed +30
contrib/coccinelle/equals-null.cocci new
+30
@@ -0,0 +1,30 @@
1 +/* SPDX-License-Identifier: LGPL-2.1-or-later */
2 +@@
3 +expression e;
4 +statement s;
5 +@@
6 +if (
7 +(
8 +!e
9 +|
10 +- e == NULL
11 ++ !e
12 +)
13 + )
14 + {...}
15 +else s
16 +
17 +@@
18 +expression e;
19 +statement s;
20 +@@
21 +if (
22 +(
23 +e
24 +|
25 +- e != NULL
26 ++ e
27 +)
28 + )
29 + {...}
30 +else s