From: "Marc-André Lureau" <marcandre.lureau@redhat.com>
To: Peter Maydell <peter.maydell@linaro.org>
Cc: QEMU Developers <qemu-devel@nongnu.org>,
Paolo Bonzini <pbonzini@redhat.com>
Subject: Re: [Qemu-devel] [PATCH 2/5] coccinelle: use DIV_ROUND_UP
Date: Wed, 7 Jun 2017 05:27:07 -0400 (EDT) [thread overview]
Message-ID: <2020123289.30850450.1496827627184.JavaMail.zimbra@redhat.com> (raw)
In-Reply-To: <CAFEAcA8FpdJEt2M5jHQjRE5OcHQ=XQoL=q3O=5ptBnc2UfN7Xw@mail.gmail.com>
Hi
----- Original Message -----
> On 7 June 2017 at 08:46, Marc-André Lureau <marcandre.lureau@redhat.com>
> wrote:
> > The coccinelle/round.cocci script doesn't catch hard coded values.
> >
> > I used the following script over qemu code base:
> >
> > (
> > - ((e1) + 3) / (4)
> > + DIV_ROUND_UP(e1,4)
> > |
> > - ((e1) + (3)) / (4)
> > + DIV_ROUND_UP(e1,4)
>
> Why do we need both of these? Is it just "coccinelle is weird" ? :-)
I am total newbie to coccinnelle-land, but I think this one is useless duplication
>
> > |
> > - ((e1) + 7) / (8)
> > + DIV_ROUND_UP(e1,8)
> > |
> > - ((e1) + (7)) / (8)
> > + DIV_ROUND_UP(e1,8)
> > |
> > - ((e1) + 15) / (16)
> > + DIV_ROUND_UP(e1,16)
> > |
> > - ((e1) + (15)) / (16)
> > + DIV_ROUND_UP(e1,16)
> > |
> > - ((e1) + 31) / (32)
> > + DIV_ROUND_UP(e1,32)
> > |
> > - ((e1) + (31)) / (32)
> > + DIV_ROUND_UP(e1,32)
> > )
>
> > - next_op = op_pointer + ((oplen + 7) / 8);
> > + next_op = op_pointer + (DIV_ROUND_UP(oplen, 8));
>
> I think there's a coccinelle trick for making it drop
> now-unnecessary brackets in substitutions like this, but I forget
> what it is. Maybe it's as simple as having substitutions for
>
> > - (((e1) + 7) / (8))
> > + DIV_ROUND_UP(e1,8)
>
> as well?
I think you need a second rule:
@@
expression e1;
expression e2;
@@
-(DIV_ROUND_UP(e1,e2))
+DIV_ROUND_UP(e1,e2)
I will fix it in second version.
next prev parent reply other threads:[~2017-06-07 9:27 UTC|newest]
Thread overview: 19+ messages / expand[flat|nested] mbox.gz Atom feed top
2017-06-07 7:46 [Qemu-devel] [PATCH 0/5] Code cleanups with Coccinelle Marc-André Lureau
2017-06-07 7:46 ` [Qemu-devel] [PATCH 1/5] coccinelle: replace code with ROUND_UP macro Marc-André Lureau
2017-06-07 10:01 ` Juan Quintela
2017-06-07 21:48 ` Eric Blake
2017-06-07 7:46 ` [Qemu-devel] [PATCH 2/5] coccinelle: use DIV_ROUND_UP Marc-André Lureau
2017-06-07 9:13 ` Peter Maydell
2017-06-07 9:27 ` Marc-André Lureau [this message]
2017-06-07 21:50 ` Eric Blake
2017-06-08 7:37 ` Marc-André Lureau
2017-06-07 7:46 ` [Qemu-devel] [PATCH 3/5] arch: introduce ELF_NOTE_SIZE macro Marc-André Lureau
2017-06-07 7:46 ` [Qemu-devel] [PATCH 4/5] Replace g_malloc()+memcpy() with g_memdup() Marc-André Lureau
2017-06-07 10:02 ` Juan Quintela
2017-06-07 7:46 ` [Qemu-devel] [PATCH 5/5] coccinelle: prefer glib g_new/g_renew macros Marc-André Lureau
2017-06-07 21:58 ` Eric Blake
2017-06-08 8:23 ` Marc-André Lureau
2017-06-08 8:50 ` Markus Armbruster
2017-06-08 20:15 ` Eric Blake
2017-06-08 20:11 ` Eric Blake
2017-06-07 17:21 ` [Qemu-devel] [PATCH 0/5] Code cleanups with Coccinelle no-reply
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=2020123289.30850450.1496827627184.JavaMail.zimbra@redhat.com \
--to=marcandre.lureau@redhat.com \
--cc=pbonzini@redhat.com \
--cc=peter.maydell@linaro.org \
--cc=qemu-devel@nongnu.org \
/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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.