On 06/10/2013 04:12 PM, Martin Kletzander wrote:
On 06/10/2013 02:10 PM, Ján Tomko wrote:
> Split out option string generation to make adding new options easier
> and simplify the code.
> ---
> src/storage/storage_backend.c | 111 ++++++++++++++++++++++--------------------
> 1 file changed, 59 insertions(+), 52 deletions(-)
> + if (imgformat == QEMU_IMG_BACKING_FORMAT_OPTIONS) {
> + if (virStorageBackendCreateQemuImgOpts(&opts,
> + backing ? backingType : NULL,
> + do_encryption, preallocate))
I guess we should use '< 0' here to unify the looks of it.
Other than that it's way more readable than the previous version, so ACK
with that fixed.
Martin
Thanks, I've squashed this in to prevent Coverity from complaining about
unused virBufferTrim's return value:
diff --git a/src/storage/storage_backend.c b/src/storage/storage_backend.c
index e7930ee..aa47871 100644
--- a/src/storage/storage_backend.c
+++ b/src/storage/storage_backend.c
@@ -643,9 +643,7 @@ virStorageBackendCreateQemuImgOpts(char **opts,
if (preallocate)
virBufferAddLit(&buf, "preallocation=metadata,");
- virBufferTrim(&buf, ",", -1);
-
- if (virBufferError(&buf)) {
+ if (virBufferTrim(&buf, ",", -1) < 0) {
virBufferFreeAndReset(&buf);
virReportOOMError();
return -1;
@@ -816,7 +814,7 @@ virStorageBackendCreateQemuImgCmd(virConnectPtr conn,
if (imgformat == QEMU_IMG_BACKING_FORMAT_OPTIONS) {
if (virStorageBackendCreateQemuImgOpts(&opts,
backing ? backingType : NULL,
- do_encryption, preallocate))
+ do_encryption, preallocate) < 0)
return NULL;
if (opts)
virCommandAddArgList(cmd, "-o", opts, NULL);