~ [ source navigation ] ~ [ diff markup ] ~ [ identifier search ] ~

TOMOYO Linux Cross Reference
Linux/scripts/coccinelle/null/badzero.cocci

Version: ~ [ linux-6.12-rc7 ] ~ [ linux-6.11.7 ] ~ [ linux-6.10.14 ] ~ [ linux-6.9.12 ] ~ [ linux-6.8.12 ] ~ [ linux-6.7.12 ] ~ [ linux-6.6.60 ] ~ [ linux-6.5.13 ] ~ [ linux-6.4.16 ] ~ [ linux-6.3.13 ] ~ [ linux-6.2.16 ] ~ [ linux-6.1.116 ] ~ [ linux-6.0.19 ] ~ [ linux-5.19.17 ] ~ [ linux-5.18.19 ] ~ [ linux-5.17.15 ] ~ [ linux-5.16.20 ] ~ [ linux-5.15.171 ] ~ [ linux-5.14.21 ] ~ [ linux-5.13.19 ] ~ [ linux-5.12.19 ] ~ [ linux-5.11.22 ] ~ [ linux-5.10.229 ] ~ [ linux-5.9.16 ] ~ [ linux-5.8.18 ] ~ [ linux-5.7.19 ] ~ [ linux-5.6.19 ] ~ [ linux-5.5.19 ] ~ [ linux-5.4.285 ] ~ [ linux-5.3.18 ] ~ [ linux-5.2.21 ] ~ [ linux-5.1.21 ] ~ [ linux-5.0.21 ] ~ [ linux-4.20.17 ] ~ [ linux-4.19.323 ] ~ [ linux-4.18.20 ] ~ [ linux-4.17.19 ] ~ [ linux-4.16.18 ] ~ [ linux-4.15.18 ] ~ [ linux-4.14.336 ] ~ [ linux-4.13.16 ] ~ [ linux-4.12.14 ] ~ [ linux-4.11.12 ] ~ [ linux-4.10.17 ] ~ [ linux-4.9.337 ] ~ [ linux-4.4.302 ] ~ [ linux-3.10.108 ] ~ [ linux-2.6.32.71 ] ~ [ linux-2.6.0 ] ~ [ linux-2.4.37.11 ] ~ [ unix-v6-master ] ~ [ ccs-tools-1.8.12 ] ~ [ policy-sample ] ~
Architecture: ~ [ i386 ] ~ [ alpha ] ~ [ m68k ] ~ [ mips ] ~ [ ppc ] ~ [ sparc ] ~ [ sparc64 ] ~

Diff markup

Differences between /scripts/coccinelle/null/badzero.cocci (Architecture sparc64) and /scripts/coccinelle/null/badzero.cocci (Architecture m68k)


  1 // SPDX-License-Identifier: GPL-2.0-only            1 // SPDX-License-Identifier: GPL-2.0-only
  2 /// Compare pointer-typed values to NULL rathe      2 /// Compare pointer-typed values to NULL rather than 0
  3 ///                                                 3 ///
  4 //# This makes an effort to choose between !x       4 //# This makes an effort to choose between !x and x == NULL.  !x is used
  5 //# if it has previously been used with the fu      5 //# if it has previously been used with the function used to initialize x.
  6 //# This relies on type information.  More typ      6 //# This relies on type information.  More type information can be obtained
  7 //# using the option -all_includes and the opt      7 //# using the option -all_includes and the option -I to specify an
  8 //# include path.                                   8 //# include path.
  9 //                                                  9 //
 10 // Confidence: High                                10 // Confidence: High
 11 // Copyright: (C) 2012 Julia Lawall, INRIA/LIP     11 // Copyright: (C) 2012 Julia Lawall, INRIA/LIP6.
 12 // Copyright: (C) 2012 Gilles Muller, INRIA/Li     12 // Copyright: (C) 2012 Gilles Muller, INRIA/LiP6.
 13 // URL: https://coccinelle.gitlabpages.inria.f     13 // URL: https://coccinelle.gitlabpages.inria.fr/website
 14 // Requires: 1.0.0                                 14 // Requires: 1.0.0
 15 // Options:                                        15 // Options:
 16                                                    16 
 17 virtual patch                                      17 virtual patch
 18 virtual context                                    18 virtual context
 19 virtual org                                        19 virtual org
 20 virtual report                                     20 virtual report
 21                                                    21 
 22 @initialize:ocaml@                                 22 @initialize:ocaml@
 23 @@                                                 23 @@
 24 let negtable = Hashtbl.create 101                  24 let negtable = Hashtbl.create 101
 25                                                    25 
 26 @depends on patch@                                 26 @depends on patch@
 27 expression *E;                                     27 expression *E;
 28 identifier f;                                      28 identifier f;
 29 @@                                                 29 @@
 30                                                    30 
 31 (                                                  31 (
 32   (E = f(...)) ==                                  32   (E = f(...)) ==
 33 - 0                                                33 - 0
 34 + NULL                                             34 + NULL
 35 |                                                  35 |
 36   (E = f(...)) !=                                  36   (E = f(...)) !=
 37 - 0                                                37 - 0
 38 + NULL                                             38 + NULL
 39 |                                                  39 |
 40 - 0                                                40 - 0
 41 + NULL                                             41 + NULL
 42   == (E = f(...))                                  42   == (E = f(...))
 43 |                                                  43 |
 44 - 0                                                44 - 0
 45 + NULL                                             45 + NULL
 46   != (E = f(...))                                  46   != (E = f(...))
 47 )                                                  47 )
 48                                                    48 
 49                                                    49 
 50 @t1 depends on !patch@                             50 @t1 depends on !patch@
 51 expression *E;                                     51 expression *E;
 52 identifier f;                                      52 identifier f;
 53 position p;                                        53 position p;
 54 @@                                                 54 @@
 55                                                    55 
 56 (                                                  56 (
 57   (E = f(...)) ==                                  57   (E = f(...)) ==
 58 * 0@p                                              58 * 0@p
 59 |                                                  59 |
 60   (E = f(...)) !=                                  60   (E = f(...)) !=
 61 * 0@p                                              61 * 0@p
 62 |                                                  62 |
 63 * 0@p                                              63 * 0@p
 64   == (E = f(...))                                  64   == (E = f(...))
 65 |                                                  65 |
 66 * 0@p                                              66 * 0@p
 67   != (E = f(...))                                  67   != (E = f(...))
 68 )                                                  68 )
 69                                                    69 
 70 @script:python depends on org@                     70 @script:python depends on org@
 71 p << t1.p;                                         71 p << t1.p;
 72 @@                                                 72 @@
 73                                                    73 
 74 coccilib.org.print_todo(p[0], "WARNING compari     74 coccilib.org.print_todo(p[0], "WARNING comparing pointer to 0")
 75                                                    75 
 76 @script:python depends on report@                  76 @script:python depends on report@
 77 p << t1.p;                                         77 p << t1.p;
 78 @@                                                 78 @@
 79                                                    79 
 80 coccilib.report.print_report(p[0], "WARNING co     80 coccilib.report.print_report(p[0], "WARNING comparing pointer to 0")
 81                                                    81 
 82 // Tests of returned values                        82 // Tests of returned values
 83                                                    83 
 84 @s@                                                84 @s@
 85 identifier f;                                      85 identifier f;
 86 expression E,E1;                                   86 expression E,E1;
 87 @@                                                 87 @@
 88                                                    88 
 89  E = f(...)                                        89  E = f(...)
 90  ... when != E = E1                                90  ... when != E = E1
 91  !E                                                91  !E
 92                                                    92 
 93 @script:ocaml depends on s@                        93 @script:ocaml depends on s@
 94 f << s.f;                                          94 f << s.f;
 95 @@                                                 95 @@
 96                                                    96 
 97 try let _ = Hashtbl.find negtable f in ()          97 try let _ = Hashtbl.find negtable f in ()
 98 with Not_found -> Hashtbl.add negtable f ()        98 with Not_found -> Hashtbl.add negtable f ()
 99                                                    99 
100 @ r disable is_zero,isnt_zero exists @            100 @ r disable is_zero,isnt_zero exists @
101 expression *E;                                    101 expression *E;
102 identifier f;                                     102 identifier f;
103 @@                                                103 @@
104                                                   104 
105 E = f(...)                                        105 E = f(...)
106 ...                                               106 ...
107 (E == 0                                           107 (E == 0
108 |E != 0                                           108 |E != 0
109 |0 == E                                           109 |0 == E
110 |0 != E                                           110 |0 != E
111 )                                                 111 )
112                                                   112 
113 @script:ocaml@                                    113 @script:ocaml@
114 f << r.f;                                         114 f << r.f;
115 @@                                                115 @@
116                                                   116 
117 try let _ = Hashtbl.find negtable f in ()         117 try let _ = Hashtbl.find negtable f in ()
118 with Not_found -> include_match false             118 with Not_found -> include_match false
119                                                   119 
120 // This rule may lead to inconsistent path pro    120 // This rule may lead to inconsistent path problems, if E is defined in two
121 // places                                         121 // places
122 @ depends on patch disable is_zero,isnt_zero @    122 @ depends on patch disable is_zero,isnt_zero @
123 expression *E;                                    123 expression *E;
124 expression E1;                                    124 expression E1;
125 identifier r.f;                                   125 identifier r.f;
126 @@                                                126 @@
127                                                   127 
128 E = f(...)                                        128 E = f(...)
129 <...                                              129 <...
130 (                                                 130 (
131 - E == 0                                          131 - E == 0
132 + !E                                              132 + !E
133 |                                                 133 |
134 - E != 0                                          134 - E != 0
135 + E                                               135 + E
136 |                                                 136 |
137 - 0 == E                                          137 - 0 == E
138 + !E                                              138 + !E
139 |                                                 139 |
140 - 0 != E                                          140 - 0 != E
141 + E                                               141 + E
142 )                                                 142 )
143 ...>                                              143 ...>
144 ?E = E1                                           144 ?E = E1
145                                                   145 
146 @t2 depends on !patch disable is_zero,isnt_zer    146 @t2 depends on !patch disable is_zero,isnt_zero @
147 expression *E;                                    147 expression *E;
148 expression E1;                                    148 expression E1;
149 identifier r.f;                                   149 identifier r.f;
150 position p1;                                      150 position p1;
151 position p2;                                      151 position p2;
152 @@                                                152 @@
153                                                   153 
154 E = f(...)                                        154 E = f(...)
155 <...                                              155 <...
156 (                                                 156 (
157 * E == 0@p1                                       157 * E == 0@p1
158 |                                                 158 |
159 * E != 0@p2                                       159 * E != 0@p2
160 |                                                 160 |
161 * 0@p1 == E                                       161 * 0@p1 == E
162 |                                                 162 |
163 * 0@p1 != E                                       163 * 0@p1 != E
164 )                                                 164 )
165 ...>                                              165 ...>
166 ?E = E1                                           166 ?E = E1
167                                                   167 
168 @script:python depends on org@                    168 @script:python depends on org@
169 p << t2.p1;                                       169 p << t2.p1;
170 @@                                                170 @@
171                                                   171 
172 coccilib.org.print_todo(p[0], "WARNING compari    172 coccilib.org.print_todo(p[0], "WARNING comparing pointer to 0, suggest !E")
173                                                   173 
174 @script:python depends on org@                    174 @script:python depends on org@
175 p << t2.p2;                                       175 p << t2.p2;
176 @@                                                176 @@
177                                                   177 
178 coccilib.org.print_todo(p[0], "WARNING compari    178 coccilib.org.print_todo(p[0], "WARNING comparing pointer to 0")
179                                                   179 
180 @script:python depends on report@                 180 @script:python depends on report@
181 p << t2.p1;                                       181 p << t2.p1;
182 @@                                                182 @@
183                                                   183 
184 coccilib.report.print_report(p[0], "WARNING co    184 coccilib.report.print_report(p[0], "WARNING comparing pointer to 0, suggest !E")
185                                                   185 
186 @script:python depends on report@                 186 @script:python depends on report@
187 p << t2.p2;                                       187 p << t2.p2;
188 @@                                                188 @@
189                                                   189 
190 coccilib.report.print_report(p[0], "WARNING co    190 coccilib.report.print_report(p[0], "WARNING comparing pointer to 0")
191                                                   191 
192 @ depends on patch disable is_zero,isnt_zero @    192 @ depends on patch disable is_zero,isnt_zero @
193 expression *E;                                    193 expression *E;
194 @@                                                194 @@
195                                                   195 
196 (                                                 196 (
197   E ==                                            197   E ==
198 - 0                                               198 - 0
199 + NULL                                            199 + NULL
200 |                                                 200 |
201   E !=                                            201   E !=
202 - 0                                               202 - 0
203 + NULL                                            203 + NULL
204 |                                                 204 |
205 - 0                                               205 - 0
206 + NULL                                            206 + NULL
207   == E                                            207   == E
208 |                                                 208 |
209 - 0                                               209 - 0
210 + NULL                                            210 + NULL
211   != E                                            211   != E
212 )                                                 212 )
213                                                   213 
214 @ t3 depends on !patch disable is_zero,isnt_ze    214 @ t3 depends on !patch disable is_zero,isnt_zero @
215 expression *E;                                    215 expression *E;
216 position p;                                       216 position p;
217 @@                                                217 @@
218                                                   218 
219 (                                                 219 (
220 * E == 0@p                                        220 * E == 0@p
221 |                                                 221 |
222 * E != 0@p                                        222 * E != 0@p
223 |                                                 223 |
224 * 0@p == E                                        224 * 0@p == E
225 |                                                 225 |
226 * 0@p != E                                        226 * 0@p != E
227 )                                                 227 )
228                                                   228 
229 @script:python depends on org@                    229 @script:python depends on org@
230 p << t3.p;                                        230 p << t3.p;
231 @@                                                231 @@
232                                                   232 
233 coccilib.org.print_todo(p[0], "WARNING compari    233 coccilib.org.print_todo(p[0], "WARNING comparing pointer to 0")
234                                                   234 
235 @script:python depends on report@                 235 @script:python depends on report@
236 p << t3.p;                                        236 p << t3.p;
237 @@                                                237 @@
238                                                   238 
239 coccilib.report.print_report(p[0], "WARNING co    239 coccilib.report.print_report(p[0], "WARNING comparing pointer to 0")
                                                      

~ [ source navigation ] ~ [ diff markup ] ~ [ identifier search ] ~

kernel.org | git.kernel.org | LWN.net | Project Home | SVN repository | Mail admin

Linux® is a registered trademark of Linus Torvalds in the United States and other countries.
TOMOYO® is a registered trademark of NTT DATA CORPORATION.

sflogo.php