Re: [Qemu-devel] [PATCH 23/31] vl: Clean up error reporting in device_init_func()
On 08/10/2018 19:31, Markus Armbruster wrote: > Calling error_report() in a function that takes an Error ** argument > is suspicious. device_init_func() does that, and then fails without > setting an error. Its caller main(), via qemu_opts_foreach(), is fine > with it, but clean it up anyway. > > Signed-off-by: Markus Armbruster Reviewed-by: Philippe Mathieu-Daudé > --- > vl.c | 10 +++--- > 1 file changed, 3 insertions(+), 7 deletions(-) > > diff --git a/vl.c b/vl.c > index a3a39ec06b..86eee4c798 100644 > --- a/vl.c > +++ b/vl.c > @@ -,12 +,10 @@ static int device_help_func(void *opaque, QemuOpts > *opts, Error **errp) > > static int device_init_func(void *opaque, QemuOpts *opts, Error **errp) > { > -Error *err = NULL; > DeviceState *dev; > > -dev = qdev_device_add(opts, ); > +dev = qdev_device_add(opts, errp); > if (!dev) { > -error_report_err(err); > return -1; > } > object_unref(OBJECT(dev)); > @@ -,10 +4442,8 @@ int main(int argc, char **argv, char **envp) > > /* init generic devices */ > rom_set_order_override(FW_CFG_ORDER_OVERRIDE_DEVICE); > -if (qemu_opts_foreach(qemu_find_opts("device"), > - device_init_func, NULL, NULL)) { > -exit(1); > -} > +qemu_opts_foreach(qemu_find_opts("device"), > + device_init_func, NULL, _fatal); > > cpu_synchronize_all_post_init(); > >
[Qemu-devel] [PATCH 23/31] vl: Clean up error reporting in device_init_func()
Calling error_report() in a function that takes an Error ** argument is suspicious. device_init_func() does that, and then fails without setting an error. Its caller main(), via qemu_opts_foreach(), is fine with it, but clean it up anyway. Signed-off-by: Markus Armbruster --- vl.c | 10 +++--- 1 file changed, 3 insertions(+), 7 deletions(-) diff --git a/vl.c b/vl.c index a3a39ec06b..86eee4c798 100644 --- a/vl.c +++ b/vl.c @@ -,12 +,10 @@ static int device_help_func(void *opaque, QemuOpts *opts, Error **errp) static int device_init_func(void *opaque, QemuOpts *opts, Error **errp) { -Error *err = NULL; DeviceState *dev; -dev = qdev_device_add(opts, ); +dev = qdev_device_add(opts, errp); if (!dev) { -error_report_err(err); return -1; } object_unref(OBJECT(dev)); @@ -,10 +4442,8 @@ int main(int argc, char **argv, char **envp) /* init generic devices */ rom_set_order_override(FW_CFG_ORDER_OVERRIDE_DEVICE); -if (qemu_opts_foreach(qemu_find_opts("device"), - device_init_func, NULL, NULL)) { -exit(1); -} +qemu_opts_foreach(qemu_find_opts("device"), + device_init_func, NULL, _fatal); cpu_synchronize_all_post_init(); -- 2.17.1