Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > linux.kernel > #1635985 > unrolled thread

[PATCH linux-next RESEND] scripts/coccinelle/misc: Warn about NULL check on kmap()

Started byFabian Frederick <fabf@skynet.be>
First post2017-05-04 21:20 +0200
Last post2017-05-04 21:20 +0200
Articles 1 — 1 participant

Back to article view | Back to linux.kernel


Contents

  [PATCH linux-next RESEND] scripts/coccinelle/misc: Warn about NULL check on kmap() Fabian Frederick <fabf@skynet.be> - 2017-05-04 21:20 +0200

#1635985 — [PATCH linux-next RESEND] scripts/coccinelle/misc: Warn about NULL check on kmap()

FromFabian Frederick <fabf@skynet.be>
Date2017-05-04 21:20 +0200
Subject[PATCH linux-next RESEND] scripts/coccinelle/misc: Warn about NULL check on kmap()
Message-ID<tDus9-7Mu-17@gated-at.bofh.it>
This script removes NULL check on kmap() and all process involved
(OOM message ...)

Thanks to Jan Kara for explanations.

Acked-by: Julia Lawall <julia.lawall@lip6.fr>
Signed-off-by: Fabian Frederick <fabf@skynet.be>
---
 scripts/coccinelle/misc/kmap.cocci | 43 ++++++++++++++++++++++++++++++++++++++
 1 file changed, 43 insertions(+)
 create mode 100644 scripts/coccinelle/misc/kmap.cocci

diff --git a/scripts/coccinelle/misc/kmap.cocci b/scripts/coccinelle/misc/kmap.cocci
new file mode 100644
index 0000000..9ae4a6e
--- /dev/null
+++ b/scripts/coccinelle/misc/kmap.cocci
@@ -0,0 +1,43 @@
+/// kmap never fails; remove NULL test case.
+///
+// Copyright: (C) 2017 Fabian Frederick.  GPLv2.
+// Comments: -
+// Options: --no-includes --include-headers
+
+virtual patch
+virtual org
+virtual report
+virtual context
+
+@r2 depends on patch@
+expression E;
+position p;
+@@
+
+E = kmap(...);
+- if (!E) {
+- ...
+- }
+
+@r depends on context || report || org @
+expression E;
+position p;
+@@
+
+* E = kmap(...);
+* if (@p!E) {
+* ...
+* }
+
+@script:python depends on org@
+p << r.p;
+@@
+
+cocci.print_main("kmap() can't fail, NULL check and special process is not needed", p)
+
+@script:python depends on report@
+p << r.p;
+@@
+
+msg = "WARNING: NULL check on kmap() result is not needed."
+coccilib.report.print_report(p[0], msg)
-- 
2.9.3

[toc] | [standalone]


Back to top | Article view | linux.kernel


csiph-web