diff options
| author | Donald Sharp <donaldsharp72@gmail.com> | 2021-09-28 10:44:54 -0400 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2021-09-28 10:44:54 -0400 |
| commit | 8e55e2c87be191ae8b80880b1014f412805d0b3c (patch) | |
| tree | 832ef0306f916bfe1c64fbf59b4fa07574634ab1 | |
| parent | 5393318d811936643edb6b60f2249462ce739982 (diff) | |
| parent | 94ca37e0a9c9f7133e9b9ca3ec9d10303bca4e77 (diff) | |
Merge pull request #9677 from ton31337/fix/zlog_newline_not_needed
tools: Add coccinelle script to catch \n or \r at the end of zlog_*
| -rw-r--r-- | tools/coccinelle/zlog_no_newline.cocci | 20 |
1 files changed, 20 insertions, 0 deletions
diff --git a/tools/coccinelle/zlog_no_newline.cocci b/tools/coccinelle/zlog_no_newline.cocci new file mode 100644 index 0000000000..20cf9d2c78 --- /dev/null +++ b/tools/coccinelle/zlog_no_newline.cocci @@ -0,0 +1,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)) |
