Refactor the function to use modern XML formatting machinery.
Signed-off-by: Peter Krempa <pkrempa(a)redhat.com>
---
src/conf/domain_conf.c | 17 +++++------------
1 file changed, 5 insertions(+), 12 deletions(-)
diff --git a/src/conf/domain_conf.c b/src/conf/domain_conf.c
index b34513f943..4110109bd8 100644
--- a/src/conf/domain_conf.c
+++ b/src/conf/domain_conf.c
@@ -27125,22 +27125,15 @@ virDomainHugepagesFormat(virBuffer *buf,
virDomainHugePage *hugepages,
size_t nhugepages)
{
+ g_auto(virBuffer) childBuf = VIR_BUFFER_INIT_CHILD(buf);
size_t i;
- if (nhugepages == 1 &&
- hugepages[0].size == 0) {
- virBufferAddLit(buf, "<hugepages/>\n");
- return;
+ if (nhugepages != 1 || hugepages[0].size != 0) {
+ for (i = 0; i < nhugepages; i++)
+ virDomainHugepagesFormatBuf(&childBuf, &hugepages[i]);
}
- virBufferAddLit(buf, "<hugepages>\n");
- virBufferAdjustIndent(buf, 2);
-
- for (i = 0; i < nhugepages; i++)
- virDomainHugepagesFormatBuf(buf, &hugepages[i]);
-
- virBufferAdjustIndent(buf, -2);
- virBufferAddLit(buf, "</hugepages>\n");
+ virXMLFormatElementEmpty(buf, "hugepages", NULL, &childBuf);
}
--
2.35.3