[<prev] [next>] [thread-next>] [day] [month] [year] [list]
Message-Id: <1398558586-28931-1-git-send-email-javier@dowhile0.org>
Date: Sun, 27 Apr 2014 02:29:46 +0200
From: Javier Martinez Canillas <javier@...hile0.org>
To: Julia Lawall <Julia.Lawall@...6.fr>
Cc: Gilles Muller <Gilles.Muller@...6.fr>,
Nicolas Palix <nicolas.palix@...g.fr>,
Michal Marek <mmarek@...e.cz>, cocci@...teme.lip6.fr,
linux-kernel@...r.kernel.org,
Javier Martinez Canillas <javier@...hile0.org>
Subject: [PATCH 1/1] scripts/coccinelle: use BIT() macro if possible
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@...hile0.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
+
+@...bitops@
+@@
+
+#include <linux/bitops.h>
+
+@...ends on hasbitops@
+expression E;
+@@
+
+- 1 << E
++ BIT(E)
+
+@...ends on hasbitops@
+expression E;
+@@
+
+- BIT((E))
++ BIT(E)
--
1.9.1
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@...r.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/
Powered by blists - more mailing lists