[libvirt] [libvirt-glib 1/6] gconfig: Allow not found child in gvir_config_object_get_child_with_type
Christophe Fergeau
cfergeau at redhat.com
Wed Jun 5 08:29:34 UTC 2013
On Tue, Jun 04, 2013 at 08:03:51PM +0200, Michal Privoznik wrote:
> On 04.06.2013 18:50, Christophe Fergeau wrote:
> > This will be useful when implementing gvir_domain_snapshot_get_parent()
> > as the child node 'parent' is not always present in the XML.
> > ---
> > libvirt-gconfig/libvirt-gconfig-object.c | 3 ++-
> > 1 file changed, 2 insertions(+), 1 deletion(-)
> >
> > diff --git a/libvirt-gconfig/libvirt-gconfig-object.c b/libvirt-gconfig/libvirt-gconfig-object.c
> > index 9e3b5f2..721f6cb 100644
> > --- a/libvirt-gconfig/libvirt-gconfig-object.c
> > +++ b/libvirt-gconfig/libvirt-gconfig-object.c
> > @@ -929,7 +929,8 @@ gvir_config_object_get_child_with_type(GVirConfigObject *object,
> > g_return_val_if_fail(child_name != NULL, NULL);
> >
> > node = gvir_config_xml_get_element(object->priv->node, child_name, NULL);
> > - g_return_val_if_fail(node != NULL, NULL);
> > + if (node == NULL)
> > + return NULL;
> >
> > return gvir_config_object_new_from_tree(child_type,
> > object->priv->doc,
> >
>
> I took me a while to realize this is not a NOP. g_return_val_if_fail
> reports critical error, but more importantly, can be turned off at
> compile time.
It's generally expected not to be turned off, what I wanted to get rid off
here is the warning that is output in the console when teh
g_return_val_if_fail is triggered.
Christophe
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 198 bytes
Desc: not available
URL: <http://listman.redhat.com/archives/libvir-list/attachments/20130605/a88a67f9/attachment-0001.sig>
More information about the libvir-list
mailing list