From: Peter Krempa Date: Tue, 5 Mar 2019 12:33:05 +0000 (+0100) Subject: conf: Avoid extra set of temp buffers in virDomainDefFormatFeatures X-Git-Url: http://xenbits.xensource.com/gitweb?a=commitdiff_plain;h=d1164bfdcaddcdf40bbf289c66d829b11692838a;p=libvirt.git conf: Avoid extra set of temp buffers in virDomainDefFormatFeatures Use the top level set of temp buffers to do the job. Signed-off-by: Peter Krempa Reviewed-by: Ján Tomko --- 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, "%llu\n", + virBufferSetChildIndent(&tmpChildBuf, buf); + virBufferAsprintf(&tmpChildBuf, "%llu\n", unit, short_size); } - if (virXMLFormatElement(buf, "smm", &attrBuf, &childBuf) < 0) + if (virXMLFormatElement(buf, "smm", &tmpAttrBuf, &tmpChildBuf) < 0) return -1; }