qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] qom/object: pass (Object *) to object_initialize_with_type()
@ 2020-05-12 17:31 Masahiro Yamada
  2020-05-12 18:17 ` Philippe Mathieu-Daudé
  2020-05-21 14:46 ` Paolo Bonzini
  0 siblings, 2 replies; 4+ messages in thread
From: Masahiro Yamada @ 2020-05-12 17:31 UTC (permalink / raw)
  To: qemu-devel, Paolo Bonzini, Daniel P . Berrange, Eduardo Habkost
  Cc: Masahiro Yamada

object_new_with_type() already passes (Object *) pointer.
Avoid casting back and forth.

Signed-off-by: Masahiro Yamada <masahiroy@kernel.org>
---

 qom/object.c | 4 +---
 1 file changed, 1 insertion(+), 3 deletions(-)

diff --git a/qom/object.c b/qom/object.c
index e4085d8ae2..9d1a918e42 100644
--- a/qom/object.c
+++ b/qom/object.c
@@ -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));
-- 
2.25.1



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

* Re: [PATCH] qom/object: pass (Object *) to object_initialize_with_type()
  2020-05-12 17:31 [PATCH] qom/object: pass (Object *) to object_initialize_with_type() Masahiro Yamada
@ 2020-05-12 18:17 ` Philippe Mathieu-Daudé
  2020-05-12 18:32   ` Masahiro Yamada
  2020-05-21 14:46 ` Paolo Bonzini
  1 sibling, 1 reply; 4+ messages in thread
From: Philippe Mathieu-Daudé @ 2020-05-12 18:17 UTC (permalink / raw)
  To: Masahiro Yamada, qemu-devel, Paolo Bonzini, Daniel P . Berrange,
	Eduardo Habkost

On 5/12/20 7:31 PM, Masahiro Yamada wrote:
> object_new_with_type() already passes (Object *) pointer.
> Avoid casting back and forth.

But object_initialize() doesn't...

> 
> Signed-off-by: Masahiro Yamada <masahiroy@kernel.org>
> ---
> 
>   qom/object.c | 4 +---
>   1 file changed, 1 insertion(+), 3 deletions(-)
> 
> diff --git a/qom/object.c b/qom/object.c
> index e4085d8ae2..9d1a918e42 100644
> --- a/qom/object.c
> +++ b/qom/object.c
> @@ -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));
> 



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

* Re: [PATCH] qom/object: pass (Object *) to object_initialize_with_type()
  2020-05-12 18:17 ` Philippe Mathieu-Daudé
@ 2020-05-12 18:32   ` Masahiro Yamada
  0 siblings, 0 replies; 4+ messages in thread
From: Masahiro Yamada @ 2020-05-12 18:32 UTC (permalink / raw)
  To: Philippe Mathieu-Daudé
  Cc: Paolo Bonzini, Daniel P . Berrange, qemu-devel, Eduardo Habkost

On Wed, May 13, 2020 at 3:17 AM Philippe Mathieu-Daudé
<philmd@redhat.com> wrote:
>
> On 5/12/20 7:31 PM, Masahiro Yamada wrote:
> > 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.






>
> >
> > Signed-off-by: Masahiro Yamada <masahiroy@kernel.org>
> > ---
> >
> >   qom/object.c | 4 +---
> >   1 file changed, 1 insertion(+), 3 deletions(-)
> >
> > diff --git a/qom/object.c b/qom/object.c
> > index e4085d8ae2..9d1a918e42 100644
> > --- a/qom/object.c
> > +++ b/qom/object.c
> > @@ -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));
> >
>


--
Best Regards
Masahiro Yamada


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

* Re: [PATCH] qom/object: pass (Object *) to object_initialize_with_type()
  2020-05-12 17:31 [PATCH] qom/object: pass (Object *) to object_initialize_with_type() Masahiro Yamada
  2020-05-12 18:17 ` Philippe Mathieu-Daudé
@ 2020-05-21 14:46 ` Paolo Bonzini
  1 sibling, 0 replies; 4+ messages in thread
From: Paolo Bonzini @ 2020-05-21 14:46 UTC (permalink / raw)
  To: Masahiro Yamada, qemu-devel, Daniel P . Berrange, Eduardo Habkost

On 12/05/20 19:31, Masahiro Yamada wrote:
> object_new_with_type() already passes (Object *) pointer.
> Avoid casting back and forth.
> 
> Signed-off-by: Masahiro Yamada <masahiroy@kernel.org>
> ---
> 
>  qom/object.c | 4 +---
>  1 file changed, 1 insertion(+), 3 deletions(-)
> 
> diff --git a/qom/object.c b/qom/object.c
> index e4085d8ae2..9d1a918e42 100644
> --- a/qom/object.c
> +++ b/qom/object.c
> @@ -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));
> 

Queued, thanks.

Paolo



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

end of thread, other threads:[~2020-05-21 14:47 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-05-12 17:31 [PATCH] qom/object: pass (Object *) to object_initialize_with_type() Masahiro Yamada
2020-05-12 18:17 ` Philippe Mathieu-Daudé
2020-05-12 18:32   ` Masahiro Yamada
2020-05-21 14:46 ` Paolo Bonzini

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).