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

TOMOYO Linux Cross Reference
Linux/scripts/coccinelle/iterators/itnull.cocci

Version: ~ [ linux-6.11.5 ] ~ [ linux-6.10.14 ] ~ [ linux-6.9.12 ] ~ [ linux-6.8.12 ] ~ [ linux-6.7.12 ] ~ [ linux-6.6.58 ] ~ [ linux-6.5.13 ] ~ [ linux-6.4.16 ] ~ [ linux-6.3.13 ] ~ [ linux-6.2.16 ] ~ [ linux-6.1.114 ] ~ [ linux-6.0.19 ] ~ [ linux-5.19.17 ] ~ [ linux-5.18.19 ] ~ [ linux-5.17.15 ] ~ [ linux-5.16.20 ] ~ [ linux-5.15.169 ] ~ [ linux-5.14.21 ] ~ [ linux-5.13.19 ] ~ [ linux-5.12.19 ] ~ [ linux-5.11.22 ] ~ [ linux-5.10.228 ] ~ [ linux-5.9.16 ] ~ [ linux-5.8.18 ] ~ [ linux-5.7.19 ] ~ [ linux-5.6.19 ] ~ [ linux-5.5.19 ] ~ [ linux-5.4.284 ] ~ [ linux-5.3.18 ] ~ [ linux-5.2.21 ] ~ [ linux-5.1.21 ] ~ [ linux-5.0.21 ] ~ [ linux-4.20.17 ] ~ [ linux-4.19.322 ] ~ [ 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.9 ] ~ [ policy-sample ] ~
Architecture: ~ [ i386 ] ~ [ alpha ] ~ [ m68k ] ~ [ mips ] ~ [ ppc ] ~ [ sparc ] ~ [ sparc64 ] ~

  1 // SPDX-License-Identifier: GPL-2.0-only
  2 /// Many iterators have the property that the first argument is always bound
  3 /// to a real list element, never NULL.
  4 //# False positives arise for some iterators that do not have this property,
  5 //# or in cases when the loop cursor is reassigned.  The latter should only
  6 //# happen when the matched code is on the way to a loop exit (break, goto,
  7 //# or return).
  8 ///
  9 // Confidence: Moderate
 10 // Copyright: (C) 2010-2012 Nicolas Palix.
 11 // Copyright: (C) 2010-2012 Julia Lawall, INRIA/LIP6.
 12 // Copyright: (C) 2010-2012 Gilles Muller, INRIA/LiP6.
 13 // URL: https://coccinelle.gitlabpages.inria.fr/website
 14 // Comments:
 15 // Options: --no-includes --include-headers
 16 
 17 virtual patch
 18 virtual context
 19 virtual org
 20 virtual report
 21 
 22 @depends on patch@
 23 iterator I;
 24 expression x,E,E1,E2;
 25 statement S,S1,S2;
 26 @@
 27 
 28 I(x,...) { <...
 29 (
 30 - if (x == NULL && ...) S
 31 |
 32 - if (x != NULL || ...)
 33   S
 34 |
 35 - (x == NULL) ||
 36   E
 37 |
 38 - (x != NULL) &&
 39   E
 40 |
 41 - (x == NULL && ...) ? E1 :
 42   E2
 43 |
 44 - (x != NULL || ...) ?
 45   E1
 46 - : E2
 47 |
 48 - if (x == NULL && ...) S1 else
 49   S2
 50 |
 51 - if (x != NULL || ...)
 52   S1
 53 - else S2
 54 |
 55 + BAD(
 56   x == NULL
 57 + )
 58 |
 59 + BAD(
 60   x != NULL
 61 + )
 62 )
 63   ...> }
 64 
 65 @r depends on !patch exists@
 66 iterator I;
 67 expression x,E;
 68 position p1,p2;
 69 @@
 70 
 71 *I@p1(x,...)
 72 { ... when != x = E
 73 (
 74 *  x@p2 == NULL
 75 |
 76 *  x@p2 != NULL
 77 )
 78   ... when any
 79 }
 80 
 81 @script:python depends on org@
 82 p1 << r.p1;
 83 p2 << r.p2;
 84 @@
 85 
 86 cocci.print_main("iterator-bound variable",p1)
 87 cocci.print_secs("useless NULL test",p2)
 88 
 89 @script:python depends on report@
 90 p1 << r.p1;
 91 p2 << r.p2;
 92 @@
 93 
 94 msg = "ERROR: iterator variable bound on line %s cannot be NULL" % (p1[0].line)
 95 coccilib.report.print_report(p2[0], msg)

~ [ 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