* [PATCH] replace error_setg(&error_fatal, ...) with error_report()
@ 2024-10-07 22:27 Tudor Gheorghiu
2024-10-08 7:04 ` Thomas Huth
2024-10-18 16:30 ` Michael Tokarev
0 siblings, 2 replies; 3+ messages in thread
From: Tudor Gheorghiu @ 2024-10-07 22:27 UTC (permalink / raw)
To: Thomas Huth; +Cc: qemu-devel, qemu-trivial
According to include/qapi/error.h:
* Please don't error_setg(&error_fatal, ...), use error_report() and
* exit(), because that's more obvious.
Patch updates all instances of error_setg(&error_fatal, ...) with
error_report(...), adds the explicit exit(1) and removes redundant
return statements.
Signed-off-by: Tudor Gheorghiu <tudor.reda@gmail.com>
Suggested-by: Thomas Huth <thuth@redhat.com>
Resolves: https://gitlab.com/qemu-project/qemu/-/issues/2587
---
hw/arm/allwinner-a10.c | 5 +++--
hw/arm/allwinner-h3.c | 4 ++--
hw/arm/allwinner-r40.c | 4 ++--
hw/arm/xlnx-versal-virt.c | 4 ++--
hw/audio/soundhw.c | 3 ++-
system/vl.c | 3 ++-
6 files changed, 13 insertions(+), 10 deletions(-)
diff --git a/hw/arm/allwinner-a10.c b/hw/arm/allwinner-a10.c
index 08cdff61e4..3cc5142832 100644
--- a/hw/arm/allwinner-a10.c
+++ b/hw/arm/allwinner-a10.c
@@ -17,6 +17,7 @@
#include "qemu/osdep.h"
#include "qapi/error.h"
+#include "qemu/error-report.h"
#include "qemu/module.h"
#include "hw/char/serial-mm.h"
#include "hw/sysbus.h"
@@ -49,9 +50,9 @@ void allwinner_a10_bootrom_setup(AwA10State *s, BlockBackend *blk)
g_autofree uint8_t *buffer = g_new0(uint8_t, rom_size);
if (blk_pread(blk, 8 * KiB, rom_size, buffer, 0) < 0) {
- error_setg(&error_fatal, "%s: failed to read BlockBackend data",
+ error_report("%s: failed to read BlockBackend data",
__func__);
- return;
+ exit(1);
}
rom_add_blob("allwinner-a10.bootrom", buffer, rom_size,
diff --git a/hw/arm/allwinner-h3.c b/hw/arm/allwinner-h3.c
index 9bc57cd266..a1b4b1de1c 100644
--- a/hw/arm/allwinner-h3.c
+++ b/hw/arm/allwinner-h3.c
@@ -182,9 +182,9 @@ void allwinner_h3_bootrom_setup(AwH3State *s, BlockBackend *blk)
g_autofree uint8_t *buffer = g_new0(uint8_t, rom_size);
if (blk_pread(blk, 8 * KiB, rom_size, buffer, 0) < 0) {
- error_setg(&error_fatal, "%s: failed to read BlockBackend data",
+ error_report("%s: failed to read BlockBackend data",
__func__);
- return;
+ exit(1);
}
rom_add_blob("allwinner-h3.bootrom", buffer, rom_size,
diff --git a/hw/arm/allwinner-r40.c b/hw/arm/allwinner-r40.c
index ced73009d6..b197530c38 100644
--- a/hw/arm/allwinner-r40.c
+++ b/hw/arm/allwinner-r40.c
@@ -231,9 +231,9 @@ bool allwinner_r40_bootrom_setup(AwR40State *s, BlockBackend *blk, int unit)
struct boot_file_head *head = (struct boot_file_head *)buffer;
if (blk_pread(blk, 8 * KiB, rom_size, buffer, 0) < 0) {
- error_setg(&error_fatal, "%s: failed to read BlockBackend data",
+ error_report("%s: failed to read BlockBackend data",
__func__);
- return false;
+ exit(1);
}
/* we only check the magic string here. */
diff --git a/hw/arm/xlnx-versal-virt.c b/hw/arm/xlnx-versal-virt.c
index 962f98fee2..8b12d3e7cb 100644
--- a/hw/arm/xlnx-versal-virt.c
+++ b/hw/arm/xlnx-versal-virt.c
@@ -761,9 +761,9 @@ static void versal_virt_init(MachineState *machine)
if (!flash_klass ||
object_class_is_abstract(flash_klass) ||
!object_class_dynamic_cast(flash_klass, TYPE_M25P80)) {
- error_setg(&error_fatal, "'%s' is either abstract or"
+ error_report("'%s' is either abstract or"
" not a subtype of m25p80", s->ospi_model);
- return;
+ exit(1);
}
}
diff --git a/hw/audio/soundhw.c b/hw/audio/soundhw.c
index b387b0ef7d..d18fd9fa05 100644
--- a/hw/audio/soundhw.c
+++ b/hw/audio/soundhw.c
@@ -88,7 +88,8 @@ void select_soundhw(const char *name, const char *audiodev)
struct soundhw *c;
if (selected) {
- error_setg(&error_fatal, "only one -soundhw option is allowed");
+ error_report("only one -soundhw option is allowed");
+ exit(1);
}
for (c = soundhw; c->name; ++c) {
diff --git a/system/vl.c b/system/vl.c
index fe547ca47c..50c138eece 100644
--- a/system/vl.c
+++ b/system/vl.c
@@ -1841,7 +1841,8 @@ static void object_option_parse(const char *str)
type = qemu_opt_get(opts, "qom-type");
if (!type) {
- error_setg(&error_fatal, QERR_MISSING_PARAMETER, "qom-type");
+ error_report(QERR_MISSING_PARAMETER, "qom-type");
+ exit(1);
}
if (user_creatable_print_help(type, opts)) {
exit(0);
--
2.39.5 (Apple Git-154)
^ permalink raw reply related [flat|nested] 3+ messages in thread
* Re: [PATCH] replace error_setg(&error_fatal, ...) with error_report()
2024-10-07 22:27 [PATCH] replace error_setg(&error_fatal, ...) with error_report() Tudor Gheorghiu
@ 2024-10-08 7:04 ` Thomas Huth
2024-10-18 16:30 ` Michael Tokarev
1 sibling, 0 replies; 3+ messages in thread
From: Thomas Huth @ 2024-10-08 7:04 UTC (permalink / raw)
To: Tudor Gheorghiu; +Cc: qemu-devel, qemu-trivial
On 08/10/2024 00.27, Tudor Gheorghiu wrote:
> According to include/qapi/error.h:
> * Please don't error_setg(&error_fatal, ...), use error_report() and
> * exit(), because that's more obvious.
>
> Patch updates all instances of error_setg(&error_fatal, ...) with
> error_report(...), adds the explicit exit(1) and removes redundant
> return statements.
>
> Signed-off-by: Tudor Gheorghiu <tudor.reda@gmail.com>
> Suggested-by: Thomas Huth <thuth@redhat.com>
> Resolves: https://gitlab.com/qemu-project/qemu/-/issues/2587
> ---
> hw/arm/allwinner-a10.c | 5 +++--
> hw/arm/allwinner-h3.c | 4 ++--
> hw/arm/allwinner-r40.c | 4 ++--
> hw/arm/xlnx-versal-virt.c | 4 ++--
> hw/audio/soundhw.c | 3 ++-
> system/vl.c | 3 ++-
> 6 files changed, 13 insertions(+), 10 deletions(-)
Reviewed-by: Thomas Huth <thuth@redhat.com>
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [PATCH] replace error_setg(&error_fatal, ...) with error_report()
2024-10-07 22:27 [PATCH] replace error_setg(&error_fatal, ...) with error_report() Tudor Gheorghiu
2024-10-08 7:04 ` Thomas Huth
@ 2024-10-18 16:30 ` Michael Tokarev
1 sibling, 0 replies; 3+ messages in thread
From: Michael Tokarev @ 2024-10-18 16:30 UTC (permalink / raw)
To: Tudor Gheorghiu, Thomas Huth; +Cc: qemu-devel, qemu-trivial
08.10.2024 01:27, Tudor Gheorghiu wrote:
> According to include/qapi/error.h:
> * Please don't error_setg(&error_fatal, ...), use error_report() and
> * exit(), because that's more obvious.
>
> Patch updates all instances of error_setg(&error_fatal, ...) with
> error_report(...), adds the explicit exit(1) and removes redundant
> return statements.
>
> Signed-off-by: Tudor Gheorghiu <tudor.reda@gmail.com>
> Suggested-by: Thomas Huth <thuth@redhat.com>
> Resolves: https://gitlab.com/qemu-project/qemu/-/issues/2587
Reviewed-by: Michael Tokarev <mjt@tls.msk.ru>
> @@ -49,9 +50,9 @@ void allwinner_a10_bootrom_setup(AwA10State *s, BlockBackend *blk)
> g_autofree uint8_t *buffer = g_new0(uint8_t, rom_size);
>
> if (blk_pread(blk, 8 * KiB, rom_size, buffer, 0) < 0) {
> - error_setg(&error_fatal, "%s: failed to read BlockBackend data",
> + error_report("%s: failed to read BlockBackend data",
> __func__);
> - return;
> + exit(1);
> }
I queued this patch to qemu-trivial, with additional change, - folding this __func__ to
the previous line, since there's no need to split the line anymore. Like this:
if (blk_pread(blk, 8 * KiB, rom_size, buffer, 0) < 0) {
- error_setg(&error_fatal, "%s: failed to read BlockBackend data",
- __func__);
- return;
+ error_report("%s: failed to read BlockBackend data", __func__);
+ exit(1);
}
Here and in 2 other allwinner-* files.
Thanks,
/mjt
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2024-10-18 16:31 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2024-10-07 22:27 [PATCH] replace error_setg(&error_fatal, ...) with error_report() Tudor Gheorghiu
2024-10-08 7:04 ` Thomas Huth
2024-10-18 16:30 ` Michael Tokarev
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).