From: Julia Lawall <julia.lawall@lip6.fr>
To: Javier Martinez Canillas <javier@dowhile0.org>
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
Subject: Re: [PATCH 1/1] scripts/coccinelle: use BIT() macro if possible
Date: Sun, 27 Apr 2014 12:29:14 +0200 (CEST) [thread overview]
Message-ID: <alpine.DEB.2.02.1404271228100.2006@localhost6.localdomain6> (raw)
In-Reply-To: <1398558586-28931-1-git-send-email-javier@dowhile0.org>
On Sun, 27 Apr 2014, Javier Martinez Canillas wrote:
> 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>
Here you could say:
@usesbit@
@@
BIT(...)
> +@depends on hasbitops@
and then here it would be
@depends on hasbitops && usesbit@
julia
> +expression E;
> +@@
> +
> +- 1 << E
> ++ BIT(E)
> +
> +@depends on hasbitops@
> +expression E;
> +@@
> +
> +- BIT((E))
> ++ BIT(E)
> --
> 1.9.1
>
>
next prev parent reply other threads:[~2014-04-27 10:29 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
2014-04-27 0:29 [PATCH 1/1] scripts/coccinelle: use BIT() macro if possible Javier Martinez Canillas
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 [this message]
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=alpine.DEB.2.02.1404271228100.2006@localhost6.localdomain6 \
--to=julia.lawall@lip6.fr \
--cc=Gilles.Muller@lip6.fr \
--cc=cocci@systeme.lip6.fr \
--cc=javier@dowhile0.org \
--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