Philippe Mathieu-Daudé <f4...@amsat.org> 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 <da...@gibson.dropbear.id.au>
> Acked-by: Paul Durrant <p...@xen.org>
> Reviewed-by: Markus Armbruster <arm...@redhat.com>
> Reviewed-by: Cédric Le Goater <c...@kaod.org>
> Acked-by: John Snow <js...@redhat.com>
> Reviewed-by: Richard Henderson <richard.hender...@linaro.org>
> Signed-off-by: Philippe Mathieu-Daudé <f4...@amsat.org>

Lovely.

Reviewed-by: Markus Armbruster <arm...@redhat.com>

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


Reply via email to