[PATCH 1/9] domain_capabilities: use early return in virDomainCapsFeatureSEVFormat()

Kristina Hanicova khanicov at redhat.com
Wed Jul 20 13:11:04 UTC 2022


Signed-off-by: Kristina Hanicova <khanicov at redhat.com>
---
 src/conf/domain_capabilities.c | 33 ++++++++++++++++-----------------
 1 file changed, 16 insertions(+), 17 deletions(-)

diff --git a/src/conf/domain_capabilities.c b/src/conf/domain_capabilities.c
index 33570a51db..bb36a956db 100644
--- a/src/conf/domain_capabilities.c
+++ b/src/conf/domain_capabilities.c
@@ -590,25 +590,24 @@ virDomainCapsFeatureSEVFormat(virBuffer *buf,
 {
     if (!sev) {
         virBufferAddLit(buf, "<sev supported='no'/>\n");
-    } else {
-        virBufferAddLit(buf, "<sev supported='yes'>\n");
-        virBufferAdjustIndent(buf, 2);
-        virBufferAsprintf(buf, "<cbitpos>%d</cbitpos>\n", sev->cbitpos);
-        virBufferAsprintf(buf, "<reducedPhysBits>%d</reducedPhysBits>\n",
-                          sev->reduced_phys_bits);
-        virBufferAsprintf(buf, "<maxGuests>%d</maxGuests>\n",
-                          sev->max_guests);
-        virBufferAsprintf(buf, "<maxESGuests>%d</maxESGuests>\n",
-                          sev->max_es_guests);
-        if (sev->cpu0_id != NULL) {
-            virBufferAsprintf(buf, "<cpu0Id>%s</cpu0Id>\n",
-                              sev->cpu0_id);
-        }
-        virBufferAdjustIndent(buf, -2);
-        virBufferAddLit(buf, "</sev>\n");
+        return;
     }
 
-    return;
+    virBufferAddLit(buf, "<sev supported='yes'>\n");
+    virBufferAdjustIndent(buf, 2);
+    virBufferAsprintf(buf, "<cbitpos>%d</cbitpos>\n", sev->cbitpos);
+    virBufferAsprintf(buf, "<reducedPhysBits>%d</reducedPhysBits>\n",
+                      sev->reduced_phys_bits);
+    virBufferAsprintf(buf, "<maxGuests>%d</maxGuests>\n",
+                      sev->max_guests);
+    virBufferAsprintf(buf, "<maxESGuests>%d</maxESGuests>\n",
+                      sev->max_es_guests);
+    if (sev->cpu0_id != NULL) {
+        virBufferAsprintf(buf, "<cpu0Id>%s</cpu0Id>\n",
+                          sev->cpu0_id);
+    }
+    virBufferAdjustIndent(buf, -2);
+    virBufferAddLit(buf, "</sev>\n");
 }
 
 
-- 
2.35.3



More information about the libvir-list mailing list