aboutsummaryrefslogtreecommitdiff
path: root/qemu-img.c
diff options
context:
space:
mode:
authorMarkus Armbruster <armbru@redhat.com>2015-12-18 16:35:14 +0100
committerMarkus Armbruster <armbru@redhat.com>2016-01-13 15:16:17 +0100
commitc29b77f955ff2f7b57c1e71e9dc26243eefd0b28 (patch)
treec76f9b9338d5a1cefef00917260242c4d04285c5 /qemu-img.c
parent8aa802a6b768e811e492c7404a58c52ecfb382ed (diff)
error: Use error_reportf_err() where it makes obvious sense
Done with this Coccinelle semantic patch @@ expression FMT, E, S; expression list ARGS; @@ - error_report(FMT, ARGS, error_get_pretty(E)); + error_reportf_err(E, FMT/*@@@*/, ARGS); ( - error_free(E); | exit(S); | abort(); ) followed by a replace of '%s"/*@@@*/' by '"' and some line rewrapping, because I can't figure out how to make Coccinelle transform strings. We now use the error whole instead of just its message obtained with error_get_pretty(). This avoids suppressing its hint (see commit 50b7b00), but I can't see how the errors touched in this commit could come with hints. Signed-off-by: Markus Armbruster <armbru@redhat.com> Message-Id: <1450452927-8346-12-git-send-email-armbru@redhat.com> Reviewed-by: Eric Blake <eblake@redhat.com>
Diffstat (limited to 'qemu-img.c')
-rw-r--r--qemu-img.c33
1 files changed, 13 insertions, 20 deletions
diff --git a/qemu-img.c b/qemu-img.c
index f4f5540b87..a5949e6b05 100644
--- a/qemu-img.c
+++ b/qemu-img.c
@@ -213,9 +213,7 @@ static BlockBackend *img_open(const char *id, const char *filename,
blk = blk_new_open(id, filename, NULL, options, flags, &local_err);
if (!blk) {
- error_report("Could not open '%s': %s", filename,
- error_get_pretty(local_err));
- error_free(local_err);
+ error_reportf_err(local_err, "Could not open '%s': ", filename);
goto fail;
}
@@ -360,8 +358,7 @@ static int img_create(int argc, char **argv)
bdrv_img_create(filename, fmt, base_filename, base_fmt,
options, img_size, BDRV_O_FLAGS, &local_err, quiet);
if (local_err) {
- error_report("%s: %s", filename, error_get_pretty(local_err));
- error_free(local_err);
+ error_reportf_err(local_err, "%s: ", filename);
goto fail;
}
@@ -1711,9 +1708,7 @@ static int img_convert(int argc, char **argv)
bdrv_snapshot_load_tmp_by_id_or_name(bs[0], snapshot_name, &local_err);
}
if (local_err) {
- error_report("Failed to load snapshot: %s",
- error_get_pretty(local_err));
- error_free(local_err);
+ error_reportf_err(local_err, "Failed to load snapshot: ");
ret = -1;
goto out;
}
@@ -1809,9 +1804,8 @@ static int img_convert(int argc, char **argv)
/* Create the new image */
ret = bdrv_create(drv, out_filename, opts, &local_err);
if (ret < 0) {
- error_report("%s: error while converting %s: %s",
- out_filename, out_fmt, error_get_pretty(local_err));
- error_free(local_err);
+ error_reportf_err(local_err, "%s: error while converting %s: ",
+ out_filename, out_fmt);
goto out;
}
}
@@ -2439,9 +2433,8 @@ static int img_snapshot(int argc, char **argv)
case SNAPSHOT_DELETE:
bdrv_snapshot_delete_by_id_or_name(bs, snapshot_name, &err);
if (err) {
- error_report("Could not delete snapshot '%s': %s",
- snapshot_name, error_get_pretty(err));
- error_free(err);
+ error_reportf_err(err, "Could not delete snapshot '%s': ",
+ snapshot_name);
ret = 1;
}
break;
@@ -2574,9 +2567,9 @@ static int img_rebase(int argc, char **argv)
blk_old_backing = blk_new_open("old_backing", backing_name, NULL,
options, src_flags, &local_err);
if (!blk_old_backing) {
- error_report("Could not open old backing file '%s': %s",
- backing_name, error_get_pretty(local_err));
- error_free(local_err);
+ error_reportf_err(local_err,
+ "Could not open old backing file '%s': ",
+ backing_name);
goto out;
}
@@ -2591,9 +2584,9 @@ static int img_rebase(int argc, char **argv)
blk_new_backing = blk_new_open("new_backing", out_baseimg, NULL,
options, src_flags, &local_err);
if (!blk_new_backing) {
- error_report("Could not open new backing file '%s': %s",
- out_baseimg, error_get_pretty(local_err));
- error_free(local_err);
+ error_reportf_err(local_err,
+ "Could not open new backing file '%s': ",
+ out_baseimg);
goto out;
}
}