From 22bf0d340df32aac9efb1c8a0fbd8843485a13a3 Mon Sep 17 00:00:00 2001 Message-Id: <22bf0d340df32aac9efb1c8a0fbd8843485a13a3@dist-git> From: Peter Krempa Date: Wed, 26 Feb 2014 14:54:44 +0100 Subject: [PATCH] conf: Clean up virDomainDiskSourceDefFormatInternal https://bugzilla.redhat.com/show_bug.cgi?id=1032370 Avoid if statements when used with virBufferEscapeString which automaticaly omits the whole string. Also add some line breaks to visualy separate the code. (cherry picked from commit 03ad83cb5a32d62a71075716139356a4fcc9972b) Signed-off-by: Jiri Denemark --- src/conf/domain_conf.c | 48 ++++++++++++++++++++---------------------------- 1 file changed, 20 insertions(+), 28 deletions(-) diff --git a/src/conf/domain_conf.c b/src/conf/domain_conf.c index 7032b2b..bba6201 100644 --- a/src/conf/domain_conf.c +++ b/src/conf/domain_conf.c @@ -14485,53 +14485,49 @@ virDomainDiskSourceDefFormatInternal(virBufferPtr buf, switch (type) { case VIR_DOMAIN_DISK_TYPE_FILE: virBufferAddLit(buf, " \n"); virBufferAdjustIndent(buf, 8); for (n = 0; n < nseclabels; n++) - virSecurityDeviceLabelDefFormat(buf, seclabels[n], - flags); + virSecurityDeviceLabelDefFormat(buf, seclabels[n], flags); virBufferAdjustIndent(buf, -8); virBufferAddLit(buf, " \n"); } else { virBufferAddLit(buf, "/>\n"); } break; + case VIR_DOMAIN_DISK_TYPE_BLOCK: virBufferAddLit(buf, " \n"); virBufferAdjustIndent(buf, 8); for (n = 0; n < nseclabels; n++) - virSecurityDeviceLabelDefFormat(buf, seclabels[n], - flags); + virSecurityDeviceLabelDefFormat(buf, seclabels[n], flags); virBufferAdjustIndent(buf, -8); virBufferAddLit(buf, " \n"); } else { virBufferAddLit(buf, "/>\n"); } break; + case VIR_DOMAIN_DISK_TYPE_DIR: - virBufferEscapeString(buf, " \n"); break; + case VIR_DOMAIN_DISK_TYPE_NETWORK: virBufferAsprintf(buf, " \n"); @@ -14539,25 +14535,21 @@ virDomainDiskSourceDefFormatInternal(virBufferPtr buf, virBufferAddLit(buf, ">\n"); for (n = 0; n < nhosts; n++) { virBufferAddLit(buf, " \n"); } virBufferAddLit(buf, " \n"); } break; + case VIR_DOMAIN_DISK_TYPE_VOLUME: virBufferAddLit(buf, " mode)); } - if (startupPolicy) - virBufferEscapeString(buf, " startupPolicy='%s'", startupPolicy); + virBufferEscapeString(buf, " startupPolicy='%s'", startupPolicy); if (nseclabels) { virBufferAddLit(buf, ">\n"); @@ -14583,6 +14574,7 @@ virDomainDiskSourceDefFormatInternal(virBufferPtr buf, virBufferAddLit(buf, "/>\n"); } break; + default: virReportError(VIR_ERR_INTERNAL_ERROR, _("unexpected disk type %s"), -- 1.9.0