All of lore.kernel.org
 help / color / mirror / Atom feed
* [Qemu-trivial] [PATCH] object_new_with_type: remove redundant code
@ 2015-11-05  5:16 Cao jin
  2015-11-06  8:11 ` Michael Tokarev
  0 siblings, 1 reply; 4+ messages in thread
From: Cao jin @ 2015-11-05  5:16 UTC (permalink / raw)
  To: =qemu-devel; +Cc: qemu-trivial, afaerber

g_assert & type_initialize are called in object_initialize_with_type

Signed-off-by: Cao jin <caoj.fnst@cn.fujitsu.com>
---
 qom/object.c | 3 ---
 1 file changed, 3 deletions(-)

diff --git a/qom/object.c b/qom/object.c
index fc6e161..43ac2dd 100644
--- a/qom/object.c
+++ b/qom/object.c
@@ -423,9 +423,6 @@ 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);
     obj->free = g_free;
-- 
2.1.0



^ permalink raw reply related	[flat|nested] 4+ messages in thread

* [Qemu-trivial] [PATCH] object_new_with_type: remove redundant code
@ 2015-11-05  5:19 Cao jin
  0 siblings, 0 replies; 4+ messages in thread
From: Cao jin @ 2015-11-05  5:19 UTC (permalink / raw)
  To: qemu-devel; +Cc: qemu-trivial, afaerber

g_assert & type_initialize are called in object_initialize_with_type

Signed-off-by: Cao jin <caoj.fnst@cn.fujitsu.com>
---
 qom/object.c | 3 ---
 1 file changed, 3 deletions(-)

diff --git a/qom/object.c b/qom/object.c
index fc6e161..43ac2dd 100644
--- a/qom/object.c
+++ b/qom/object.c
@@ -423,9 +423,6 @@ 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);
     obj->free = g_free;
-- 
2.1.0



^ permalink raw reply related	[flat|nested] 4+ messages in thread

* Re: [Qemu-trivial] [PATCH] object_new_with_type: remove redundant code
  2015-11-05  5:16 [Qemu-trivial] [PATCH] object_new_with_type: remove redundant code Cao jin
@ 2015-11-06  8:11 ` Michael Tokarev
  2015-11-06 11:28   ` Cao jin
  0 siblings, 1 reply; 4+ messages in thread
From: Michael Tokarev @ 2015-11-06  8:11 UTC (permalink / raw)
  To: Cao jin, =qemu-devel; +Cc: qemu-trivial, afaerber

05.11.2015 08:16, Cao jin wrote:
> g_assert & type_initialize are called in object_initialize_with_type

object_new_with_type() is a separate QOM API function.  If we're
to rely on other functions calling it to check for parameters,
we should probably remove it from public API and make it static.

And yes, I'm aware of the fact that currently object_new_with_type()
is only called from object_initialize_with_type().  This is not a
good reason to drop the check/init, since object_new_with_type()
remains a published API and might be used in other places in the
future.

Thanks,

/mjt


^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [Qemu-trivial] [PATCH] object_new_with_type: remove redundant code
  2015-11-06  8:11 ` Michael Tokarev
@ 2015-11-06 11:28   ` Cao jin
  0 siblings, 0 replies; 4+ messages in thread
From: Cao jin @ 2015-11-06 11:28 UTC (permalink / raw)
  To: Michael Tokarev; +Cc: qemu-trivial

Hi Michael,

     Thanks very much for your reply, there is a tiny mistake here, I 
sent the patch with email format typo "=qemu-devel@nongnu.org" and got 
"undeliverable" feeback. so I sent it again...I thought you can`t 
receive the 1st one, but obviously I make a wrong guess...I Already 
replied the 2nd one stating that I realized I am wrong about this patch: 
type_initialize(type) is used to assign a value to type->instance_size 
when it is called 1st time, so it could malloc in the following.

Your opinion make sense to me, thanks for sharing it with me. As a 
personal habit, I prefer to figure out the arch of the project when I 
learn it, and you know, sometimes it is hard to figure out why author 
wrote that way, especially lacking of doc and comment, and having no one 
around to discuss with. So, Thanks very much for discussing with me and 
your time, I appreciate it.

On 11/06/2015 04:11 PM, Michael Tokarev wrote:
> 05.11.2015 08:16, Cao jin wrote:
>> g_assert & type_initialize are called in object_initialize_with_type
>
> object_new_with_type() is a separate QOM API function.  If we're
> to rely on other functions calling it to check for parameters,
> we should probably remove it from public API and make it static.
>
> And yes, I'm aware of the fact that currently object_new_with_type()
> is only called from object_initialize_with_type().  This is not a
> good reason to drop the check/init, since object_new_with_type()
> remains a published API and might be used in other places in the
> future.
>
> Thanks,
>
> /mjt
> .
>

-- 
Yours Sincerely,

Cao Jin


^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2015-11-06 11:28 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2015-11-05  5:16 [Qemu-trivial] [PATCH] object_new_with_type: remove redundant code Cao jin
2015-11-06  8:11 ` Michael Tokarev
2015-11-06 11:28   ` Cao jin
  -- strict thread matches above, loose matches on Subject: below --
2015-11-05  5:19 Cao jin

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.