@@ -3031,7 +3031,7 @@ static int qcow2_create(const char *filename, QemuOpts *opts, Error **errp)
int refcount_order;
const char *encryptfmt = NULL;
Error *local_err = NULL;
- int ret;
+ int ret = -EINVAL;
/* Read out options */
size = ROUND_UP(qemu_opt_get_size_del(opts, BLOCK_OPT_SIZE, 0),
@@ -3043,7 +3043,6 @@ static int qcow2_create(const char *filename, QemuOpts *opts, Error **errp)
if (qemu_opt_get_del(opts, BLOCK_OPT_ENCRYPT)) {
error_setg(errp, "Options " BLOCK_OPT_ENCRYPT " and "
BLOCK_OPT_ENCRYPT_FORMAT " are mutually exclusive");
- ret = -EINVAL;
goto finish;
}
} else if (qemu_opt_get_bool_del(opts, BLOCK_OPT_ENCRYPT, false)) {
@@ -3052,7 +3051,6 @@ static int qcow2_create(const char *filename, QemuOpts *opts, Error **errp)
cluster_size = qcow2_opt_get_cluster_size_del(opts, &local_err);
if (local_err) {
error_propagate(errp, local_err);
- ret = -EINVAL;
goto finish;
}
buf = qemu_opt_get_del(opts, BLOCK_OPT_PREALLOC);
@@ -3061,14 +3059,12 @@ static int qcow2_create(const char *filename, QemuOpts *opts, Error **errp)
&local_err);
if (local_err) {
error_propagate(errp, local_err);
- ret = -EINVAL;
goto finish;
}
version = qcow2_opt_get_version_del(opts, &local_err);
if (local_err) {
error_propagate(errp, local_err);
- ret = -EINVAL;
goto finish;
}
@@ -3079,21 +3075,18 @@ static int qcow2_create(const char *filename, QemuOpts *opts, Error **errp)
if (backing_file && prealloc != PREALLOC_MODE_OFF) {
error_setg(errp, "Backing file and preallocation cannot be used at "
"the same time");
- ret = -EINVAL;
goto finish;
}
if (version < 3 && (flags & BLOCK_FLAG_LAZY_REFCOUNTS)) {
error_setg(errp, "Lazy refcounts only supported with compatibility "
"level 1.1 and above (use compat=1.1 or greater)");
- ret = -EINVAL;
goto finish;
}
refcount_bits = qcow2_opt_get_refcount_bits_del(opts, version, &local_err);
if (local_err) {
error_propagate(errp, local_err);
- ret = -EINVAL;
goto finish;
}
@@ -3110,13 +3103,11 @@ static int qcow2_create(const char *filename, QemuOpts *opts, Error **errp)
visit_start_struct(v, NULL, NULL, 0, &local_err);
if (local_err) {
error_propagate(errp, local_err);
- ret = -EINVAL;
goto finish;
}
visit_type_Qcow2Compress_members(v, &compress, &local_err);
if (local_err) {
error_propagate(errp, local_err);
- ret = -EINVAL;
goto finish;
}
visit_end_struct(v, NULL);
@@ -3126,12 +3117,12 @@ static int qcow2_create(const char *filename, QemuOpts *opts, Error **errp)
qcow2_check_compress_settings(&compress, &local_err);
if (local_err) {
error_propagate(errp, local_err);
- ret = -EINVAL;
goto finish;
}
compress_ptr = &compress;
}
+ /* ret is still -EINVAL until here */
ret = qcow2_create2(filename, size, backing_file, backing_fmt, flags,
cluster_size, prealloc, opts, version, refcount_order,
encryptfmt, compress_ptr, &local_err);
Signed-off-by: Peter Lieven <pl@kamp.de> --- block/qcow2.c | 13 ++----------- 1 file changed, 2 insertions(+), 11 deletions(-)