[libvirt] [PATCH 16/23] conf: Avoid extra set of temp buffers in virDomainDefFormatFeatures

Peter Krempa pkrempa at redhat.com
Wed Mar 6 08:20:41 UTC 2019


Use the top level set of temp buffers to do the job.

Signed-off-by: Peter Krempa <pkrempa at redhat.com>
---
 src/conf/domain_conf.c | 10 ++++------
 1 file changed, 4 insertions(+), 6 deletions(-)

diff --git a/src/conf/domain_conf.c b/src/conf/domain_conf.c
index 605ae3667b..a1ed889e1d 100644
--- a/src/conf/domain_conf.c
+++ b/src/conf/domain_conf.c
@@ -27816,10 +27816,8 @@ virDomainDefFormatFeatures(virBufferPtr buf,
         case VIR_DOMAIN_FEATURE_SMM:
             if (def->features[i] != VIR_TRISTATE_SWITCH_ABSENT) {
                 virTristateSwitch state = def->features[i];
-                virBuffer attrBuf = VIR_BUFFER_INITIALIZER;
-                virBuffer childBuf = VIR_BUFFER_INITIALIZER;

-                virBufferAsprintf(&attrBuf, " state='%s'",
+                virBufferAsprintf(&tmpAttrBuf, " state='%s'",
                                   virTristateSwitchTypeToString(state));

                 if (state == VIR_TRISTATE_SWITCH_ON &&
@@ -27828,12 +27826,12 @@ virDomainDefFormatFeatures(virBufferPtr buf,
                     unsigned long long short_size = virFormatIntPretty(def->tseg_size,
                                                                        &unit);

-                    virBufferSetChildIndent(&childBuf, buf);
-                    virBufferAsprintf(&childBuf, "<tseg unit='%s'>%llu</tseg>\n",
+                    virBufferSetChildIndent(&tmpChildBuf, buf);
+                    virBufferAsprintf(&tmpChildBuf, "<tseg unit='%s'>%llu</tseg>\n",
                                       unit, short_size);
                 }

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

-- 
2.20.1




More information about the libvir-list mailing list