[PATCH 1/8] Remove superfluous usage of virDomainDeviceInfoNeedsFormat

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

 



This function returns false if virDomainDeviceInfoFormat
would not format anything.

Using it as the sole condition to decide whether to call
virDomainDeviceInfoFormat or not is pointless, since
the conditions are repeated in virDomainDeviceInfoFormat.
---
 src/conf/domain_conf.c | 33 +++++++++++----------------------
 1 file changed, 11 insertions(+), 22 deletions(-)

diff --git a/src/conf/domain_conf.c b/src/conf/domain_conf.c
index 34c8f45ed..73c4b55e9 100644
--- a/src/conf/domain_conf.c
+++ b/src/conf/domain_conf.c
@@ -21903,8 +21903,7 @@ virDomainControllerDefFormat(virBufferPtr buf,
 
     virDomainControllerDriverFormat(&childBuf, def);
 
-    if (virDomainDeviceInfoNeedsFormat(&def->info, flags) &&
-        virDomainDeviceInfoFormat(&childBuf, &def->info, flags) < 0)
+    if (virDomainDeviceInfoFormat(&childBuf, &def->info, flags) < 0)
         return -1;
 
     if (def->type == VIR_DOMAIN_CONTROLLER_TYPE_PCI &&
@@ -23037,10 +23036,8 @@ virDomainChrDefFormat(virBufferPtr buf,
         break;
     }
 
-    if (virDomainDeviceInfoNeedsFormat(&def->info, flags)) {
-        if (virDomainDeviceInfoFormat(buf, &def->info, flags) < 0)
-            return -1;
-    }
+    if (virDomainDeviceInfoFormat(buf, &def->info, flags) < 0)
+        return -1;
 
     virBufferAdjustIndent(buf, -2);
     virBufferAsprintf(buf, "</%s>\n", elementName);
@@ -23142,10 +23139,8 @@ virDomainTPMDefFormat(virBufferPtr buf,
     virBufferAdjustIndent(buf, -2);
     virBufferAddLit(buf, "</backend>\n");
 
-    if (virDomainDeviceInfoNeedsFormat(&def->info, flags)) {
-        if (virDomainDeviceInfoFormat(buf, &def->info, flags) < 0)
-            return -1;
-    }
+    if (virDomainDeviceInfoFormat(buf, &def->info, flags) < 0)
+        return -1;
 
     virBufferAdjustIndent(buf, -2);
     virBufferAddLit(buf, "</tpm>\n");
@@ -23227,8 +23222,7 @@ virDomainMemballoonDefFormat(virBufferPtr buf,
     if (def->period)
         virBufferAsprintf(&childrenBuf, "<stats period='%i'/>\n", def->period);
 
-    if (virDomainDeviceInfoNeedsFormat(&def->info, flags) &&
-        virDomainDeviceInfoFormat(&childrenBuf, &def->info, flags) < 0) {
+    if (virDomainDeviceInfoFormat(&childrenBuf, &def->info, flags) < 0) {
         virBufferFreeAndReset(&childrenBuf);
         return -1;
     }
@@ -23267,8 +23261,7 @@ virDomainNVRAMDefFormat(virBufferPtr buf,
 {
     virBufferAddLit(buf, "<nvram>\n");
     virBufferAdjustIndent(buf, 2);
-    if (virDomainDeviceInfoNeedsFormat(&def->info, flags) &&
-        virDomainDeviceInfoFormat(buf, &def->info, flags) < 0)
+    if (virDomainDeviceInfoFormat(buf, &def->info, flags) < 0)
         return -1;
 
     virBufferAdjustIndent(buf, -2);
@@ -23427,10 +23420,8 @@ virDomainRNGDefFormat(virBufferPtr buf,
         virBufferAddLit(buf, "/>\n");
     }
 
-    if (virDomainDeviceInfoNeedsFormat(&def->info, flags)) {
-        if (virDomainDeviceInfoFormat(buf, &def->info, flags) < 0)
-            return -1;
-    }
+    if (virDomainDeviceInfoFormat(buf, &def->info, flags) < 0)
+        return -1;
 
     virBufferAdjustIndent(buf, -2);
     virBufferAddLit(buf, "</rng>\n");
@@ -23548,10 +23539,8 @@ virDomainMemoryDefFormat(virBufferPtr buf,
 
     virDomainMemoryTargetDefFormat(buf, def);
 
-    if (virDomainDeviceInfoNeedsFormat(&def->info, flags)) {
-        if (virDomainDeviceInfoFormat(buf, &def->info, flags) < 0)
-            return -1;
-    }
+    if (virDomainDeviceInfoFormat(buf, &def->info, flags) < 0)
+        return -1;
 
     virBufferAdjustIndent(buf, -2);
     virBufferAddLit(buf, "</memory>\n");
-- 
2.13.0

--
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]
  Powered by Linux