Move it to a single location which also allows to get rid of the temporrary variable. Signed-off-by: Peter Krempa <pkrempa@xxxxxxxxxx> --- src/conf/domain_conf.c | 12 ++++-------- 1 file changed, 4 insertions(+), 8 deletions(-) diff --git a/src/conf/domain_conf.c b/src/conf/domain_conf.c index 4aa66fe09c..b77cc8ed9f 100644 --- a/src/conf/domain_conf.c +++ b/src/conf/domain_conf.c @@ -22806,29 +22806,22 @@ virDomainDiskSourceFormatInternal(virBufferPtr buf, bool skipSeclabels, virDomainXMLOptionPtr xmlopt) { - const char *startupPolicy = NULL; virBuffer attrBuf = VIR_BUFFER_INITIALIZER; virBuffer childBuf = VIR_BUFFER_INITIALIZER; virBufferSetChildIndent(&childBuf, buf); - if (policy) - startupPolicy = virDomainStartupPolicyTypeToString(policy); - switch ((virStorageType)src->type) { case VIR_STORAGE_TYPE_FILE: virBufferEscapeString(&attrBuf, " file='%s'", src->path); - virBufferEscapeString(&attrBuf, " startupPolicy='%s'", startupPolicy); break; case VIR_STORAGE_TYPE_BLOCK: virBufferEscapeString(&attrBuf, " dev='%s'", src->path); - virBufferEscapeString(&attrBuf, " startupPolicy='%s'", startupPolicy); break; case VIR_STORAGE_TYPE_DIR: virBufferEscapeString(&attrBuf, " dir='%s'", src->path); - virBufferEscapeString(&attrBuf, " startupPolicy='%s'", startupPolicy); break; case VIR_STORAGE_TYPE_NETWORK: @@ -22846,7 +22839,6 @@ virDomainDiskSourceFormatInternal(virBufferPtr buf, virBufferAsprintf(&attrBuf, " mode='%s'", virStorageSourcePoolModeTypeToString(src->srcpool->mode)); } - virBufferEscapeString(&attrBuf, " startupPolicy='%s'", startupPolicy); break; @@ -22858,6 +22850,10 @@ virDomainDiskSourceFormatInternal(virBufferPtr buf, } if (src->type != VIR_STORAGE_TYPE_NETWORK) { + if (policy) + virBufferEscapeString(&attrBuf, " startupPolicy='%s'", + virDomainStartupPolicyTypeToString(policy)); + if (!skipSeclabels) virDomainSourceDefFormatSeclabel(&childBuf, src->nseclabels, src->seclabels, flags); -- 2.16.2 -- libvir-list mailing list libvir-list@xxxxxxxxxx https://www.redhat.com/mailman/listinfo/libvir-list