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

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



From: "Zeeshan Ali (Khattak)" <zeeshanak gnome org>

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


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