1 // SPDX-License-Identifier: GPL-2.0-only
2 /// Compare pointer-typed values to NULL rather than 0
4 //# This makes an effort to choose between !x and x == NULL. !x is used
5 //# if it has previously been used with the function used to initialize x.
6 //# This relies on type information. More type information can be obtained
7 //# using the option -all_includes and the option -I to specify an
11 // Copyright: (C) 2012 Julia Lawall, INRIA/LIP6.
12 // Copyright: (C) 2012 Gilles Muller, INRIA/LiP6.
13 // URL: http://coccinelle.lip6.fr/
24 let negtable = Hashtbl.create 101
50 @t1 depends on !patch@
70 @script:python depends on org@
74 coccilib.org.print_todo(p[0], "WARNING comparing pointer to 0")
76 @script:python depends on report@
80 coccilib.report.print_report(p[0], "WARNING comparing pointer to 0")
82 // Tests of returned values
93 @script:ocaml depends on s@
97 try let _ = Hashtbl.find negtable f in ()
98 with Not_found -> Hashtbl.add negtable f ()
100 @ r disable is_zero,isnt_zero exists @
117 try let _ = Hashtbl.find negtable f in ()
118 with Not_found -> include_match false
120 // This rule may lead to inconsistent path problems, if E is defined in two
122 @ depends on patch disable is_zero,isnt_zero @
146 @t2 depends on !patch disable is_zero,isnt_zero @
168 @script:python depends on org@
172 coccilib.org.print_todo(p[0], "WARNING comparing pointer to 0, suggest !E")
174 @script:python depends on org@
178 coccilib.org.print_todo(p[0], "WARNING comparing pointer to 0")
180 @script:python depends on report@
184 coccilib.report.print_report(p[0], "WARNING comparing pointer to 0, suggest !E")
186 @script:python depends on report@
190 coccilib.report.print_report(p[0], "WARNING comparing pointer to 0")
192 @ depends on patch disable is_zero,isnt_zero @
214 @ t3 depends on !patch disable is_zero,isnt_zero @
229 @script:python depends on org@
233 coccilib.org.print_todo(p[0], "WARNING comparing pointer to 0")
235 @script:python depends on report@
239 coccilib.report.print_report(p[0], "WARNING comparing pointer to 0")