[libvirt] [libvirt-glib 2/3] Simplify gvir_config_xml_get_attribute_content a bit

Christophe Fergeau cfergeau at redhat.com
Mon Mar 12 17:52:48 UTC 2012


g_strcmp0 is convenient when comparing potentially NULL strings.
Use this in gvir_config_xml_get_attribute_content instead of
explicitly checking for NULL.
---
 libvirt-gconfig/libvirt-gconfig-helpers.c |    8 ++------
 1 files changed, 2 insertions(+), 6 deletions(-)

diff --git a/libvirt-gconfig/libvirt-gconfig-helpers.c b/libvirt-gconfig/libvirt-gconfig-helpers.c
index 3790cab..ba54590 100644
--- a/libvirt-gconfig/libvirt-gconfig-helpers.c
+++ b/libvirt-gconfig/libvirt-gconfig-helpers.c
@@ -249,13 +249,9 @@ gvir_config_xml_get_attribute_content(xmlNodePtr node, const char *attr_name)
 {
     xmlAttr *attr;
 
-    for (attr = node->properties; attr; attr = attr->next) {
-        if (attr->name == NULL)
-            continue;
-
-        if (strcmp (attr_name, (char *)attr->name) == 0)
+    for (attr = node->properties; attr; attr = attr->next)
+        if (g_strcmp0 (attr_name, (char *)attr->name) == 0)
             return attr->children->content;
-    }
 
     return NULL;
 }
-- 
1.7.7.6




More information about the libvir-list mailing list