[PATCH 17/23] conf: Avoid extra scope when formatting 'smm' feature

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

 



Use an early break and remove the temporary variable.

Signed-off-by: Peter Krempa <pkrempa@xxxxxxxxxx>
---
 src/conf/domain_conf.c | 31 +++++++++++++++----------------
 1 file changed, 15 insertions(+), 16 deletions(-)

diff --git a/src/conf/domain_conf.c b/src/conf/domain_conf.c
index a1ed889e1d..b42c63fb4d 100644
--- a/src/conf/domain_conf.c
+++ b/src/conf/domain_conf.c
@@ -27814,27 +27814,26 @@ virDomainDefFormatFeatures(virBufferPtr buf,
             break;

         case VIR_DOMAIN_FEATURE_SMM:
-            if (def->features[i] != VIR_TRISTATE_SWITCH_ABSENT) {
-                virTristateSwitch state = def->features[i];
-
-                virBufferAsprintf(&tmpAttrBuf, " state='%s'",
-                                  virTristateSwitchTypeToString(state));
+            if (def->features[i] == VIR_TRISTATE_SWITCH_ABSENT)
+                break;

-                if (state == VIR_TRISTATE_SWITCH_ON &&
-                    def->tseg_specified) {
-                    const char *unit;
-                    unsigned long long short_size = virFormatIntPretty(def->tseg_size,
-                                                                       &unit);
+            virBufferAsprintf(&tmpAttrBuf, " state='%s'",
+                              virTristateSwitchTypeToString(def->features[i]));

-                    virBufferSetChildIndent(&tmpChildBuf, buf);
-                    virBufferAsprintf(&tmpChildBuf, "<tseg unit='%s'>%llu</tseg>\n",
-                                      unit, short_size);
-                }
+            if (def->features[i] == VIR_TRISTATE_SWITCH_ON &&
+                def->tseg_specified) {
+                const char *unit;
+                unsigned long long short_size = virFormatIntPretty(def->tseg_size,
+                                                                   &unit);

-                if (virXMLFormatElement(buf, "smm", &tmpAttrBuf, &tmpChildBuf) < 0)
-                    return -1;
+                virBufferSetChildIndent(&tmpChildBuf, buf);
+                virBufferAsprintf(&tmpChildBuf, "<tseg unit='%s'>%llu</tseg>\n",
+                                  unit, short_size);
             }

+            if (virXMLFormatElement(buf, "smm", &tmpAttrBuf, &tmpChildBuf) < 0)
+                return -1;
+
             break;

         case VIR_DOMAIN_FEATURE_APIC:
-- 
2.20.1

--
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