diff options
Diffstat (limited to 'qemu-img.c')
-rw-r--r-- | qemu-img.c | 31 |
1 files changed, 8 insertions, 23 deletions
diff --git a/qemu-img.c b/qemu-img.c index 53bd32bf8f..498fbf42fe 100644 --- a/qemu-img.c +++ b/qemu-img.c @@ -465,23 +465,18 @@ static int add_old_style_options(const char *fmt, QemuOpts *opts, const char *base_filename, const char *base_fmt) { - Error *err = NULL; - if (base_filename) { - qemu_opt_set(opts, BLOCK_OPT_BACKING_FILE, base_filename, &err); - if (err) { + if (!qemu_opt_set(opts, BLOCK_OPT_BACKING_FILE, base_filename, + NULL)) { error_report("Backing file not supported for file format '%s'", fmt); - error_free(err); return -1; } } if (base_fmt) { - qemu_opt_set(opts, BLOCK_OPT_BACKING_FMT, base_fmt, &err); - if (err) { + if (!qemu_opt_set(opts, BLOCK_OPT_BACKING_FMT, base_fmt, NULL)) { error_report("Backing file format not supported for file " "format '%s'", fmt); - error_free(err); return -1; } } @@ -2487,8 +2482,7 @@ static int img_convert(int argc, char **argv) opts = qemu_opts_create(create_opts, NULL, 0, &error_abort); if (options) { - qemu_opts_do_parse(opts, options, NULL, &local_err); - if (local_err) { + if (!qemu_opts_do_parse(opts, options, NULL, &local_err)) { error_report_err(local_err); ret = -1; goto out; @@ -3963,8 +3957,7 @@ static int img_resize(int argc, char **argv) /* Parse size */ param = qemu_opts_create(&resize_options, NULL, 0, &error_abort); - qemu_opt_set(param, BLOCK_OPT_SIZE, size, &err); - if (err) { + if (!qemu_opt_set(param, BLOCK_OPT_SIZE, size, &err)) { error_report_err(err); ret = -1; qemu_opts_del(param); @@ -4215,21 +4208,14 @@ static int img_amend(int argc, char **argv) amend_opts = qemu_opts_append(amend_opts, bs->drv->amend_opts); opts = qemu_opts_create(amend_opts, NULL, 0, &error_abort); - qemu_opts_do_parse(opts, options, NULL, &err); - - if (err) { + if (!qemu_opts_do_parse(opts, options, NULL, &err)) { /* Try to parse options using the create options */ - Error *err1 = NULL; amend_opts = qemu_opts_append(amend_opts, bs->drv->create_opts); qemu_opts_del(opts); opts = qemu_opts_create(amend_opts, NULL, 0, &error_abort); - qemu_opts_do_parse(opts, options, NULL, &err1); - - if (!err1) { + if (qemu_opts_do_parse(opts, options, NULL, NULL)) { error_append_hint(&err, "This option is only supported for image creation\n"); - } else { - error_free(err1); } error_report_err(err); @@ -5363,8 +5349,7 @@ static int img_measure(int argc, char **argv) create_opts = qemu_opts_append(create_opts, bdrv_file.create_opts); opts = qemu_opts_create(create_opts, NULL, 0, &error_abort); if (options) { - qemu_opts_do_parse(opts, options, NULL, &local_err); - if (local_err) { + if (!qemu_opts_do_parse(opts, options, NULL, &local_err)) { error_report_err(local_err); error_report("Invalid options for file format '%s'", out_fmt); goto out; |