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

Lovely.

Reviewed-by: Markus Armbruster <[email protected]>

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


Reply via email to