qemu-arm
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [PATCH v2 3/3] hw: Remove unnecessary DEVICE() cast


From: Markus Armbruster
Subject: Re: [PATCH v2 3/3] hw: Remove unnecessary DEVICE() cast
Date: Fri, 08 May 2020 14:47:04 +0200
User-agent: Gnus/5.13 (Gnus v5.13) Emacs/26.3 (gnu/linux)

Philippe Mathieu-Daudé <address@hidden> 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 <address@hidden>
> Acked-by: Paul Durrant <address@hidden>
> Reviewed-by: Markus Armbruster <address@hidden>
> Reviewed-by: Cédric Le Goater <address@hidden>
> Acked-by: John Snow <address@hidden>
> Reviewed-by: Richard Henderson <address@hidden>
> Signed-off-by: Philippe Mathieu-Daudé <address@hidden>

Lovely.

Reviewed-by: Markus Armbruster <address@hidden>

Now repeat this exercise for each QOM type cast macro :)




reply via email to

[Prev in Thread] Current Thread [Next in Thread]