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>
This commit is contained in:
parent
8aa802a6b7
commit
c29b77f955
@ -258,9 +258,7 @@ void do_acpitable_option(const QemuOpts *opts)
|
||||
|
||||
acpi_table_add(opts, &err);
|
||||
if (err) {
|
||||
error_report("Wrong acpi table provided: %s",
|
||||
error_get_pretty(err));
|
||||
error_free(err);
|
||||
error_reportf_err(err, "Wrong acpi table provided: ");
|
||||
exit(1);
|
||||
}
|
||||
#endif
|
||||
|
@ -2405,9 +2405,8 @@ static int sd_snapshot_create(BlockDriverState *bs, QEMUSnapshotInfo *sn_info)
|
||||
|
||||
ret = do_sd_create(s, &new_vid, 1, &local_err);
|
||||
if (ret < 0) {
|
||||
error_report("failed to create inode for snapshot: %s",
|
||||
error_get_pretty(local_err));
|
||||
error_free(local_err);
|
||||
error_reportf_err(local_err,
|
||||
"failed to create inode for snapshot: ");
|
||||
goto cleanup;
|
||||
}
|
||||
|
||||
|
12
blockdev.c
12
blockdev.c
@ -1582,13 +1582,11 @@ static void internal_snapshot_abort(BlkActionState *common)
|
||||
}
|
||||
|
||||
if (bdrv_snapshot_delete(bs, sn->id_str, sn->name, &local_error) < 0) {
|
||||
error_report("Failed to delete snapshot with id '%s' and name '%s' on "
|
||||
"device '%s' in abort: %s",
|
||||
sn->id_str,
|
||||
sn->name,
|
||||
bdrv_get_device_name(bs),
|
||||
error_get_pretty(local_error));
|
||||
error_free(local_error);
|
||||
error_reportf_err(local_error,
|
||||
"Failed to delete snapshot with id '%s' and "
|
||||
"name '%s' on device '%s' in abort: ",
|
||||
sn->id_str, sn->name,
|
||||
bdrv_get_device_name(bs));
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -39,27 +39,26 @@ static void cubieboard_init(MachineState *machine)
|
||||
|
||||
object_property_set_int(OBJECT(&s->a10->emac), 1, "phy-addr", &err);
|
||||
if (err != NULL) {
|
||||
error_report("Couldn't set phy address: %s", error_get_pretty(err));
|
||||
error_reportf_err(err, "Couldn't set phy address: ");
|
||||
exit(1);
|
||||
}
|
||||
|
||||
object_property_set_int(OBJECT(&s->a10->timer), 32768, "clk0-freq", &err);
|
||||
if (err != NULL) {
|
||||
error_report("Couldn't set clk0 frequency: %s", error_get_pretty(err));
|
||||
error_reportf_err(err, "Couldn't set clk0 frequency: ");
|
||||
exit(1);
|
||||
}
|
||||
|
||||
object_property_set_int(OBJECT(&s->a10->timer), 24000000, "clk1-freq",
|
||||
&err);
|
||||
if (err != NULL) {
|
||||
error_report("Couldn't set clk1 frequency: %s", error_get_pretty(err));
|
||||
error_reportf_err(err, "Couldn't set clk1 frequency: ");
|
||||
exit(1);
|
||||
}
|
||||
|
||||
object_property_set_bool(OBJECT(s->a10), true, "realized", &err);
|
||||
if (err != NULL) {
|
||||
error_report("Couldn't realize Allwinner A10: %s",
|
||||
error_get_pretty(err));
|
||||
error_reportf_err(err, "Couldn't realize Allwinner A10: ");
|
||||
exit(1);
|
||||
}
|
||||
|
||||
|
@ -64,8 +64,7 @@ static void digic4_board_init(DigicBoard *board)
|
||||
s->digic = DIGIC(object_new(TYPE_DIGIC));
|
||||
object_property_set_bool(OBJECT(s->digic), true, "realized", &err);
|
||||
if (err != NULL) {
|
||||
error_report("Couldn't realize DIGIC SoC: %s",
|
||||
error_get_pretty(err));
|
||||
error_reportf_err(err, "Couldn't realize DIGIC SoC: ");
|
||||
exit(1);
|
||||
}
|
||||
|
||||
|
@ -1063,10 +1063,8 @@ static void qdev_prop_set_globals_for_type(DeviceState *dev,
|
||||
object_property_parse(OBJECT(dev), prop->value, prop->property, &err);
|
||||
if (err != NULL) {
|
||||
assert(prop->user_provided);
|
||||
error_report("Warning: global %s.%s=%s ignored: %s",
|
||||
prop->driver, prop->property, prop->value,
|
||||
error_get_pretty(err));
|
||||
error_free(err);
|
||||
error_reportf_err(err, "Warning: global %s.%s=%s ignored: ",
|
||||
prop->driver, prop->property, prop->value);
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
@ -370,9 +370,8 @@ void qdev_init_nofail(DeviceState *dev)
|
||||
|
||||
object_property_set_bool(OBJECT(dev), true, "realized", &err);
|
||||
if (err) {
|
||||
error_report("Initialization of device %s failed: %s",
|
||||
object_get_typename(OBJECT(dev)),
|
||||
error_get_pretty(err));
|
||||
error_reportf_err(err, "Initialization of device %s failed: ",
|
||||
object_get_typename(OBJECT(dev)));
|
||||
exit(1);
|
||||
}
|
||||
}
|
||||
|
@ -1253,9 +1253,8 @@ void pc_acpi_init(const char *default_dsdt)
|
||||
|
||||
acpi_table_add_builtin(opts, &err);
|
||||
if (err) {
|
||||
error_report("WARNING: failed to load %s: %s", filename,
|
||||
error_get_pretty(err));
|
||||
error_free(err);
|
||||
error_reportf_err(err, "WARNING: failed to load %s: ",
|
||||
filename);
|
||||
}
|
||||
g_free(filename);
|
||||
}
|
||||
|
@ -751,8 +751,8 @@ static qemu_irq *ppce500_init_mpic(MachineState *machine, PPCE500Params *params,
|
||||
dev = ppce500_init_mpic_kvm(params, irqs, &err);
|
||||
}
|
||||
if (machine_kernel_irqchip_required(machine) && !dev) {
|
||||
error_report("kernel_irqchip requested but unavailable: %s",
|
||||
error_get_pretty(err));
|
||||
error_reportf_err(err,
|
||||
"kernel_irqchip requested but unavailable: ");
|
||||
exit(1);
|
||||
}
|
||||
}
|
||||
|
@ -725,9 +725,8 @@ USBDevice *usbdevice_create(const char *cmdline)
|
||||
}
|
||||
object_property_set_bool(OBJECT(dev), true, "realized", &err);
|
||||
if (err) {
|
||||
error_report("Failed to initialize USB device '%s': %s",
|
||||
f->name, error_get_pretty(err));
|
||||
error_free(err);
|
||||
error_reportf_err(err, "Failed to initialize USB device '%s': ",
|
||||
f->name);
|
||||
object_unparent(OBJECT(dev));
|
||||
return NULL;
|
||||
}
|
||||
|
33
qemu-img.c
33
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;
|
||||
}
|
||||
}
|
||||
|
11
qemu-nbd.c
11
qemu-nbd.c
@ -495,8 +495,8 @@ int main(int argc, char **argv)
|
||||
BLOCKDEV_DETECT_ZEROES_OPTIONS_OFF,
|
||||
&local_err);
|
||||
if (local_err) {
|
||||
error_report("Failed to parse detect_zeroes mode: %s",
|
||||
error_get_pretty(local_err));
|
||||
error_reportf_err(local_err,
|
||||
"Failed to parse detect_zeroes mode: ");
|
||||
exit(EXIT_FAILURE);
|
||||
}
|
||||
if (detect_zeroes == BLOCKDEV_DETECT_ZEROES_OPTIONS_UNMAP &&
|
||||
@ -703,8 +703,8 @@ int main(int argc, char **argv)
|
||||
srcpath = argv[optind];
|
||||
blk = blk_new_open("hda", srcpath, NULL, options, flags, &local_err);
|
||||
if (!blk) {
|
||||
error_report("Failed to blk_new_open '%s': %s", argv[optind],
|
||||
error_get_pretty(local_err));
|
||||
error_reportf_err(local_err, "Failed to blk_new_open '%s': ",
|
||||
argv[optind]);
|
||||
exit(EXIT_FAILURE);
|
||||
}
|
||||
bs = blk_bs(blk);
|
||||
@ -719,8 +719,7 @@ int main(int argc, char **argv)
|
||||
&local_err);
|
||||
}
|
||||
if (ret < 0) {
|
||||
error_report("Failed to load snapshot: %s",
|
||||
error_get_pretty(local_err));
|
||||
error_reportf_err(local_err, "Failed to load snapshot: ");
|
||||
exit(EXIT_FAILURE);
|
||||
}
|
||||
|
||||
|
@ -291,8 +291,7 @@ void replay_start(void)
|
||||
}
|
||||
|
||||
if (replay_blockers) {
|
||||
error_report("Record/replay: %s",
|
||||
error_get_pretty(replay_blockers->data));
|
||||
error_reportf_err(replay_blockers->data, "Record/replay: ");
|
||||
exit(1);
|
||||
}
|
||||
if (!use_icount) {
|
||||
|
@ -832,9 +832,7 @@ int main(int argc, char **argv)
|
||||
|
||||
ctx = aio_context_new(&local_error);
|
||||
if (!ctx) {
|
||||
error_report("Failed to create AIO Context: %s",
|
||||
error_get_pretty(local_error));
|
||||
error_free(local_error);
|
||||
error_reportf_err(local_error, "Failed to create AIO Context: ");
|
||||
exit(1);
|
||||
}
|
||||
src = aio_get_g_source(ctx);
|
||||
|
@ -229,9 +229,7 @@ int main(int argc, char **argv)
|
||||
|
||||
ctx = aio_context_new(&local_error);
|
||||
if (!ctx) {
|
||||
error_report("Failed to create AIO Context: %s",
|
||||
error_get_pretty(local_error));
|
||||
error_free(local_error);
|
||||
error_reportf_err(local_error, "Failed to create AIO Context: ");
|
||||
exit(1);
|
||||
}
|
||||
pool = aio_get_thread_pool(ctx);
|
||||
|
4
ui/vnc.c
4
ui/vnc.c
@ -3861,9 +3861,7 @@ int vnc_init_func(void *opaque, QemuOpts *opts, Error **errp)
|
||||
vnc_display_init(id);
|
||||
vnc_display_open(id, &local_err);
|
||||
if (local_err != NULL) {
|
||||
error_report("Failed to start VNC server: %s",
|
||||
error_get_pretty(local_err));
|
||||
error_free(local_err);
|
||||
error_reportf_err(local_err, "Failed to start VNC server: ");
|
||||
exit(1);
|
||||
}
|
||||
return 0;
|
||||
|
6
vl.c
6
vl.c
@ -3043,7 +3043,7 @@ int main(int argc, char **argv, char **envp)
|
||||
runstate_init();
|
||||
|
||||
if (qcrypto_init(&err) < 0) {
|
||||
error_report("cannot initialize crypto: %s", error_get_pretty(err));
|
||||
error_reportf_err(err, "cannot initialize crypto: ");
|
||||
exit(1);
|
||||
}
|
||||
rtc_clock = QEMU_CLOCK_HOST;
|
||||
@ -4649,9 +4649,7 @@ int main(int argc, char **argv, char **envp)
|
||||
Error *local_err = NULL;
|
||||
qemu_start_incoming_migration(incoming, &local_err);
|
||||
if (local_err) {
|
||||
error_report("-incoming %s: %s", incoming,
|
||||
error_get_pretty(local_err));
|
||||
error_free(local_err);
|
||||
error_reportf_err(local_err, "-incoming %s: ", incoming);
|
||||
exit(1);
|
||||
}
|
||||
} else if (autostart) {
|
||||
|
Loading…
Reference in New Issue
Block a user