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/
22 let negtable = Hashtbl.create 101
48 @t1 depends on !patch@
68 @script:python depends on org@
72 coccilib.org.print_todo(p[0], "WARNING comparing pointer to 0")
74 @script:python depends on report@
78 coccilib.report.print_report(p[0], "WARNING comparing pointer to 0")
80 // Tests of returned values
91 @script:ocaml depends on s@
95 try let _ = Hashtbl.find negtable f in ()
96 with Not_found -> Hashtbl.add negtable f ()
98 @ r disable is_zero,isnt_zero exists @
115 try let _ = Hashtbl.find negtable f in ()
116 with Not_found -> include_match false
118 // This rule may lead to inconsistent path problems, if E is defined in two
120 @ depends on patch disable is_zero,isnt_zero @
144 @t2 depends on !patch disable is_zero,isnt_zero @
166 @script:python depends on org@
170 coccilib.org.print_todo(p[0], "WARNING comparing pointer to 0, suggest !E")
172 @script:python depends on org@
176 coccilib.org.print_todo(p[0], "WARNING comparing pointer to 0")
178 @script:python depends on report@
182 coccilib.report.print_report(p[0], "WARNING comparing pointer to 0, suggest !E")
184 @script:python depends on report@
188 coccilib.report.print_report(p[0], "WARNING comparing pointer to 0")
190 @ depends on patch disable is_zero,isnt_zero @
212 @ t3 depends on !patch disable is_zero,isnt_zero @
227 @script:python depends on org@
231 coccilib.org.print_todo(p[0], "WARNING comparing pointer to 0")
233 @script:python depends on report@
237 coccilib.report.print_report(p[0], "WARNING comparing pointer to 0")