qemu-devel
[Top][All Lists]
Advanced

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

Re: [PATCH v4 31/32] qdev: Avoid unnecessary DeviceState* variable at se


From: Igor Mammedov
Subject: Re: [PATCH v4 31/32] qdev: Avoid unnecessary DeviceState* variable at set_prop_arraylen()
Date: Mon, 14 Dec 2020 16:11:36 +0100

On Fri, 11 Dec 2020 17:05:28 -0500
Eduardo Habkost <ehabkost@redhat.com> wrote:

> We're just doing pointer math with the device pointer, we can
> simply use obj instead.
> 
> Reviewed-by: Marc-André Lureau <marcandre.lureau@redhat.com>
> Signed-off-by: Eduardo Habkost <ehabkost@redhat.com>

Reviewed-by: Igor Mammedov <imammedo@redhat.com>

> ---
> Cc: Paolo Bonzini <pbonzini@redhat.com>
> Cc: "Daniel P. Berrangé" <berrange@redhat.com>
> Cc: Eduardo Habkost <ehabkost@redhat.com>
> Cc: qemu-devel@nongnu.org
> ---
>  hw/core/qdev-properties.c | 5 ++---
>  1 file changed, 2 insertions(+), 3 deletions(-)
> 
> diff --git a/hw/core/qdev-properties.c b/hw/core/qdev-properties.c
> index 3d648b088d..9d25b49fc1 100644
> --- a/hw/core/qdev-properties.c
> +++ b/hw/core/qdev-properties.c
> @@ -559,10 +559,9 @@ static void set_prop_arraylen(Object *obj, Visitor *v, 
> const char *name,
>       * array-length field in the device struct, we have to create the
>       * array itself and dynamically add the corresponding properties.
>       */
> -    DeviceState *dev = DEVICE(obj);
>      Property *prop = opaque;
>      uint32_t *alenptr = object_field_prop_ptr(obj, prop);
> -    void **arrayptr = (void *)dev + prop->arrayoffset;
> +    void **arrayptr = (void *)obj + prop->arrayoffset;
>      void *eltptr;
>      const char *arrayname;
>      int i;
> @@ -602,7 +601,7 @@ static void set_prop_arraylen(Object *obj, Visitor *v, 
> const char *name,
>           * they get the right answer despite the array element not actually
>           * being inside the device struct.
>           */
> -        arrayprop->prop.offset = eltptr - (void *)dev;
> +        arrayprop->prop.offset = eltptr - (void *)obj;
>          assert(object_field_prop_ptr(obj, &arrayprop->prop) == eltptr);
>          object_property_add(obj, propname,
>                              arrayprop->prop.info->name,




reply via email to

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