[PATCH v1 09/26] virDomainMemoryTargetDefFormat: Utilize virXMLFormatElement()

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

 



The virDomainMemoryTargetDefFormat() uses good old style of
formatting child buffer (virBufferAdjustIndent()). When switched
to virXMLFormatElement() we can save a couple of lines

Signed-off-by: Michal Privoznik <mprivozn@xxxxxxxxxx>
---
 src/conf/domain_conf.c | 21 +++++++++------------
 1 file changed, 9 insertions(+), 12 deletions(-)

diff --git a/src/conf/domain_conf.c b/src/conf/domain_conf.c
index 8f10fe14d3..c4da972f1a 100644
--- a/src/conf/domain_conf.c
+++ b/src/conf/domain_conf.c
@@ -27920,24 +27920,21 @@ static void
 virDomainMemoryTargetDefFormat(virBufferPtr buf,
                                virDomainMemoryDefPtr def)
 {
-    virBufferAddLit(buf, "<target>\n");
-    virBufferAdjustIndent(buf, 2);
+    g_auto(virBuffer) childBuf = VIR_BUFFER_INIT_CHILD(buf);
 
-    virBufferAsprintf(buf, "<size unit='KiB'>%llu</size>\n", def->size);
+    virBufferAsprintf(&childBuf, "<size unit='KiB'>%llu</size>\n", def->size);
     if (def->targetNode >= 0)
-        virBufferAsprintf(buf, "<node>%d</node>\n", def->targetNode);
+        virBufferAsprintf(&childBuf, "<node>%d</node>\n", def->targetNode);
     if (def->labelsize) {
-        virBufferAddLit(buf, "<label>\n");
-        virBufferAdjustIndent(buf, 2);
-        virBufferAsprintf(buf, "<size unit='KiB'>%llu</size>\n", def->labelsize);
-        virBufferAdjustIndent(buf, -2);
-        virBufferAddLit(buf, "</label>\n");
+        g_auto(virBuffer) labelChildBuf = VIR_BUFFER_INIT_CHILD(&childBuf);
+
+        virBufferAsprintf(&labelChildBuf, "<size unit='KiB'>%llu</size>\n", def->labelsize);
+        virXMLFormatElement(&childBuf, "label", NULL, &labelChildBuf);
     }
     if (def->readonly)
-        virBufferAddLit(buf, "<readonly/>\n");
+        virBufferAddLit(&childBuf, "<readonly/>\n");
 
-    virBufferAdjustIndent(buf, -2);
-    virBufferAddLit(buf, "</target>\n");
+    virXMLFormatElement(buf, "target", NULL, &childBuf);
 }
 
 static int
-- 
2.26.2




[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