mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Nicholas Mc Guire <der.herr@hofr.at>
To: Julia Lawall <Julia.Lawall@lip6.fr>
Cc: Gilles Muller <Gilles.Muller@lip6.fr>,
	Nicolas Palix <nicolas.palix@imag.fr>,
	Michal Marek <mmarek@suse.cz>,
	Andreas Platschek <platschek@ict.tuwien.ac.at>,
	cocci@systeme.lip6.fr, linux-kernel@vger.kernel.org,
	Nicholas Mc Guire <der.herr@hofr.at>
Subject: [PATCH 1/3 RFC] Coccinelle: drop unecessary duplicated init_compltion calls
Date: Fri,  2 Jan 2015 04:59:10 -0500	[thread overview]
Message-ID: <1420192752-4889-2-git-send-email-der.herr@hofr.at> (raw)
In-Reply-To: <1420192752-4889-1-git-send-email-der.herr@hofr.at>

Reviewed-by: Andreas Platschek <platschek@ict.tuwien.ac.at>
Signed-off-by: Nicholas Mc Guire <der.herr@hofr.at>
---
 .../coccinelle/api/duplicate_init_completion.cocci |   59 ++++++++++++++++++++
 1 file changed, 59 insertions(+)
 create mode 100644 scripts/coccinelle/api/duplicate_init_completion.cocci

diff --git a/scripts/coccinelle/api/duplicate_init_completion.cocci b/scripts/coccinelle/api/duplicate_init_completion.cocci
new file mode 100644
index 0000000..889715a
--- /dev/null
+++ b/scripts/coccinelle/api/duplicate_init_completion.cocci
@@ -0,0 +1,59 @@
+/* drop unnecessary duplicated init_compltion calls
+ * in patch mode one must be check that it is actually
+ * the second init_completion that can be removed and not
+ * the first.
+ * Options: --no-includes --include-headers
+ */
+virtual context
+virtual patch
+virtual org
+virtual report
+
+/* mark first call to init_completion */
+@c@
+expression cmp;
+position p;
+@@
+
+ init_completion@p(cmp)
+
+/* flag duplicate initializations */
+@d depends on patch && !(context || org || report)@
+expression E,c.cmp;
+identifier f;
+position c.p,p1;
+@@
+
+  init_completion@p(cmp)
+  ... when != E = cmp
+      when != E = &cmp
+      when != f(..., cmp, ...)
+      when != f(..., &cmp, ...)
+- init_completion@p1(cmp);
+
+@dp depends on !patch && (context || org || report)@
+identifier f;
+expression E,c.cmp;
+position c.p,p1;
+@@
+
+  init_completion@p(cmp)
+  ... when != E = cmp
+      when != E = &cmp
+      when != f(..., cmp, ...)
+      when != f(..., &cmp, ...)
+  init_completion@p1(cmp);
+
+@script:python depends on org@
+p << dp.p1;
+@@
+
+msg="WARNING: possible duplicate init_completion"
+coccilib.org.print_todo(p[0], msg)
+
+@script:python depends on report@
+p << dp.p1;
+@@
+
+msg="WARNING: possible duplicate init_completion"
+coccilib.report.print_report(p[0], msg)
-- 
1.7.10.4


  reply	other threads:[~2015-01-02 10:04 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-01-02  9:59 [PATCH 0/3 RFC] Coccinelle: completion API checking Nicholas Mc Guire
2015-01-02  9:59 ` Nicholas Mc Guire [this message]
2015-01-02  9:59 ` [PATCH 2/3 RFC] Coccinelle: check for incorrect DECLARE_COMPLETION use Nicholas Mc Guire
2015-01-02  9:59 ` [PATCH 3/3 RFC] Coccinelle: incorrect use of multiple init_completion Nicholas Mc Guire
2015-01-02 11:46 ` [PATCH 0/3 RFC] Coccinelle: completion API checking Julia Lawall

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1420192752-4889-2-git-send-email-der.herr@hofr.at \
    --to=der.herr@hofr.at \
    --cc=Gilles.Muller@lip6.fr \
    --cc=Julia.Lawall@lip6.fr \
    --cc=cocci@systeme.lip6.fr \
    --cc=linux-kernel@vger.kernel.org \
    --cc=mmarek@suse.cz \
    --cc=nicolas.palix@imag.fr \
    --cc=platschek@ict.tuwien.ac.at \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®