[libvirt] [PATCH 03/10] conf: disk: Remove one unnecessary level of indentation

Cole Robinson crobinso at redhat.com
Tue Apr 12 14:15:16 UTC 2016


On 04/12/2016 09:55 AM, Peter Krempa wrote:
> Also simplify the code by switching to a for loop.
> ---
>  src/conf/domain_conf.c | 737 ++++++++++++++++++++++++-------------------------
>  1 file changed, 368 insertions(+), 369 deletions(-)
> 

git show -w makes it clear:

diff --git a/src/conf/domain_conf.c b/src/conf/domain_conf.c
index fb5d327..f691174 100644
--- a/src/conf/domain_conf.c
+++ b/src/conf/domain_conf.c
@@ -6760,9 +6760,10 @@ virDomainDiskDefParseXML(virDomainXMLOptionPtr xmlopt,
     rawio = virXMLPropString(node, "rawio");
     sgio = virXMLPropString(node, "sgio");

-    cur = node->children;
-    while (cur != NULL) {
-        if (cur->type == XML_ELEMENT_NODE) {
+    for (cur = node->children; cur != NULL; cur = cur->next) {
+        if (cur->type != XML_ELEMENT_NODE)
+            continue;
+
         if (!source && xmlStrEqual(cur->name, BAD_CAST "source")) {
             sourceNode = cur;

@@ -7176,8 +7177,6 @@ virDomainDiskDefParseXML(virDomainXMLOptionPtr xmlopt,
             /* boot is parsed as part of virDomainDeviceInfoParseXML */
         }
     }
-        cur = cur->next;
-    }

     /* Disk volume types will have authentication information handled in
      * virStorageTranslateDiskSourcePool

ACK

- Cole




More information about the libvir-list mailing list