diff mbox

[RFC,10/14] qom: catch errors in object_property_add_child

Message ID 1386764361-15260-11-git-send-email-pbonzini@redhat.com
State New
Headers show

Commit Message

Paolo Bonzini Dec. 11, 2013, 12:19 p.m. UTC
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
---
 qom/object.c | 9 +++++++--
 1 file changed, 7 insertions(+), 2 deletions(-)

Comments

Igor Mammedov Dec. 11, 2013, 12:44 p.m. UTC | #1
On Wed, 11 Dec 2013 13:19:17 +0100
Paolo Bonzini <pbonzini@redhat.com> wrote:

> Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
> ---
>  qom/object.c | 9 +++++++--
>  1 file changed, 7 insertions(+), 2 deletions(-)
> 
> diff --git a/qom/object.c b/qom/object.c
> index fc19cf6..68fe07a 100644
> --- a/qom/object.c
> +++ b/qom/object.c
> @@ -988,17 +988,22 @@ static void object_finalize_child_property(Object *obj, const char *name,
>  void object_property_add_child(Object *obj, const char *name,
>                                 Object *child, Error **errp)
>  {
> +    Error *local_err = NULL;
>      gchar *type;
>  
>      type = g_strdup_printf("child<%s>", object_get_typename(OBJECT(child)));
>  
>      object_property_add(obj, name, type, object_get_child_property,
> -                        NULL, object_finalize_child_property, child, errp);
> -
> +                        NULL, object_finalize_child_property, child, &local_err);
> +    if (error_is_set(&local_err)) {
> +        error_propagate(errp, local_err);
> +        goto out;
> +    }
>      object_ref(child);
>      g_assert(child->parent == NULL);
>      child->parent = obj;
>  
> +out:
>      g_free(type);
>  }
>  
> -- 
> 1.8.4.2
> 
> 
> 
Reviewed-By: Igor Mammedov <imammedo@redhat.com>
Stefan Hajnoczi Dec. 12, 2013, 8:18 a.m. UTC | #2
On Wed, Dec 11, 2013 at 01:19:17PM +0100, Paolo Bonzini wrote:
> Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
> ---
>  qom/object.c | 9 +++++++--
>  1 file changed, 7 insertions(+), 2 deletions(-)

Reviewed-by: Stefan Hajnoczi <stefanha@redhat.com>
diff mbox

Patch

diff --git a/qom/object.c b/qom/object.c
index fc19cf6..68fe07a 100644
--- a/qom/object.c
+++ b/qom/object.c
@@ -988,17 +988,22 @@  static void object_finalize_child_property(Object *obj, const char *name,
 void object_property_add_child(Object *obj, const char *name,
                                Object *child, Error **errp)
 {
+    Error *local_err = NULL;
     gchar *type;
 
     type = g_strdup_printf("child<%s>", object_get_typename(OBJECT(child)));
 
     object_property_add(obj, name, type, object_get_child_property,
-                        NULL, object_finalize_child_property, child, errp);
-
+                        NULL, object_finalize_child_property, child, &local_err);
+    if (error_is_set(&local_err)) {
+        error_propagate(errp, local_err);
+        goto out;
+    }
     object_ref(child);
     g_assert(child->parent == NULL);
     child->parent = obj;
 
+out:
     g_free(type);
 }