[libvirt] [PATCH] remove bogus casts of arg to g_object_ref

Daniel P. Berrange posted 1 patch 6 years, 4 months ago
Failed in applying to current master (apply log)
libvirt-gconfig/libvirt-gconfig-object.c | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
[libvirt] [PATCH] remove bogus casts of arg to g_object_ref
Posted by Daniel P. Berrange 6 years, 4 months ago
Latest version of glib uses typeof() magic to cast the
return value of g_object_ref to match its argument,
instead of returning a 'void *'. A few places in the
code were casting the arg to G_OBJECT() which was then
incompatible with the variable we assigned the result
to. The parameter casts were always redundant so just
remove them.

Signed-off-by: Daniel P. Berrange <berrange@redhat.com>
---
 libvirt-gconfig/libvirt-gconfig-object.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/libvirt-gconfig/libvirt-gconfig-object.c b/libvirt-gconfig/libvirt-gconfig-object.c
index 851e35c..ca2c6e6 100644
--- a/libvirt-gconfig/libvirt-gconfig-object.c
+++ b/libvirt-gconfig/libvirt-gconfig-object.c
@@ -572,7 +572,7 @@ gvir_config_object_set_node_content(GVirConfigObject *object,
         node = gvir_config_object_replace_child(object, node_name);
         g_return_if_fail(node != NULL);
     } else {
-        node = g_object_ref(G_OBJECT(object));
+        node = g_object_ref(object);
     }
     encoded_data = xmlEncodeEntitiesReentrant(node->priv->node->doc,
                                               (xmlChar *)value);
@@ -896,7 +896,7 @@ gvir_config_object_attach(GVirConfigObject *parent, GVirConfigObject *child, gbo
         child->priv->doc = NULL;
     }
     if (parent->priv->doc != NULL) {
-        child->priv->doc = g_object_ref(G_OBJECT(parent->priv->doc));
+        child->priv->doc = g_object_ref(parent->priv->doc);
     }
 }
 
-- 
2.14.3

--
libvir-list mailing list
libvir-list@redhat.com
https://www.redhat.com/mailman/listinfo/libvir-list
Re: [libvirt] [PATCH] remove bogus casts of arg to g_object_ref
Posted by Daniel P. Berrange 6 years, 4 months ago
On Wed, Jan 17, 2018 at 02:43:17PM +0000, Daniel P. Berrange wrote:
> Latest version of glib uses typeof() magic to cast the
> return value of g_object_ref to match its argument,
> instead of returning a 'void *'. A few places in the
> code were casting the arg to G_OBJECT() which was then
> incompatible with the variable we assigned the result
> to. The parameter casts were always redundant so just
> remove them.
> 
> Signed-off-by: Daniel P. Berrange <berrange@redhat.com>
> ---
>  libvirt-gconfig/libvirt-gconfig-object.c | 4 ++--
>  1 file changed, 2 insertions(+), 2 deletions(-)

Opps, should have said, I pushed this as a build fix...

> 
> diff --git a/libvirt-gconfig/libvirt-gconfig-object.c b/libvirt-gconfig/libvirt-gconfig-object.c
> index 851e35c..ca2c6e6 100644
> --- a/libvirt-gconfig/libvirt-gconfig-object.c
> +++ b/libvirt-gconfig/libvirt-gconfig-object.c
> @@ -572,7 +572,7 @@ gvir_config_object_set_node_content(GVirConfigObject *object,
>          node = gvir_config_object_replace_child(object, node_name);
>          g_return_if_fail(node != NULL);
>      } else {
> -        node = g_object_ref(G_OBJECT(object));
> +        node = g_object_ref(object);
>      }
>      encoded_data = xmlEncodeEntitiesReentrant(node->priv->node->doc,
>                                                (xmlChar *)value);
> @@ -896,7 +896,7 @@ gvir_config_object_attach(GVirConfigObject *parent, GVirConfigObject *child, gbo
>          child->priv->doc = NULL;
>      }
>      if (parent->priv->doc != NULL) {
> -        child->priv->doc = g_object_ref(G_OBJECT(parent->priv->doc));
> +        child->priv->doc = g_object_ref(parent->priv->doc);
>      }
>  }
>  
> -- 
> 2.14.3
> 

Regards,
Daniel
-- 
|: https://berrange.com      -o-    https://www.flickr.com/photos/dberrange :|
|: https://libvirt.org         -o-            https://fstop138.berrange.com :|
|: https://entangle-photo.org    -o-    https://www.instagram.com/dberrange :|

--
libvir-list mailing list
libvir-list@redhat.com
https://www.redhat.com/mailman/listinfo/libvir-list