mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Javier Martinez Canillas <javier@dowhile0.org>
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>,
	cocci@systeme.lip6.fr, linux-kernel@vger.kernel.org,
	Javier Martinez Canillas <javier@dowhile0.org>
Subject: [PATCH 1/1] scripts/coccinelle: use BIT() macro if possible
Date: Sun, 27 Apr 2014 02:29:46 +0200	[thread overview]
Message-ID: <1398558586-28931-1-git-send-email-javier@dowhile0.org> (raw)

Using the BIT() macro instead of manually shifting bits
makes the code less error prone and also more readable.

Signed-off-by: Javier Martinez Canillas <javier@dowhile0.org>
---

An example of the patches that can be obtained with this spatch:

http://www.mail-archive.com/linux-gpio@vger.kernel.org/msg02722.html

 scripts/coccinelle/api/bit.cocci | 25 +++++++++++++++++++++++++
 1 file changed, 25 insertions(+)
 create mode 100644 scripts/coccinelle/api/bit.cocci

diff --git a/scripts/coccinelle/api/bit.cocci b/scripts/coccinelle/api/bit.cocci
new file mode 100644
index 0000000..a5df73a
--- /dev/null
+++ b/scripts/coccinelle/api/bit.cocci
@@ -0,0 +1,25 @@
+// Use the macro BIT() macro if possible
+//
+// Confidence: High
+// Copyright (C) 2014 Javier Martinez Canillas.  GPLv2.
+// URL: http://coccinelle.lip6.fr/
+// Options: --include-headers
+
+@hasbitops@
+@@
+
+#include <linux/bitops.h>
+
+@depends on hasbitops@
+expression E;
+@@
+
+- 1 << E
++ BIT(E)
+
+@depends on hasbitops@
+expression E;
+@@
+
+- BIT((E))
++ BIT(E)
-- 
1.9.1


             reply	other threads:[~2014-04-27  0:29 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2014-04-27  0:29 Javier Martinez Canillas [this message]
2014-04-27  5:14 ` [Cocci] " Wolfram Sang
2014-04-27  8:58   ` Javier Martinez Canillas
2014-04-27  9:36     ` Julia Lawall
2014-04-27 10:24       ` Javier Martinez Canillas
2014-04-27 10:29 ` Julia Lawall
2014-04-27 10:41   ` Javier Martinez Canillas

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=1398558586-28931-1-git-send-email-javier@dowhile0.org \
    --to=javier@dowhile0.org \
    --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 \
    /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®