* [PATCH] qom: eliminate identical functions
@ 2020-11-30 12:37 Paolo Bonzini
2020-11-30 13:18 ` Philippe Mathieu-Daudé
2020-11-30 13:56 ` Claudio Fontana
0 siblings, 2 replies; 3+ messages in thread
From: Paolo Bonzini @ 2020-11-30 12:37 UTC (permalink / raw)
To: qemu-devel; +Cc: ehabkost
Most property release functions in qom/object.c only free the opaque
value. Combine all of them into a single function.
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
---
qom/object.c | 36 +++++++-----------------------------
1 file changed, 7 insertions(+), 29 deletions(-)
diff --git a/qom/object.c b/qom/object.c
index 1065355233..75a78c9343 100644
--- a/qom/object.c
+++ b/qom/object.c
@@ -2174,11 +2174,10 @@ static void property_set_str(Object *obj, Visitor *v, const char *name,
g_free(value);
}
-static void property_release_str(Object *obj, const char *name,
- void *opaque)
+static void property_release_data(Object *obj, const char *name,
+ void *opaque)
{
- StringProperty *prop = opaque;
- g_free(prop);
+ g_free(opaque);
}
ObjectProperty *
@@ -2194,7 +2193,7 @@ object_property_add_str(Object *obj, const char *name,
return object_property_add(obj, name, "string",
get ? property_get_str : NULL,
set ? property_set_str : NULL,
- property_release_str,
+ property_release_data,
prop);
}
@@ -2251,13 +2250,6 @@ static void property_set_bool(Object *obj, Visitor *v, const char *name,
prop->set(obj, value, errp);
}
-static void property_release_bool(Object *obj, const char *name,
- void *opaque)
-{
- BoolProperty *prop = opaque;
- g_free(prop);
-}
-
ObjectProperty *
object_property_add_bool(Object *obj, const char *name,
bool (*get)(Object *, Error **),
@@ -2271,7 +2263,7 @@ object_property_add_bool(Object *obj, const char *name,
return object_property_add(obj, name, "bool",
get ? property_get_bool : NULL,
set ? property_set_bool : NULL,
- property_release_bool,
+ property_release_data,
prop);
}
@@ -2320,13 +2312,6 @@ static void property_set_enum(Object *obj, Visitor *v, const char *name,
prop->set(obj, value, errp);
}
-static void property_release_enum(Object *obj, const char *name,
- void *opaque)
-{
- EnumProperty *prop = opaque;
- g_free(prop);
-}
-
ObjectProperty *
object_property_add_enum(Object *obj, const char *name,
const char *typename,
@@ -2343,7 +2328,7 @@ object_property_add_enum(Object *obj, const char *name,
return object_property_add(obj, name, typename,
get ? property_get_enum : NULL,
set ? property_set_enum : NULL,
- property_release_enum,
+ property_release_data,
prop);
}
@@ -2410,13 +2395,6 @@ out_end:
visit_end_struct(v, NULL);
}
-static void property_release_tm(Object *obj, const char *name,
- void *opaque)
-{
- TMProperty *prop = opaque;
- g_free(prop);
-}
-
ObjectProperty *
object_property_add_tm(Object *obj, const char *name,
void (*get)(Object *, struct tm *, Error **))
@@ -2427,7 +2405,7 @@ object_property_add_tm(Object *obj, const char *name,
return object_property_add(obj, name, "struct tm",
get ? property_get_tm : NULL, NULL,
- property_release_tm,
+ property_release_data,
prop);
}
--
2.26.2
^ permalink raw reply related [flat|nested] 3+ messages in thread
* Re: [PATCH] qom: eliminate identical functions
2020-11-30 12:37 [PATCH] qom: eliminate identical functions Paolo Bonzini
@ 2020-11-30 13:18 ` Philippe Mathieu-Daudé
2020-11-30 13:56 ` Claudio Fontana
1 sibling, 0 replies; 3+ messages in thread
From: Philippe Mathieu-Daudé @ 2020-11-30 13:18 UTC (permalink / raw)
To: Paolo Bonzini, qemu-devel; +Cc: ehabkost
On 11/30/20 1:37 PM, Paolo Bonzini wrote:
> Most property release functions in qom/object.c only free the opaque
> value. Combine all of them into a single function.
>
> Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
> ---
> qom/object.c | 36 +++++++-----------------------------
> 1 file changed, 7 insertions(+), 29 deletions(-)
Reviewed-by: Philippe Mathieu-Daudé <philmd@redhat.com>
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [PATCH] qom: eliminate identical functions
2020-11-30 12:37 [PATCH] qom: eliminate identical functions Paolo Bonzini
2020-11-30 13:18 ` Philippe Mathieu-Daudé
@ 2020-11-30 13:56 ` Claudio Fontana
1 sibling, 0 replies; 3+ messages in thread
From: Claudio Fontana @ 2020-11-30 13:56 UTC (permalink / raw)
To: Paolo Bonzini, qemu-devel; +Cc: ehabkost
On 11/30/20 1:37 PM, Paolo Bonzini wrote:
> Most property release functions in qom/object.c only free the opaque
> value. Combine all of them into a single function.
>
> Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
I noticed also a bunch of unused defines in qom,
OBJECT_DEFINE_... not all of them are really used..
Ciao,
Claudio
> ---
> qom/object.c | 36 +++++++-----------------------------
> 1 file changed, 7 insertions(+), 29 deletions(-)
>
> diff --git a/qom/object.c b/qom/object.c
> index 1065355233..75a78c9343 100644
> --- a/qom/object.c
> +++ b/qom/object.c
> @@ -2174,11 +2174,10 @@ static void property_set_str(Object *obj, Visitor *v, const char *name,
> g_free(value);
> }
>
> -static void property_release_str(Object *obj, const char *name,
> - void *opaque)
> +static void property_release_data(Object *obj, const char *name,
> + void *opaque)
> {
> - StringProperty *prop = opaque;
> - g_free(prop);
> + g_free(opaque);
> }
>
> ObjectProperty *
> @@ -2194,7 +2193,7 @@ object_property_add_str(Object *obj, const char *name,
> return object_property_add(obj, name, "string",
> get ? property_get_str : NULL,
> set ? property_set_str : NULL,
> - property_release_str,
> + property_release_data,
> prop);
> }
>
> @@ -2251,13 +2250,6 @@ static void property_set_bool(Object *obj, Visitor *v, const char *name,
> prop->set(obj, value, errp);
> }
>
> -static void property_release_bool(Object *obj, const char *name,
> - void *opaque)
> -{
> - BoolProperty *prop = opaque;
> - g_free(prop);
> -}
> -
> ObjectProperty *
> object_property_add_bool(Object *obj, const char *name,
> bool (*get)(Object *, Error **),
> @@ -2271,7 +2263,7 @@ object_property_add_bool(Object *obj, const char *name,
> return object_property_add(obj, name, "bool",
> get ? property_get_bool : NULL,
> set ? property_set_bool : NULL,
> - property_release_bool,
> + property_release_data,
> prop);
> }
>
> @@ -2320,13 +2312,6 @@ static void property_set_enum(Object *obj, Visitor *v, const char *name,
> prop->set(obj, value, errp);
> }
>
> -static void property_release_enum(Object *obj, const char *name,
> - void *opaque)
> -{
> - EnumProperty *prop = opaque;
> - g_free(prop);
> -}
> -
> ObjectProperty *
> object_property_add_enum(Object *obj, const char *name,
> const char *typename,
> @@ -2343,7 +2328,7 @@ object_property_add_enum(Object *obj, const char *name,
> return object_property_add(obj, name, typename,
> get ? property_get_enum : NULL,
> set ? property_set_enum : NULL,
> - property_release_enum,
> + property_release_data,
> prop);
> }
>
> @@ -2410,13 +2395,6 @@ out_end:
> visit_end_struct(v, NULL);
> }
>
> -static void property_release_tm(Object *obj, const char *name,
> - void *opaque)
> -{
> - TMProperty *prop = opaque;
> - g_free(prop);
> -}
> -
> ObjectProperty *
> object_property_add_tm(Object *obj, const char *name,
> void (*get)(Object *, struct tm *, Error **))
> @@ -2427,7 +2405,7 @@ object_property_add_tm(Object *obj, const char *name,
>
> return object_property_add(obj, name, "struct tm",
> get ? property_get_tm : NULL, NULL,
> - property_release_tm,
> + property_release_data,
> prop);
> }
>
>
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2020-11-30 13:58 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-11-30 12:37 [PATCH] qom: eliminate identical functions Paolo Bonzini
2020-11-30 13:18 ` Philippe Mathieu-Daudé
2020-11-30 13:56 ` Claudio Fontana
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.