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

[libvirt] [PATCH 2/5] conf: minor indentation cleanups



On few places there are too many levels of indentation when some of
them can be fixed with negating the option they are in or omitting
useless condition altogether.
---
 src/conf/domain_conf.c | 65 +++++++++++++++++++++++++-------------------------
 1 file changed, 32 insertions(+), 33 deletions(-)

diff --git a/src/conf/domain_conf.c b/src/conf/domain_conf.c
index 19af058..cba910a 100644
--- a/src/conf/domain_conf.c
+++ b/src/conf/domain_conf.c
@@ -9060,21 +9060,22 @@ static virDomainDefPtr virDomainDefParseXML(virCapsPtr caps,
         }

         for (i = 0; i < def->vcpus; i++) {
-            if (!virDomainVcpuPinIsDuplicate(def->cputune.vcpupin,
-                                             def->cputune.nvcpupin,
-                                             i)) {
-                virDomainVcpuPinDefPtr vcpupin = NULL;
+            if (virDomainVcpuPinIsDuplicate(def->cputune.vcpupin,
+                                            def->cputune.nvcpupin,
+                                            i))
+                continue;

-                if (VIR_ALLOC(vcpupin) < 0) {
-                    virReportOOMError();
-                    goto error;
-                }
+            virDomainVcpuPinDefPtr vcpupin = NULL;

-                vcpupin->cpumask = virBitmapNew(VIR_DOMAIN_CPUMASK_LEN);
-                virBitmapCopy(vcpupin->cpumask, def->cpumask);
-                vcpupin->vcpuid = i;
-                def->cputune.vcpupin[def->cputune.nvcpupin++] = vcpupin;
+            if (VIR_ALLOC(vcpupin) < 0) {
+                virReportOOMError();
+                goto error;
             }
+
+            vcpupin->cpumask = virBitmapNew(VIR_DOMAIN_CPUMASK_LEN);
+            virBitmapCopy(vcpupin->cpumask, def->cpumask);
+            vcpupin->vcpuid = i;
+            def->cputune.vcpupin[def->cputune.nvcpupin++] = vcpupin;
         }
     }

@@ -13921,31 +13922,29 @@ virDomainDefFormatInternal(virDomainDefPtr def,
                           "</emulator_quota>\n",
                           def->cputune.emulator_quota);

-    if (def->cputune.vcpupin) {
-        for (i = 0; i < def->cputune.nvcpupin; i++) {
-            /* Ignore the vcpupin which inherit from "cpuset"
-             * of "<vcpu>."
-             */
-            if (def->cpumask &&
-                virBitmapEqual(def->cpumask,
-                               def->cputune.vcpupin[i]->cpumask))
-                continue;
-
-            virBufferAsprintf(buf, "    <vcpupin vcpu='%u' ",
-                              def->cputune.vcpupin[i]->vcpuid);
+    for (i = 0; i < def->cputune.nvcpupin; i++) {
+        /* Ignore the vcpupin which inherit from "cpuset"
+         * of "<vcpu>."
+         */
+        if (def->cpumask &&
+            virBitmapEqual(def->cpumask,
+                           def->cputune.vcpupin[i]->cpumask))
+            continue;

-            char *cpumask = NULL;
-            cpumask = virBitmapFormat(def->cputune.vcpupin[i]->cpumask);
+        virBufferAsprintf(buf, "    <vcpupin vcpu='%u' ",
+                          def->cputune.vcpupin[i]->vcpuid);

-            if (cpumask == NULL) {
-                virReportError(VIR_ERR_INTERNAL_ERROR,
-                               "%s", _("failed to format cpuset for vcpupin"));
-                goto cleanup;
-            }
+        char *cpumask = NULL;
+        cpumask = virBitmapFormat(def->cputune.vcpupin[i]->cpumask);

-            virBufferAsprintf(buf, "cpuset='%s'/>\n", cpumask);
-            VIR_FREE(cpumask);
+        if (cpumask == NULL) {
+            virReportError(VIR_ERR_INTERNAL_ERROR,
+                           "%s", _("failed to format cpuset for vcpupin"));
+            goto cleanup;
         }
+
+        virBufferAsprintf(buf, "cpuset='%s'/>\n", cpumask);
+        VIR_FREE(cpumask);
     }

     if (def->cputune.emulatorpin) {
-- 
1.8.0.2


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