[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [PATCH v2 3/3] hw: Remove unnecessary DEVICE() cast
- To: Philippe Mathieu-Daudé <f4bug@xxxxxxxxx>
- From: Markus Armbruster <armbru@xxxxxxxxxx>
- Date: Fri, 08 May 2020 14:47:04 +0200
- Cc: Peter Maydell <peter.maydell@xxxxxxxxxx>, Paul Durrant <paul@xxxxxxx>, Jason Wang <jasowang@xxxxxxxxxx>, Mark Cave-Ayland <mark.cave-ayland@xxxxxxxxxxxx>, qemu-devel@xxxxxxxxxx, Gerd Hoffmann <kraxel@xxxxxxxxxx>, "Edgar E. Iglesias" <edgar.iglesias@xxxxxxxxx>, Stefano Stabellini <sstabellini@xxxxxxxxxx>, qemu-block@xxxxxxxxxx, David Hildenbrand <david@xxxxxxxxxx>, Halil Pasic <pasic@xxxxxxxxxxxxx>, Christian Borntraeger <borntraeger@xxxxxxxxxx>, Aleksandar Markovic <aleksandar.qemu.devel@xxxxxxxxx>, Joel Stanley <joel@xxxxxxxxx>, Anthony Perard <anthony.perard@xxxxxxxxxx>, xen-devel@xxxxxxxxxxxxxxxxxxxx, David Gibson <david@xxxxxxxxxxxxxxxxxxxxx>, Philippe Mathieu-Daudé <philmd@xxxxxxxxxx>, Eduardo Habkost <ehabkost@xxxxxxxxxx>, Corey Minyard <minyard@xxxxxxx>, Richard Henderson <richard.henderson@xxxxxxxxxx>, "Dr. David Alan Gilbert" <dgilbert@xxxxxxxxxx>, qemu-s390x@xxxxxxxxxx, qemu-arm@xxxxxxxxxx, Peter Chubb <peter.chubb@xxxxxxxxxxxx>, Cédric Le Goater <clg@xxxxxxxx>, John Snow <jsnow@xxxxxxxxxx>, Richard Henderson <rth@xxxxxxxxxxx>, "Daniel P. Berrangé" <berrange@xxxxxxxxxx>, Andrew Jeffery <andrew@xxxxxxxx>, Cornelia Huck <cohuck@xxxxxxxxxx>, Laurent Vivier <laurent@xxxxxxxxx>, qemu-ppc@xxxxxxxxxx, Paolo Bonzini <pbonzini@xxxxxxxxxx>, Aurelien Jarno <aurelien@xxxxxxxxxxx>
- Delivery-date: Fri, 08 May 2020 12:47:26 +0000
- List-id: Xen developer discussion <xen-devel.lists.xenproject.org>
Philippe Mathieu-Daudé <f4bug@xxxxxxxxx> writes:
> The DEVICE() macro is defined as:
>
> #define DEVICE(obj) OBJECT_CHECK(DeviceState, (obj), TYPE_DEVICE)
>
> which expands to:
>
> ((DeviceState *)object_dynamic_cast_assert((Object *)(obj), (name),
> __FILE__, __LINE__,
> __func__))
>
> This assertion can only fail when @obj points to something other
> than its stated type, i.e. when we're in undefined behavior country.
>
> Remove the unnecessary DEVICE() casts when we already know the
> pointer is of DeviceState type.
>
> Patch created mechanically using spatch with this script:
>
> @@
> typedef DeviceState;
> DeviceState *s;
> @@
> - DEVICE(s)
> + s
>
> Acked-by: David Gibson <david@xxxxxxxxxxxxxxxxxxxxx>
> Acked-by: Paul Durrant <paul@xxxxxxx>
> Reviewed-by: Markus Armbruster <armbru@xxxxxxxxxx>
> Reviewed-by: Cédric Le Goater <clg@xxxxxxxx>
> Acked-by: John Snow <jsnow@xxxxxxxxxx>
> Reviewed-by: Richard Henderson <richard.henderson@xxxxxxxxxx>
> Signed-off-by: Philippe Mathieu-Daudé <f4bug@xxxxxxxxx>
Lovely.
Reviewed-by: Markus Armbruster <armbru@xxxxxxxxxx>
Now repeat this exercise for each QOM type cast macro :)
|