summaryrefslogtreecommitdiffstats
path: root/tools/coccinelle/zlog_no_newline.cocci
blob: 20cf9d2c78a68f1662de20ef9099cce3eac608a3 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
// zlog_* should not have \n or \r at the end usually.
// spatch --sp-file tools/coccinelle/zlog_no_newline.cocci --macro-file tools/cocci.h ./ 2>/dev/null

@r@
expression fmt;
identifier func =~ "zlog_";
position p;
@@
(
  func(fmt)@p
|
  func(fmt, ...)@p
)

@script:python@
fmt << r.fmt;
p << r.p;
@@
if "\\n" in str(fmt) or "\\r" in str(fmt):
    print("Newline in logging function detected %s:%s:%s:%s" % (p[0].file, p[0].line, p[0].column, fmt))