Skip to contentSkip to conversation

qom: remove type_initialize() in object_new_with_type()

PATCH In review Wei Yang 3 participants 3 messages Mar 1, 2019 – Mar 2, 2019

lore
Share & tools
lore

Wei Yang

author
#0 lore raw

PATCH 1/1 qom: remove type_initialize() in object_new_with_type()

Here is the abstraction of current call flow of object_new_with_type()

object_initialize_with_type
type_initialize
object_initialize_with_type
type_initialize

This is not necessary to spread type_initialize in two places.

---
 qom/object.c | 1 -
 1 file changed, 1 deletion(-)
qom/object.c +0 -1
index b8c732063b..6252cca418 100644
@@ -585,7 +585,6 @@ static Object *object_new_with_type(Type type)
     Object *obj;
 
     g_assert(type != NULL);
-    type_initialize(type);
 
     obj = g_malloc(type->instance_size);
     object_initialize_with_type(obj, type->instance_size, type);
Signature · 1 line
2.19.1
#1 lore raw
Quoted 19 lines · On Fri, 1 Mar 2019 15:44:48 +0800 Wei Yang <[email protected]>…

Here is the abstraction of current call flow of object_new_with_type()

object_initialize_with_type
type_initialize
object_initialize_with_type
type_initialize

This is not necessary to spread type_initialize in two places.

---
 qom/object.c | 1 -
 1 file changed, 1 deletion(-)
qom/object.c +0 -0
index b8c732063b..6252cca418 100644

qom/object.c static Object *object_new_with_type(Type type) · line 590

Quoted 7 lines
qom/object.c +0 -1
@@ -585,7 +585,6 @@ static Object *object_new_with_type(Type type)
     Object *obj;
 
     g_assert(type != NULL);
-    type_initialize(type);
 
     obj = g_malloc(type->instance_size);
     object_initialize_with_type(obj, type->instance_size, type);

Are you sure it's correct?

see how type->instance_size

PS:
there is also unit-tests which might detect issues in patches before one sends them. To execute them run: make check

#2 lore raw
Quoted 24 lines · Igor Mammedov
Quoted 21 lines · On Fri, 1 Mar 2019 15:44:48 +0800 Wei Yang <[email protected]>…

Here is the abstraction of current call flow of object_new_with_type()

object_initialize_with_type
type_initialize
object_initialize_with_type
type_initialize

This is not necessary to spread type_initialize in two places.

---
 qom/object.c | 1 -
 1 file changed, 1 deletion(-)
qom/object.c +0 -0
index b8c732063b..6252cca418 100644
@@ -585,7 +585,6 @@ static Object *object_new_with_type(Type type)
     Object *obj;
 
Quoted 9 lines

qom/object.c static Object *object_new_with_type(Type type) · line 590

Quoted 5 lines
qom/object.c +0 -1
     g_assert(type != NULL);
-    type_initialize(type);
 
     obj = g_malloc(type->instance_size);
     object_initialize_with_type(obj, type->instance_size, type);

Are you sure it's correct?

see how type->instance_size

You are right, I thought the instance_size is initialized in type_new(). But this would be adjusted in type_initialize() again.

Quoted 4 lines

PS:
there is also unit-tests which might detect issues in patches before one sends them. To execute them run: make check

With this patch applied, I managed to run a guest successfully. Looks this didn't catch some corner case.

Signature · 2 lines
Wei Yang
Help you, Help me