qemu-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [Qemu-devel] [PATCH 24/31] vl: Clean up error reporting in vnc_init_


From: Markus Armbruster
Subject: Re: [Qemu-devel] [PATCH 24/31] vl: Clean up error reporting in vnc_init_func()
Date: Thu, 11 Oct 2018 19:48:18 +0200
User-agent: Gnus/5.13 (Gnus v5.13) Emacs/26.1 (gnu/linux)

Markus Armbruster <address@hidden> writes:

> Calling error_report() in a function that takes an Error ** argument
> is suspicious.  vnc_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.
>
> Cc: Gerd Hoffmann <address@hidden>
> Signed-off-by: Markus Armbruster <address@hidden>
> ---
>  ui/vnc.c | 5 +++--
>  vl.c     | 2 +-
>  2 files changed, 4 insertions(+), 3 deletions(-)
>
> diff --git a/ui/vnc.c b/ui/vnc.c
> index cf221c83cc..df6c84b802 100644
> --- a/ui/vnc.c
> +++ b/ui/vnc.c
> @@ -4082,8 +4082,9 @@ int vnc_init_func(void *opaque, QemuOpts *opts, Error 
> **errp)
>      vnc_display_init(id);

My patch is incomplete, there's fprintf(stderr, ...); exit(1); hiding
behind vnc_display_init().  See my review of "[PATCH RFC v5 2/7]
ui/vnc.c: polish vnc_init_func"
https://lists.nongnu.org/archive/html/qemu-devel/2018-10/msg02238.html
Message-ID: <address@hidden>


>      vnc_display_open(id, &local_err);
>      if (local_err != NULL) {
> -        error_reportf_err(local_err, "Failed to start VNC server: ");
> -        exit(1);
> +        error_propagate(errp, local_err);
> +        error_prepend(errp, "Failed to start VNC server: ");
> +        return -1;
>      }
>      return 0;
>  }
> diff --git a/vl.c b/vl.c
> index 86eee4c798..5c159ca45c 100644
> --- a/vl.c
> +++ b/vl.c
> @@ -4479,7 +4479,7 @@ int main(int argc, char **argv, char **envp)
>      /* init remote displays */
>  #ifdef CONFIG_VNC
>      qemu_opts_foreach(qemu_find_opts("vnc"),
> -                      vnc_init_func, NULL, NULL);
> +                      vnc_init_func, NULL, &error_fatal);
>  #endif
>  
>      if (using_spice) {



reply via email to

[Prev in Thread] Current Thread [Next in Thread]