[libvirt-glib] Prefer 'for' over 'while'

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



From: "Zeeshan Ali (Khattak)" <zeeshanak@xxxxxxxxx>

In this particular case 'for' seems like a more natural choice as then
we don't need to update the iterator (which we were forgetting to do and
causing a hang in Boxes).
---
 libvirt-gconfig/libvirt-gconfig-helpers.c |    5 +----
 1 files changed, 1 insertions(+), 4 deletions(-)

diff --git a/libvirt-gconfig/libvirt-gconfig-helpers.c b/libvirt-gconfig/libvirt-gconfig-helpers.c
index c406a49..cc2e5cc 100644
--- a/libvirt-gconfig/libvirt-gconfig-helpers.c
+++ b/libvirt-gconfig/libvirt-gconfig-helpers.c
@@ -169,17 +169,14 @@ void gvir_config_xml_foreach_child(xmlNodePtr node,
 
     g_return_if_fail(iter_func != NULL);
 
-    it = node->children;
-    while (it != NULL) {
+    for (it = node->children; it != NULL; it = it->next) {
         gboolean cont;
-        xmlNodePtr next = it->next;
 
         if (xmlIsBlankNode(it))
             continue;
         cont = iter_func(it, opaque);
         if (!cont)
             break;
-        it = next;
     }
 }
 
-- 
1.7.7.5

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


[Index of Archives]     [Virt Tools]     [Libvirt Users]     [Lib OS Info]     [Fedora Users]     [Fedora Desktop]     [Fedora SELinux]     [Big List of Linux Books]     [Yosemite News]     [KDE Users]     [Fedora Tools]