[Qemu-devel] [PATCH 20/31] vl: Clean up error reporting in machine_set_property()

Markus Armbruster posted 31 patches 7 years ago
There is a newer version of this series
[Qemu-devel] [PATCH 20/31] vl: Clean up error reporting in machine_set_property()
Posted by Markus Armbruster 7 years ago
Calling error_report() in a function that takes an Error ** argument
is suspicious.  machine_set_property() 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 <armbru@redhat.com>
---
 vl.c | 9 +++------
 1 file changed, 3 insertions(+), 6 deletions(-)

diff --git a/vl.c b/vl.c
index ecb70f87d8..3adc9dbe4f 100644
--- a/vl.c
+++ b/vl.c
@@ -2676,7 +2676,7 @@ static int machine_set_property(void *opaque,
     g_free(qom_name);
 
     if (local_err) {
-        error_report_err(local_err);
+        error_propagate(errp, local_err);
         return -1;
     }
 
@@ -4201,11 +4201,8 @@ int main(int argc, char **argv, char **envp)
     }
 
     machine_opts = qemu_get_machine_opts();
-    if (qemu_opt_foreach(machine_opts, machine_set_property, current_machine,
-                         NULL)) {
-        object_unref(OBJECT(current_machine));
-        exit(1);
-    }
+    qemu_opt_foreach(machine_opts, machine_set_property, current_machine,
+                     &error_fatal);
 
     configure_accelerator(current_machine);
 
-- 
2.17.1


Re: [Qemu-devel] [PATCH 20/31] vl: Clean up error reporting in machine_set_property()
Posted by Philippe Mathieu-Daudé 7 years ago
On 08/10/2018 19:31, Markus Armbruster wrote:
> Calling error_report() in a function that takes an Error ** argument
> is suspicious.  machine_set_property() 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 <armbru@redhat.com>

Reviewed-by: Philippe Mathieu-Daudé <philmd@redhat.com>

> ---
>  vl.c | 9 +++------
>  1 file changed, 3 insertions(+), 6 deletions(-)
> 
> diff --git a/vl.c b/vl.c
> index ecb70f87d8..3adc9dbe4f 100644
> --- a/vl.c
> +++ b/vl.c
> @@ -2676,7 +2676,7 @@ static int machine_set_property(void *opaque,
>      g_free(qom_name);
>  
>      if (local_err) {
> -        error_report_err(local_err);
> +        error_propagate(errp, local_err);
>          return -1;
>      }
>  
> @@ -4201,11 +4201,8 @@ int main(int argc, char **argv, char **envp)
>      }
>  
>      machine_opts = qemu_get_machine_opts();
> -    if (qemu_opt_foreach(machine_opts, machine_set_property, current_machine,
> -                         NULL)) {
> -        object_unref(OBJECT(current_machine));
> -        exit(1);
> -    }
> +    qemu_opt_foreach(machine_opts, machine_set_property, current_machine,
> +                     &error_fatal);
>  
>      configure_accelerator(current_machine);
>  
> 

Re: [Qemu-devel] [PATCH 20/31] vl: Clean up error reporting in machine_set_property()
Posted by Marc-André Lureau 7 years ago
Hi

On Mon, Oct 8, 2018 at 9:47 PM Markus Armbruster <armbru@redhat.com> wrote:
>
> Calling error_report() in a function that takes an Error ** argument
> is suspicious.  machine_set_property() 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 <armbru@redhat.com>

Reviewed-by: Marc-André Lureau <marcandre.lureau@redhat.com>

> ---
>  vl.c | 9 +++------
>  1 file changed, 3 insertions(+), 6 deletions(-)
>
> diff --git a/vl.c b/vl.c
> index ecb70f87d8..3adc9dbe4f 100644
> --- a/vl.c
> +++ b/vl.c
> @@ -2676,7 +2676,7 @@ static int machine_set_property(void *opaque,
>      g_free(qom_name);
>
>      if (local_err) {
> -        error_report_err(local_err);
> +        error_propagate(errp, local_err);
>          return -1;
>      }
>
> @@ -4201,11 +4201,8 @@ int main(int argc, char **argv, char **envp)
>      }
>
>      machine_opts = qemu_get_machine_opts();
> -    if (qemu_opt_foreach(machine_opts, machine_set_property, current_machine,
> -                         NULL)) {
> -        object_unref(OBJECT(current_machine));
> -        exit(1);
> -    }
> +    qemu_opt_foreach(machine_opts, machine_set_property, current_machine,
> +                     &error_fatal);
>
>      configure_accelerator(current_machine);
>
> --
> 2.17.1
>
>


-- 
Marc-André Lureau