github.com/imran-kn/cilium-fork@v1.6.9/contrib/coccinelle/null.cocci (about)

     1  // spatch --sp-file null.cocci lib/*.h *.c *.h
     2  //
     3  // This script finds undefined behavior in BPF C code which LLVM
     4  // does not warn about but optimizes instead. See GH PR #4881.
     5  
     6  @r exists@
     7  expression E;
     8  identifier f;
     9  position p;
    10  @@
    11  
    12  if (E == NULL)
    13  {
    14    ...
    15    E@p->f
    16    ...
    17  }
    18  
    19  @script:python@
    20  E << r.E;
    21  p << r.p;
    22  @@
    23  
    24  print "* file: %s deref of NULL value %s on line %s" % (p[0].file,E,p[0].line)