qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
From: Peter Maydell <peter.maydell@linaro.org>
To: Eric Blake <eblake@redhat.com>
Cc: "Laurent Vivier" <lvivier@redhat.com>,
	"Thomas Huth" <thuth@redhat.com>,
	"Alistair Francis" <alistair@alistair23.me>,
	"Eduardo Habkost" <ehabkost@redhat.com>,
	"Cornelia Huck" <cohuck@redhat.com>,
	"QEMU Developers" <qemu-devel@nongnu.org>,
	"Halil Pasic" <pasic@linux.ibm.com>,
	"Christian Borntraeger" <borntraeger@de.ibm.com>,
	"Cédric Le Goater" <clg@kaod.org>,
	"Edgar E. Iglesias" <edgar.iglesias@gmail.com>,
	"Paolo Bonzini" <pbonzini@redhat.com>,
	"Philippe Mathieu-Daudé" <philmd@redhat.com>,
	"David Gibson" <david@gibson.dropbear.id.au>
Subject: Re: [PATCH v2] Avoid address_space_rw() with a constant is_write argument
Date: Tue, 18 Feb 2020 13:41:59 +0000	[thread overview]
Message-ID: <CAFEAcA-AaDxCbLu3S2LO49Lt18s_aLmDC9XZ-kHtac33sdv_jg@mail.gmail.com> (raw)
In-Reply-To: <08b37e02-49b5-1485-aa71-83ead1adf407@redhat.com>

On Tue, 18 Feb 2020 at 13:33, Eric Blake <eblake@redhat.com> wrote:
>
> On 2/18/20 6:56 AM, Philippe Mathieu-Daudé wrote:
>
> >> +++ b/scripts/coccinelle/as_rw_const.cocci
> >> @@ -0,0 +1,30 @@
> >> +// Avoid uses of address_space_rw() with a constant is_write argument.
> >> +// Usage:
> >> +//  spatch --sp-file as-rw-const.spatch --dir . --in-place
> >
> > Nitpick, script is now scripts/coccinelle/as_rw_const.cocci.
> >
> > Reviewed-by: Philippe Mathieu-Daudé <philmd@redhat.com>
> >
> >> +
> >> +@@
> >> +expression E1, E2, E3, E4, E5;
> >> +symbol false;
> >> +@@
> >> +
> >> +- address_space_rw(E1, E2, E3, E4, E5, false)
> >> ++ address_space_read(E1, E2, E3, E4, E5)
> >> +@@
> >> +expression E1, E2, E3, E4, E5;
> >> +@@
> >> +
> >> +- address_space_rw(E1, E2, E3, E4, E5, 0)
> >> ++ address_space_read(E1, E2, E3, E4, E5)
>
> This feels a bit redundant.  Doesn't coccinelle have enough smarts about
> isomorphisms (such as 0 == false, 1 == true) that it could get by with
> one @@ hunk instead of 2, if we come up with the right way to represent
> any isomorphism to a constant value?  But admittedly, I don't know what
> that representation would actually be, and your verbose patch works even
> if it is not the most concise possible.  So don't let my remarks hold
> this patch up.

My experience with Coccinelle has generally been that trying
to make semantic patches smaller and less redundant is futile
and a massive timesink. In this case as far as I can tell
Coccinelle has no idea at all about the existence of the 'bool'
type and that 'true' and 'false' are equivalent to 1 and 0.
Thus the 'symbol' declaration, otherwise it thinks that 'false'
is a random semantic identifier and doesn't look for a literal
match of it.

thanks
-- PMM


  reply	other threads:[~2020-02-18 13:42 UTC|newest]

Thread overview: 14+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-02-18 11:24 [PATCH v2] Avoid address_space_rw() with a constant is_write argument Peter Maydell
2020-02-16 17:24 ` Edgar E. Iglesias
2020-02-18 12:56 ` Philippe Mathieu-Daudé
2020-02-18 13:33   ` Eric Blake
2020-02-18 13:41     ` Peter Maydell [this message]
2020-02-20  9:27   ` Philippe Mathieu-Daudé
2020-02-18 13:13 ` Laurent Vivier
2020-02-18 13:20   ` Peter Maydell
2020-02-20 11:28   ` Paolo Bonzini
2020-02-18 13:30 ` Cédric Le Goater
2020-02-18 14:54 ` Christian Borntraeger
2020-02-18 17:34 ` Cornelia Huck
2020-02-18 22:30 ` Alistair Francis
2020-02-18 23:00 ` David Gibson

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=CAFEAcA-AaDxCbLu3S2LO49Lt18s_aLmDC9XZ-kHtac33sdv_jg@mail.gmail.com \
    --to=peter.maydell@linaro.org \
    --cc=alistair@alistair23.me \
    --cc=borntraeger@de.ibm.com \
    --cc=clg@kaod.org \
    --cc=cohuck@redhat.com \
    --cc=david@gibson.dropbear.id.au \
    --cc=eblake@redhat.com \
    --cc=edgar.iglesias@gmail.com \
    --cc=ehabkost@redhat.com \
    --cc=lvivier@redhat.com \
    --cc=pasic@linux.ibm.com \
    --cc=pbonzini@redhat.com \
    --cc=philmd@redhat.com \
    --cc=qemu-devel@nongnu.org \
    --cc=thuth@redhat.com \
    /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;
as well as URLs for NNTP newsgroup(s).