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

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



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 :)




 


Rackspace

Lists.xenproject.org is hosted with RackSpace, monitoring our
servers 24x7x365 and backed by RackSpace's Fanatical Support®.