1 /// Compare pointer-typed values to NULL rather than 0
3 //# This makes an effort to choose between !x and x == NULL. !x is used
4 //# if it has previously been used with the function used to initialize x.
5 //# This relies on type information. More type information can be obtained
6 //# using the option -all_includes and the option -I to specify an
10 // Copyright: (C) 2012 Julia Lawall, INRIA/LIP6. GPLv2.
11 // Copyright: (C) 2012 Gilles Muller, INRIA/LiP6. GPLv2.
12 // URL: http://coccinelle.lip6.fr/
16 // SPDX-License-Identifier: GPL-2.0
26 let negtable = Hashtbl.create 101
52 @t1 depends on !patch@
72 @script:python depends on org@
76 coccilib.org.print_todo(p[0], "WARNING comparing pointer to 0")
78 @script:python depends on report@
82 coccilib.report.print_report(p[0], "WARNING comparing pointer to 0")
84 // Tests of returned values
95 @script:ocaml depends on s@
99 try let _ = Hashtbl.find negtable f in ()
100 with Not_found -> Hashtbl.add negtable f ()
102 @ r disable is_zero,isnt_zero exists @
119 try let _ = Hashtbl.find negtable f in ()
120 with Not_found -> include_match false
122 // This rule may lead to inconsistent path problems, if E is defined in two
124 @ depends on patch disable is_zero,isnt_zero @
148 @t2 depends on !patch disable is_zero,isnt_zero @
170 @script:python depends on org@
174 coccilib.org.print_todo(p[0], "WARNING comparing pointer to 0, suggest !E")
176 @script:python depends on org@
180 coccilib.org.print_todo(p[0], "WARNING comparing pointer to 0")
182 @script:python depends on report@
186 coccilib.report.print_report(p[0], "WARNING comparing pointer to 0, suggest !E")
188 @script:python depends on report@
192 coccilib.report.print_report(p[0], "WARNING comparing pointer to 0")
194 @ depends on patch disable is_zero,isnt_zero @
216 @ t3 depends on !patch disable is_zero,isnt_zero @
231 @script:python depends on org@
235 coccilib.org.print_todo(p[0], "WARNING comparing pointer to 0")
237 @script:python depends on report@
241 coccilib.report.print_report(p[0], "WARNING comparing pointer to 0")