xref: /btstack/tool/misc/fix_null_pointer_checks.cocci (revision c9921182ab4b1f83e3e5c671446dca5ffdf45b90)
1// Replace pointer null checks with boolen operations
2// inverse version of https://github.com/neomutt/coccinelle/blob/master/null-check.cocci
3// License: GPLv2
4
5@@
6type T;
7identifier I;
8statement S1, S2;
9expression E;
10@@
11
12T *I;
13
14(
15- if (!I)
16+ if (I == NULL)
17S1
18|
19- if (I)
20+ if (I != NULL)
21S1
22|
23- if (!I)
24+ if (I == NULL)
25S1 else S2
26|
27- if (I)
28+ if (I != NULL)
29S1 else S2
30|
31if (E) S1 else
32- if (!I)
33+ if (I == NULL)
34S1 else S2
35|
36if (E) S1 else
37- if (I)
38+ if (I != NULL)
39S1 else S2
40)
41