mirror of
https://github.com/xemu-project/xemu.git
synced 2024-11-27 05:20:50 +00:00
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);
|
acpi_table_add(opts, &err);
|
||||||
if (err) {
|
if (err) {
|
||||||
error_report("Wrong acpi table provided: %s",
|
error_reportf_err(err, "Wrong acpi table provided: ");
|
||||||
error_get_pretty(err));
|
|
||||||
error_free(err);
|
|
||||||
exit(1);
|
exit(1);
|
||||||
}
|
}
|
||||||
#endif
|
#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);
|
ret = do_sd_create(s, &new_vid, 1, &local_err);
|
||||||
if (ret < 0) {
|
if (ret < 0) {
|
||||||
error_report("failed to create inode for snapshot: %s",
|
error_reportf_err(local_err,
|
||||||
error_get_pretty(local_err));
|
"failed to create inode for snapshot: ");
|
||||||
error_free(local_err);
|
|
||||||
goto cleanup;
|
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) {
|
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 "
|
error_reportf_err(local_error,
|
||||||
"device '%s' in abort: %s",
|
"Failed to delete snapshot with id '%s' and "
|
||||||
sn->id_str,
|
"name '%s' on device '%s' in abort: ",
|
||||||
sn->name,
|
sn->id_str, sn->name,
|
||||||
bdrv_get_device_name(bs),
|
bdrv_get_device_name(bs));
|
||||||
error_get_pretty(local_error));
|
|
||||||
error_free(local_error);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -39,27 +39,26 @@ static void cubieboard_init(MachineState *machine)
|
|||||||
|
|
||||||
object_property_set_int(OBJECT(&s->a10->emac), 1, "phy-addr", &err);
|
object_property_set_int(OBJECT(&s->a10->emac), 1, "phy-addr", &err);
|
||||||
if (err != NULL) {
|
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);
|
exit(1);
|
||||||
}
|
}
|
||||||
|
|
||||||
object_property_set_int(OBJECT(&s->a10->timer), 32768, "clk0-freq", &err);
|
object_property_set_int(OBJECT(&s->a10->timer), 32768, "clk0-freq", &err);
|
||||||
if (err != NULL) {
|
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);
|
exit(1);
|
||||||
}
|
}
|
||||||
|
|
||||||
object_property_set_int(OBJECT(&s->a10->timer), 24000000, "clk1-freq",
|
object_property_set_int(OBJECT(&s->a10->timer), 24000000, "clk1-freq",
|
||||||
&err);
|
&err);
|
||||||
if (err != NULL) {
|
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);
|
exit(1);
|
||||||
}
|
}
|
||||||
|
|
||||||
object_property_set_bool(OBJECT(s->a10), true, "realized", &err);
|
object_property_set_bool(OBJECT(s->a10), true, "realized", &err);
|
||||||
if (err != NULL) {
|
if (err != NULL) {
|
||||||
error_report("Couldn't realize Allwinner A10: %s",
|
error_reportf_err(err, "Couldn't realize Allwinner A10: ");
|
||||||
error_get_pretty(err));
|
|
||||||
exit(1);
|
exit(1);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -64,8 +64,7 @@ static void digic4_board_init(DigicBoard *board)
|
|||||||
s->digic = DIGIC(object_new(TYPE_DIGIC));
|
s->digic = DIGIC(object_new(TYPE_DIGIC));
|
||||||
object_property_set_bool(OBJECT(s->digic), true, "realized", &err);
|
object_property_set_bool(OBJECT(s->digic), true, "realized", &err);
|
||||||
if (err != NULL) {
|
if (err != NULL) {
|
||||||
error_report("Couldn't realize DIGIC SoC: %s",
|
error_reportf_err(err, "Couldn't realize DIGIC SoC: ");
|
||||||
error_get_pretty(err));
|
|
||||||
exit(1);
|
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);
|
object_property_parse(OBJECT(dev), prop->value, prop->property, &err);
|
||||||
if (err != NULL) {
|
if (err != NULL) {
|
||||||
assert(prop->user_provided);
|
assert(prop->user_provided);
|
||||||
error_report("Warning: global %s.%s=%s ignored: %s",
|
error_reportf_err(err, "Warning: global %s.%s=%s ignored: ",
|
||||||
prop->driver, prop->property, prop->value,
|
prop->driver, prop->property, prop->value);
|
||||||
error_get_pretty(err));
|
|
||||||
error_free(err);
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -370,9 +370,8 @@ void qdev_init_nofail(DeviceState *dev)
|
|||||||
|
|
||||||
object_property_set_bool(OBJECT(dev), true, "realized", &err);
|
object_property_set_bool(OBJECT(dev), true, "realized", &err);
|
||||||
if (err) {
|
if (err) {
|
||||||
error_report("Initialization of device %s failed: %s",
|
error_reportf_err(err, "Initialization of device %s failed: ",
|
||||||
object_get_typename(OBJECT(dev)),
|
object_get_typename(OBJECT(dev)));
|
||||||
error_get_pretty(err));
|
|
||||||
exit(1);
|
exit(1);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1253,9 +1253,8 @@ void pc_acpi_init(const char *default_dsdt)
|
|||||||
|
|
||||||
acpi_table_add_builtin(opts, &err);
|
acpi_table_add_builtin(opts, &err);
|
||||||
if (err) {
|
if (err) {
|
||||||
error_report("WARNING: failed to load %s: %s", filename,
|
error_reportf_err(err, "WARNING: failed to load %s: ",
|
||||||
error_get_pretty(err));
|
filename);
|
||||||
error_free(err);
|
|
||||||
}
|
}
|
||||||
g_free(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);
|
dev = ppce500_init_mpic_kvm(params, irqs, &err);
|
||||||
}
|
}
|
||||||
if (machine_kernel_irqchip_required(machine) && !dev) {
|
if (machine_kernel_irqchip_required(machine) && !dev) {
|
||||||
error_report("kernel_irqchip requested but unavailable: %s",
|
error_reportf_err(err,
|
||||||
error_get_pretty(err));
|
"kernel_irqchip requested but unavailable: ");
|
||||||
exit(1);
|
exit(1);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -725,9 +725,8 @@ USBDevice *usbdevice_create(const char *cmdline)
|
|||||||
}
|
}
|
||||||
object_property_set_bool(OBJECT(dev), true, "realized", &err);
|
object_property_set_bool(OBJECT(dev), true, "realized", &err);
|
||||||
if (err) {
|
if (err) {
|
||||||
error_report("Failed to initialize USB device '%s': %s",
|
error_reportf_err(err, "Failed to initialize USB device '%s': ",
|
||||||
f->name, error_get_pretty(err));
|
f->name);
|
||||||
error_free(err);
|
|
||||||
object_unparent(OBJECT(dev));
|
object_unparent(OBJECT(dev));
|
||||||
return NULL;
|
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);
|
blk = blk_new_open(id, filename, NULL, options, flags, &local_err);
|
||||||
if (!blk) {
|
if (!blk) {
|
||||||
error_report("Could not open '%s': %s", filename,
|
error_reportf_err(local_err, "Could not open '%s': ", filename);
|
||||||
error_get_pretty(local_err));
|
|
||||||
error_free(local_err);
|
|
||||||
goto fail;
|
goto fail;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -360,8 +358,7 @@ static int img_create(int argc, char **argv)
|
|||||||
bdrv_img_create(filename, fmt, base_filename, base_fmt,
|
bdrv_img_create(filename, fmt, base_filename, base_fmt,
|
||||||
options, img_size, BDRV_O_FLAGS, &local_err, quiet);
|
options, img_size, BDRV_O_FLAGS, &local_err, quiet);
|
||||||
if (local_err) {
|
if (local_err) {
|
||||||
error_report("%s: %s", filename, error_get_pretty(local_err));
|
error_reportf_err(local_err, "%s: ", filename);
|
||||||
error_free(local_err);
|
|
||||||
goto fail;
|
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);
|
bdrv_snapshot_load_tmp_by_id_or_name(bs[0], snapshot_name, &local_err);
|
||||||
}
|
}
|
||||||
if (local_err) {
|
if (local_err) {
|
||||||
error_report("Failed to load snapshot: %s",
|
error_reportf_err(local_err, "Failed to load snapshot: ");
|
||||||
error_get_pretty(local_err));
|
|
||||||
error_free(local_err);
|
|
||||||
ret = -1;
|
ret = -1;
|
||||||
goto out;
|
goto out;
|
||||||
}
|
}
|
||||||
@ -1809,9 +1804,8 @@ static int img_convert(int argc, char **argv)
|
|||||||
/* Create the new image */
|
/* Create the new image */
|
||||||
ret = bdrv_create(drv, out_filename, opts, &local_err);
|
ret = bdrv_create(drv, out_filename, opts, &local_err);
|
||||||
if (ret < 0) {
|
if (ret < 0) {
|
||||||
error_report("%s: error while converting %s: %s",
|
error_reportf_err(local_err, "%s: error while converting %s: ",
|
||||||
out_filename, out_fmt, error_get_pretty(local_err));
|
out_filename, out_fmt);
|
||||||
error_free(local_err);
|
|
||||||
goto out;
|
goto out;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -2439,9 +2433,8 @@ static int img_snapshot(int argc, char **argv)
|
|||||||
case SNAPSHOT_DELETE:
|
case SNAPSHOT_DELETE:
|
||||||
bdrv_snapshot_delete_by_id_or_name(bs, snapshot_name, &err);
|
bdrv_snapshot_delete_by_id_or_name(bs, snapshot_name, &err);
|
||||||
if (err) {
|
if (err) {
|
||||||
error_report("Could not delete snapshot '%s': %s",
|
error_reportf_err(err, "Could not delete snapshot '%s': ",
|
||||||
snapshot_name, error_get_pretty(err));
|
snapshot_name);
|
||||||
error_free(err);
|
|
||||||
ret = 1;
|
ret = 1;
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
@ -2574,9 +2567,9 @@ static int img_rebase(int argc, char **argv)
|
|||||||
blk_old_backing = blk_new_open("old_backing", backing_name, NULL,
|
blk_old_backing = blk_new_open("old_backing", backing_name, NULL,
|
||||||
options, src_flags, &local_err);
|
options, src_flags, &local_err);
|
||||||
if (!blk_old_backing) {
|
if (!blk_old_backing) {
|
||||||
error_report("Could not open old backing file '%s': %s",
|
error_reportf_err(local_err,
|
||||||
backing_name, error_get_pretty(local_err));
|
"Could not open old backing file '%s': ",
|
||||||
error_free(local_err);
|
backing_name);
|
||||||
goto out;
|
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,
|
blk_new_backing = blk_new_open("new_backing", out_baseimg, NULL,
|
||||||
options, src_flags, &local_err);
|
options, src_flags, &local_err);
|
||||||
if (!blk_new_backing) {
|
if (!blk_new_backing) {
|
||||||
error_report("Could not open new backing file '%s': %s",
|
error_reportf_err(local_err,
|
||||||
out_baseimg, error_get_pretty(local_err));
|
"Could not open new backing file '%s': ",
|
||||||
error_free(local_err);
|
out_baseimg);
|
||||||
goto out;
|
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,
|
BLOCKDEV_DETECT_ZEROES_OPTIONS_OFF,
|
||||||
&local_err);
|
&local_err);
|
||||||
if (local_err) {
|
if (local_err) {
|
||||||
error_report("Failed to parse detect_zeroes mode: %s",
|
error_reportf_err(local_err,
|
||||||
error_get_pretty(local_err));
|
"Failed to parse detect_zeroes mode: ");
|
||||||
exit(EXIT_FAILURE);
|
exit(EXIT_FAILURE);
|
||||||
}
|
}
|
||||||
if (detect_zeroes == BLOCKDEV_DETECT_ZEROES_OPTIONS_UNMAP &&
|
if (detect_zeroes == BLOCKDEV_DETECT_ZEROES_OPTIONS_UNMAP &&
|
||||||
@ -703,8 +703,8 @@ int main(int argc, char **argv)
|
|||||||
srcpath = argv[optind];
|
srcpath = argv[optind];
|
||||||
blk = blk_new_open("hda", srcpath, NULL, options, flags, &local_err);
|
blk = blk_new_open("hda", srcpath, NULL, options, flags, &local_err);
|
||||||
if (!blk) {
|
if (!blk) {
|
||||||
error_report("Failed to blk_new_open '%s': %s", argv[optind],
|
error_reportf_err(local_err, "Failed to blk_new_open '%s': ",
|
||||||
error_get_pretty(local_err));
|
argv[optind]);
|
||||||
exit(EXIT_FAILURE);
|
exit(EXIT_FAILURE);
|
||||||
}
|
}
|
||||||
bs = blk_bs(blk);
|
bs = blk_bs(blk);
|
||||||
@ -719,8 +719,7 @@ int main(int argc, char **argv)
|
|||||||
&local_err);
|
&local_err);
|
||||||
}
|
}
|
||||||
if (ret < 0) {
|
if (ret < 0) {
|
||||||
error_report("Failed to load snapshot: %s",
|
error_reportf_err(local_err, "Failed to load snapshot: ");
|
||||||
error_get_pretty(local_err));
|
|
||||||
exit(EXIT_FAILURE);
|
exit(EXIT_FAILURE);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -291,8 +291,7 @@ void replay_start(void)
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (replay_blockers) {
|
if (replay_blockers) {
|
||||||
error_report("Record/replay: %s",
|
error_reportf_err(replay_blockers->data, "Record/replay: ");
|
||||||
error_get_pretty(replay_blockers->data));
|
|
||||||
exit(1);
|
exit(1);
|
||||||
}
|
}
|
||||||
if (!use_icount) {
|
if (!use_icount) {
|
||||||
|
@ -832,9 +832,7 @@ int main(int argc, char **argv)
|
|||||||
|
|
||||||
ctx = aio_context_new(&local_error);
|
ctx = aio_context_new(&local_error);
|
||||||
if (!ctx) {
|
if (!ctx) {
|
||||||
error_report("Failed to create AIO Context: %s",
|
error_reportf_err(local_error, "Failed to create AIO Context: ");
|
||||||
error_get_pretty(local_error));
|
|
||||||
error_free(local_error);
|
|
||||||
exit(1);
|
exit(1);
|
||||||
}
|
}
|
||||||
src = aio_get_g_source(ctx);
|
src = aio_get_g_source(ctx);
|
||||||
|
@ -229,9 +229,7 @@ int main(int argc, char **argv)
|
|||||||
|
|
||||||
ctx = aio_context_new(&local_error);
|
ctx = aio_context_new(&local_error);
|
||||||
if (!ctx) {
|
if (!ctx) {
|
||||||
error_report("Failed to create AIO Context: %s",
|
error_reportf_err(local_error, "Failed to create AIO Context: ");
|
||||||
error_get_pretty(local_error));
|
|
||||||
error_free(local_error);
|
|
||||||
exit(1);
|
exit(1);
|
||||||
}
|
}
|
||||||
pool = aio_get_thread_pool(ctx);
|
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_init(id);
|
||||||
vnc_display_open(id, &local_err);
|
vnc_display_open(id, &local_err);
|
||||||
if (local_err != NULL) {
|
if (local_err != NULL) {
|
||||||
error_report("Failed to start VNC server: %s",
|
error_reportf_err(local_err, "Failed to start VNC server: ");
|
||||||
error_get_pretty(local_err));
|
|
||||||
error_free(local_err);
|
|
||||||
exit(1);
|
exit(1);
|
||||||
}
|
}
|
||||||
return 0;
|
return 0;
|
||||||
|
6
vl.c
6
vl.c
@ -3043,7 +3043,7 @@ int main(int argc, char **argv, char **envp)
|
|||||||
runstate_init();
|
runstate_init();
|
||||||
|
|
||||||
if (qcrypto_init(&err) < 0) {
|
if (qcrypto_init(&err) < 0) {
|
||||||
error_report("cannot initialize crypto: %s", error_get_pretty(err));
|
error_reportf_err(err, "cannot initialize crypto: ");
|
||||||
exit(1);
|
exit(1);
|
||||||
}
|
}
|
||||||
rtc_clock = QEMU_CLOCK_HOST;
|
rtc_clock = QEMU_CLOCK_HOST;
|
||||||
@ -4649,9 +4649,7 @@ int main(int argc, char **argv, char **envp)
|
|||||||
Error *local_err = NULL;
|
Error *local_err = NULL;
|
||||||
qemu_start_incoming_migration(incoming, &local_err);
|
qemu_start_incoming_migration(incoming, &local_err);
|
||||||
if (local_err) {
|
if (local_err) {
|
||||||
error_report("-incoming %s: %s", incoming,
|
error_reportf_err(local_err, "-incoming %s: ", incoming);
|
||||||
error_get_pretty(local_err));
|
|
||||||
error_free(local_err);
|
|
||||||
exit(1);
|
exit(1);
|
||||||
}
|
}
|
||||||
} else if (autostart) {
|
} else if (autostart) {
|
||||||
|
Loading…
Reference in New Issue
Block a user