From: Ján Tomko Date: Mon, 22 Aug 2016 15:45:18 +0000 (+0200) Subject: Use a separate buffer for X-Git-Tag: v3.3.0-rc1~76 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=8d704e6cf7da60156a0b25b165d4780e99a0fa2f;p=thirdparty%2Flibvirt.git Use a separate buffer for Format the attributes in a separate buffer and only print the element if it's not empty. --- diff --git a/src/conf/domain_conf.c b/src/conf/domain_conf.c index 97f00da9d3..61006dea7d 100644 --- a/src/conf/domain_conf.c +++ b/src/conf/domain_conf.c @@ -21388,6 +21388,7 @@ virDomainFSDefFormat(virBufferPtr buf, const char *fsdriver = virDomainFSDriverTypeToString(def->fsdriver); const char *wrpolicy = virDomainFSWrpolicyTypeToString(def->wrpolicy); const char *src = def->src->path; + virBuffer driverBuf = VIR_BUFFER_INITIALIZER; if (!type) { virReportError(VIR_ERR_INTERNAL_ERROR, @@ -21407,16 +21408,21 @@ virDomainFSDefFormat(virBufferPtr buf, type, accessmode); virBufferAdjustIndent(buf, 2); if (def->fsdriver) { - virBufferAsprintf(buf, "format) - virBufferAsprintf(buf, " format='%s'", + virBufferAsprintf(&driverBuf, " format='%s'", virStorageFileFormatTypeToString(def->format)); /* Don't generate anything if wrpolicy is set to default */ if (def->wrpolicy) - virBufferAsprintf(buf, " wrpolicy='%s'", wrpolicy); + virBufferAsprintf(&driverBuf, " wrpolicy='%s'", wrpolicy); + + } + if (virBufferUse(&driverBuf)) { + virBufferAddLit(buf, "\n"); }