[libvirt] [PATCH] xenFormatXLDisk: Fix commas for arguments

instead of: virBufferAdd(buf, "arg1,"); virBufferAdd(buf, "arg2"); lets have: virBufferAdd(buf, "arg1"); virBufferAdd(buf, ",arg2"); Signed-off-by: Michal Privoznik <mprivozn@redhat.com> --- src/xenconfig/xen_xl.c | 32 ++++++++++++++++---------------- 1 file changed, 16 insertions(+), 16 deletions(-) diff --git a/src/xenconfig/xen_xl.c b/src/xenconfig/xen_xl.c index 742f1ef..337f9dd 100644 --- a/src/xenconfig/xen_xl.c +++ b/src/xenconfig/xen_xl.c @@ -1022,33 +1022,33 @@ xenFormatXLDisk(virConfValuePtr list, virDomainDiskDefPtr disk) virBufferAddLit(&buf, "format="); switch (format) { case VIR_STORAGE_FILE_RAW: - virBufferAddLit(&buf, "raw,"); + virBufferAddLit(&buf, "raw"); break; case VIR_STORAGE_FILE_VHD: - virBufferAddLit(&buf, "xvhd,"); + virBufferAddLit(&buf, "xvhd"); break; case VIR_STORAGE_FILE_QCOW: - virBufferAddLit(&buf, "qcow,"); + virBufferAddLit(&buf, "qcow"); break; case VIR_STORAGE_FILE_QCOW2: - virBufferAddLit(&buf, "qcow2,"); + virBufferAddLit(&buf, "qcow2"); break; /* set default */ default: - virBufferAddLit(&buf, "raw,"); + virBufferAddLit(&buf, "raw"); } /* device */ - virBufferAsprintf(&buf, "vdev=%s,", disk->dst); + virBufferAsprintf(&buf, ",vdev=%s", disk->dst); /* access */ - virBufferAddLit(&buf, "access="); + virBufferAddLit(&buf, ",access="); if (disk->src->readonly) - virBufferAddLit(&buf, "ro,"); + virBufferAddLit(&buf, "ro"); else if (disk->src->shared) - virBufferAddLit(&buf, "!,"); + virBufferAddLit(&buf, "!"); else - virBufferAddLit(&buf, "rw,"); + virBufferAddLit(&buf, "rw"); if (disk->transient) { virReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s", _("transient disks not supported yet")); @@ -1057,18 +1057,18 @@ xenFormatXLDisk(virConfValuePtr list, virDomainDiskDefPtr disk) /* backendtype */ if (driver) { - virBufferAddLit(&buf, "backendtype="); + virBufferAddLit(&buf, ",backendtype="); if (STREQ(driver, "qemu") || STREQ(driver, "file")) - virBufferAddLit(&buf, "qdisk,"); + virBufferAddLit(&buf, "qdisk"); else if (STREQ(driver, "tap")) - virBufferAddLit(&buf, "tap,"); + virBufferAddLit(&buf, "tap"); else if (STREQ(driver, "phy")) - virBufferAddLit(&buf, "phy,"); + virBufferAddLit(&buf, "phy"); } /* devtype */ if (disk->device == VIR_DOMAIN_DISK_DEVICE_CDROM) - virBufferAddLit(&buf, "devtype=cdrom,"); + virBufferAddLit(&buf, ",devtype=cdrom"); /* * target @@ -1082,7 +1082,7 @@ xenFormatXLDisk(virConfValuePtr list, virDomainDiskDefPtr disk) goto cleanup; if (target) - virBufferAsprintf(&buf, "target=%s", target); + virBufferAsprintf(&buf, ",target=%s", target); if (virBufferCheckError(&buf) < 0) goto cleanup; -- 2.8.4

On 20.10.2016 22:27, Ján Tomko wrote:
On Thu, Oct 20, 2016 at 10:16:05PM +0800, Michal Privoznik wrote:
instead of:
virBufferAdd(buf, "arg1,"); virBufferAdd(buf, "arg2");
lets have:
virBufferAdd(buf, "arg1"); virBufferAdd(buf, ",arg2");
Why?
Because it's better. Consider we want to add conditionally arg3. With my change, it's simple: if (cond) virBufferAdd(buf, ",arg3"); with current code there might be a comma hanging at EOL. Michal

On Thu, Oct 20, 2016 at 11:05:36PM +0800, Michal Privoznik wrote:
On 20.10.2016 22:27, Ján Tomko wrote:
On Thu, Oct 20, 2016 at 10:16:05PM +0800, Michal Privoznik wrote:
instead of:
virBufferAdd(buf, "arg1,"); virBufferAdd(buf, "arg2");
lets have:
virBufferAdd(buf, "arg1"); virBufferAdd(buf, ",arg2");
Why?
Because it's better. Consider we want to add conditionally arg3. With my change, it's simple:
if (cond) virBufferAdd(buf, ",arg3");
with current code there might be a comma hanging at EOL.
ACK with the explanation included in the commit message. Please substitute the 'Fix' in the summary for something that does not imply a functional change. Jan
participants (2)
-
Ján Tomko
-
Michal Privoznik