From: Markus Armbruster <armbru@redhat.com>
To: "Philippe Mathieu-Daudé" <f4bug@amsat.org>
Cc: "Peter Maydell" <peter.maydell@linaro.org>,
"David Hildenbrand" <david@redhat.com>,
"Jason Wang" <jasowang@redhat.com>,
"Mark Cave-Ayland" <mark.cave-ayland@ilande.co.uk>,
qemu-devel@nongnu.org, "Gerd Hoffmann" <kraxel@redhat.com>,
"Stefano Stabellini" <sstabellini@kernel.org>,
qemu-block@nongnu.org, "Paul Durrant" <paul@xen.org>,
"Halil Pasic" <pasic@linux.ibm.com>,
"Christian Borntraeger" <borntraeger@de.ibm.com>,
"Aleksandar Markovic" <aleksandar.qemu.devel@gmail.com>,
"Joel Stanley" <joel@jms.id.au>,
"Anthony Perard" <anthony.perard@citrix.com>,
xen-devel@lists.xenproject.org,
"Richard Henderson" <rth@twiddle.net>,
"Philippe Mathieu-Daudé" <philmd@redhat.com>,
"Eduardo Habkost" <ehabkost@redhat.com>,
"Corey Minyard" <minyard@acm.org>,
"Dr. David Alan Gilbert" <dgilbert@redhat.com>,
qemu-s390x@nongnu.org, qemu-arm@nongnu.org,
"Peter Chubb" <peter.chubb@nicta.com.au>,
"Cédric Le Goater" <clg@kaod.org>, "John Snow" <jsnow@redhat.com>,
"David Gibson" <david@gibson.dropbear.id.au>,
"Daniel P. Berrangé" <berrange@redhat.com>,
"Andrew Jeffery" <andrew@aj.id.au>,
"Cornelia Huck" <cohuck@redhat.com>,
"Laurent Vivier" <laurent@vivier.eu>,
qemu-ppc@nongnu.org, "Paolo Bonzini" <pbonzini@redhat.com>,
"Aurelien Jarno" <aurelien@aurel32.net>
Subject: Re: [PATCH-for-5.1 3/3] hw: Remove unnecessary DEVICE() cast
Date: Tue, 14 Apr 2020 13:31:59 +0200 [thread overview]
Message-ID: <87lfmytia8.fsf@dusky.pond.sub.org> (raw)
In-Reply-To: <20200412210954.32313-4-f4bug@amsat.org> ("Philippe Mathieu-Daudé"'s message of "Sun, 12 Apr 2020 23:09:54 +0200")
Philippe Mathieu-Daudé <f4bug@amsat.org> writes:
> The DEVICE() macro is defined as:
>
> #define DEVICE(obj) OBJECT_CHECK(DeviceState, (obj), TYPE_DEVICE)
>
> Remove unnecessary DEVICE() casts.
>
> Patch created mechanically using spatch with this script:
>
> @@
> typedef DeviceState;
> DeviceState *s;
> @@
> - DEVICE(s)
> + s
>
> Signed-off-by: Philippe Mathieu-Daudé <f4bug@amsat.org>
DEVICE(obj) expands to
OBJECT_CHECK(DeviceState, (obj), TYPE_DEVICE)
and then to
((DeviceState *)object_dynamic_cast_assert((Object *)(obj), (name),
__FILE__, __LINE__, __func__))
object_dynamic_cast_assert() asserts @obj can be safely converted to the
type named by @name, and returns @obj.
Your patch drops the assertion.
The assertion can only fail when @obj points to something other than its
stated type, i.e. when we're in undefined behavior country.
Preferably with this argument worked into your commit message:
Reviewed-by: Markus Armbruster <armbru@redhat.com>
There are many similar macros. Should they get the same treatment?
WARNING: multiple messages have this Message-ID (diff)
From: Markus Armbruster <armbru@redhat.com>
To: "Philippe Mathieu-Daudé" <f4bug@amsat.org>
Cc: "Peter Maydell" <peter.maydell@linaro.org>,
"David Hildenbrand" <david@redhat.com>,
"Jason Wang" <jasowang@redhat.com>,
"Mark Cave-Ayland" <mark.cave-ayland@ilande.co.uk>,
qemu-devel@nongnu.org, "Gerd Hoffmann" <kraxel@redhat.com>,
"Edgar E. Iglesias" <edgar.iglesias@gmail.com>,
"Stefano Stabellini" <sstabellini@kernel.org>,
qemu-block@nongnu.org, "Paul Durrant" <paul@xen.org>,
"Halil Pasic" <pasic@linux.ibm.com>,
"Christian Borntraeger" <borntraeger@de.ibm.com>,
"Aleksandar Markovic" <aleksandar.qemu.devel@gmail.com>,
"Joel Stanley" <joel@jms.id.au>,
"Anthony Perard" <anthony.perard@citrix.com>,
xen-devel@lists.xenproject.org,
"Richard Henderson" <rth@twiddle.net>,
"Philippe Mathieu-Daudé" <philmd@redhat.com>,
"Eduardo Habkost" <ehabkost@redhat.com>,
"Corey Minyard" <minyard@acm.org>,
"Dr. David Alan Gilbert" <dgilbert@redhat.com>,
qemu-s390x@nongnu.org, qemu-arm@nongnu.org,
"Peter Chubb" <peter.chubb@nicta.com.au>,
"Cédric Le Goater" <clg@kaod.org>, "John Snow" <jsnow@redhat.com>,
"David Gibson" <david@gibson.dropbear.id.au>,
"Daniel P. Berrangé" <berrange@redhat.com>,
"Andrew Jeffery" <andrew@aj.id.au>,
"Cornelia Huck" <cohuck@redhat.com>,
"Laurent Vivier" <laurent@vivier.eu>,
qemu-ppc@nongnu.org, "Paolo Bonzini" <pbonzini@redhat.com>,
"Aurelien Jarno" <aurelien@aurel32.net>
Subject: Re: [PATCH-for-5.1 3/3] hw: Remove unnecessary DEVICE() cast
Date: Tue, 14 Apr 2020 13:31:59 +0200 [thread overview]
Message-ID: <87lfmytia8.fsf@dusky.pond.sub.org> (raw)
In-Reply-To: <20200412210954.32313-4-f4bug@amsat.org> ("Philippe Mathieu-Daudé"'s message of "Sun, 12 Apr 2020 23:09:54 +0200")
Philippe Mathieu-Daudé <f4bug@amsat.org> writes:
> The DEVICE() macro is defined as:
>
> #define DEVICE(obj) OBJECT_CHECK(DeviceState, (obj), TYPE_DEVICE)
>
> Remove unnecessary DEVICE() casts.
>
> Patch created mechanically using spatch with this script:
>
> @@
> typedef DeviceState;
> DeviceState *s;
> @@
> - DEVICE(s)
> + s
>
> Signed-off-by: Philippe Mathieu-Daudé <f4bug@amsat.org>
DEVICE(obj) expands to
OBJECT_CHECK(DeviceState, (obj), TYPE_DEVICE)
and then to
((DeviceState *)object_dynamic_cast_assert((Object *)(obj), (name),
__FILE__, __LINE__, __func__))
object_dynamic_cast_assert() asserts @obj can be safely converted to the
type named by @name, and returns @obj.
Your patch drops the assertion.
The assertion can only fail when @obj points to something other than its
stated type, i.e. when we're in undefined behavior country.
Preferably with this argument worked into your commit message:
Reviewed-by: Markus Armbruster <armbru@redhat.com>
There are many similar macros. Should they get the same treatment?
next prev parent reply other threads:[~2020-04-14 11:32 UTC|newest]
Thread overview: 38+ messages / expand[flat|nested] mbox.gz Atom feed top
2020-04-12 21:09 [PATCH-for-5.1 0/3] various: Remove unnecessary casts Philippe Mathieu-Daudé
2020-04-12 21:09 ` Philippe Mathieu-Daudé
2020-04-12 21:09 ` [PATCH-for-5.1 1/3] target: Remove unnecessary CPU() cast Philippe Mathieu-Daudé
2020-04-12 21:09 ` Philippe Mathieu-Daudé
2020-04-12 21:09 ` Philippe Mathieu-Daudé
2020-04-14 2:06 ` David Gibson
2020-04-14 2:06 ` David Gibson
2020-04-14 2:06 ` David Gibson
2020-04-15 7:48 ` Cédric Le Goater
2020-04-15 7:48 ` Cédric Le Goater
2020-04-12 21:09 ` [PATCH-for-5.1 2/3] various: Remove unnecessary OBJECT() cast Philippe Mathieu-Daudé
2020-04-12 21:09 ` Philippe Mathieu-Daudé
2020-04-14 9:44 ` Cornelia Huck
2020-04-14 9:44 ` Cornelia Huck
2020-04-14 9:44 ` Cornelia Huck
2020-04-14 20:14 ` Corey Minyard
2020-04-14 20:14 ` Corey Minyard
2020-04-14 20:14 ` Corey Minyard
2020-04-17 19:45 ` John Snow
2020-04-17 19:45 ` John Snow
2020-04-17 19:45 ` John Snow
2020-04-12 21:09 ` [PATCH-for-5.1 3/3] hw: Remove unnecessary DEVICE() cast Philippe Mathieu-Daudé
2020-04-12 21:09 ` Philippe Mathieu-Daudé
2020-04-12 21:09 ` Philippe Mathieu-Daudé
2020-04-14 2:07 ` David Gibson
2020-04-14 2:07 ` David Gibson
2020-04-14 2:07 ` David Gibson
2020-04-14 7:14 ` Paul Durrant
2020-04-14 7:14 ` Paul Durrant
2020-04-14 11:31 ` Markus Armbruster [this message]
2020-04-14 11:31 ` Markus Armbruster
2020-04-15 7:47 ` Cédric Le Goater
2020-04-15 7:47 ` Cédric Le Goater
2020-04-17 19:45 ` John Snow
2020-04-17 19:45 ` John Snow
2020-04-17 19:45 ` John Snow
2020-04-14 21:40 ` [PATCH-for-5.1 0/3] various: Remove unnecessary casts Richard Henderson
2020-04-14 21:40 ` Richard Henderson
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=87lfmytia8.fsf@dusky.pond.sub.org \
--to=armbru@redhat.com \
--cc=aleksandar.qemu.devel@gmail.com \
--cc=andrew@aj.id.au \
--cc=anthony.perard@citrix.com \
--cc=aurelien@aurel32.net \
--cc=berrange@redhat.com \
--cc=borntraeger@de.ibm.com \
--cc=clg@kaod.org \
--cc=cohuck@redhat.com \
--cc=david@gibson.dropbear.id.au \
--cc=david@redhat.com \
--cc=dgilbert@redhat.com \
--cc=ehabkost@redhat.com \
--cc=f4bug@amsat.org \
--cc=jasowang@redhat.com \
--cc=joel@jms.id.au \
--cc=jsnow@redhat.com \
--cc=kraxel@redhat.com \
--cc=laurent@vivier.eu \
--cc=mark.cave-ayland@ilande.co.uk \
--cc=minyard@acm.org \
--cc=pasic@linux.ibm.com \
--cc=paul@xen.org \
--cc=pbonzini@redhat.com \
--cc=peter.chubb@nicta.com.au \
--cc=peter.maydell@linaro.org \
--cc=philmd@redhat.com \
--cc=qemu-arm@nongnu.org \
--cc=qemu-block@nongnu.org \
--cc=qemu-devel@nongnu.org \
--cc=qemu-ppc@nongnu.org \
--cc=qemu-s390x@nongnu.org \
--cc=rth@twiddle.net \
--cc=sstabellini@kernel.org \
--cc=xen-devel@lists.xenproject.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.