qom/object: pass (Object *) to object_initialize_with_type()
PATCH 1/1 qom/object: pass (Object *) to object_initialize_with_type()
object_new_with_type() already passes (Object *) pointer. Avoid casting back and forth.
---
qom/object.c | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-)
qom/object.c +1 -3
@@ -495,10 +495,8 @@ static void object_class_property_init_all(Object *obj) } } -static void object_initialize_with_type (void *data,size_t size,TypeImpl *type) +static void object_initialize_with_type (Object *obj,size_t size,TypeImpl *type) { -Object *obj = data; -type_initialize (type);g_assert (type->instance_size >=sizeof (Object));
Signature · 1 line
2.25.1
Quoted 2 lines · Masahiro Yamada
object_new_with_type()already passes (Object *) pointer. Avoid casting back and forth.
But object_initialize() doesn't...
Quoted 24 lines
Signed-off-by Masahiro Yamada <[email protected]>---
qom/object.c | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-)qom/object.c +1
-3@@ -495,10 +495,8 @@ static void object_class_property_init_all(Object *obj) } } -static void object_initialize_with_type (void *data,size_t size,TypeImpl *type) +static void object_initialize_with_type (Object *obj,size_t size,TypeImpl *type) { -Object *obj = data; -type_initialize (type);g_assert (type->instance_size >=sizeof (Object));
Quoted 6 lines · Philippe Mathieu-Daudé
Quoted 2 lines · Masahiro Yamada
object_new_with_type()already passes (Object *) pointer. Avoid casting back and forth.But
object_initialize()doesn't...
That is no problem.
A caller can pass an opaque pointer
to a function that takes (Object *).
There is no explicit cast for it.
Quoted 23 lines
Quoted 23 lines
Signed-off-by Masahiro Yamada <[email protected]>---
qom/object.c | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-)qom/object.c +1
-3@@ -495,10 +495,8 @@ static void object_class_property_init_all(Object *obj) } } -static void object_initialize_with_type (void *data,size_t size,TypeImpl *type) +static void object_initialize_with_type (Object *obj,size_t size,TypeImpl *type) { -Object *obj = data; -type_initialize (type);
Quoted 3 lines
qom/object.c static void object_class_property_init_all(Object *obj) · line 502
Quoted 2 lines
qom/object.c +0
-0g_assert (type->instance_size >=sizeof (Object));
--
Best Regards
Masahiro Yamada
Paolo Bonzini
AppliedQuoted 16 lines · Masahiro Yamada
object_new_with_type()already passes (Object *) pointer. Avoid casting back and forth.Signed-off-by Masahiro Yamada <[email protected]>---
qom/object.c | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-)qom/object.c +0
-0@@ -495,10 +495,8 @@ static void object_class_property_init_all(Object *obj) }
qom/object.c static void object_class_property_init_all(Object *obj) · line 502
Quoted 10 lines
qom/object.c +1
-3} -static void object_initialize_with_type (void *data,size_t size,TypeImpl *type) +static void object_initialize_with_type (Object *obj,size_t size,TypeImpl *type) { -Object *obj = data; -type_initialize (type);g_assert (type->instance_size >=sizeof (Object));
Queued, thanks.
Paolo