Skip to content

Commit

Permalink
qdev: Avoid unnecessary DeviceState* variable at set_prop_arraylen()
Browse files Browse the repository at this point in the history
We're just doing pointer math with the device pointer, we can
simply use obj instead.

Signed-off-by: Eduardo Habkost <[email protected]>
Reviewed-by: Marc-André Lureau <[email protected]>
Reviewed-by: Igor Mammedov <[email protected]>
Message-Id: <[email protected]>
Signed-off-by: Eduardo Habkost <[email protected]>
  • Loading branch information
ehabkost committed Dec 18, 2020
1 parent 1e19871 commit f405e3c
Showing 1 changed file with 2 additions and 3 deletions.
5 changes: 2 additions & 3 deletions hw/core/qdev-properties.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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,
Expand Down

0 comments on commit f405e3c

Please sign in to comment.