All of lore.kernel.org
 help / color / mirror / Atom feed
From: "Philippe Mathieu-Daudé" <philmd@redhat.com>
To: Markus Armbruster <armbru@redhat.com>, qemu-devel@nongnu.org
Cc: Fei Li <fli@suse.com>, Gerd Hoffmann <kraxel@redhat.com>
Subject: Re: [Qemu-devel] [PATCH v2 26/35] ui: Convert vnc_display_init(), init_keyboard_layout() to Error
Date: Tue, 16 Oct 2018 00:42:46 +0200	[thread overview]
Message-ID: <532d19dd-2ce3-c17e-84ea-a7244ce2c52a@redhat.com> (raw)
In-Reply-To: <20181015115309.17089-27-armbru@redhat.com>

On 15/10/2018 13:53, Markus Armbruster wrote:
> From: Fei Li <fli@suse.com>
> 
> Signed-off-by: Fei Li <fli@suse.com>
> Cc: Gerd Hoffmann <kraxel@redhat.com>
> Signed-off-by: Markus Armbruster <armbru@redhat.com>

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

> ---
>  include/ui/console.h |  2 +-
>  ui/curses.c          |  6 +++---
>  ui/keymaps.c         | 11 ++++++-----
>  ui/keymaps.h         |  2 +-
>  ui/sdl.c             |  6 +++---
>  ui/vnc.c             | 15 ++++++++++-----
>  6 files changed, 24 insertions(+), 18 deletions(-)
> 
> diff --git a/include/ui/console.h b/include/ui/console.h
> index fb969caf70..c17803c530 100644
> --- a/include/ui/console.h
> +++ b/include/ui/console.h
> @@ -453,7 +453,7 @@ void qemu_display_early_init(DisplayOptions *opts);
>  void qemu_display_init(DisplayState *ds, DisplayOptions *opts);
>  
>  /* vnc.c */
> -void vnc_display_init(const char *id);
> +void vnc_display_init(const char *id, Error **errp);
>  void vnc_display_open(const char *id, Error **errp);
>  void vnc_display_add_client(const char *id, int csock, bool skipauth);
>  int vnc_display_password(const char *id, const char *password);
> diff --git a/ui/curses.c b/ui/curses.c
> index 59d819fd4d..f4e7a12f74 100644
> --- a/ui/curses.c
> +++ b/ui/curses.c
> @@ -28,6 +28,7 @@
>  #include <termios.h>
>  #endif
>  
> +#include "qapi/error.h"
>  #include "qemu-common.h"
>  #include "ui/console.h"
>  #include "ui/input.h"
> @@ -421,9 +422,8 @@ static void curses_keyboard_setup(void)
>          keyboard_layout = "en-us";
>  #endif
>      if(keyboard_layout) {
> -        kbd_layout = init_keyboard_layout(name2keysym, keyboard_layout);
> -        if (!kbd_layout)
> -            exit(1);
> +        kbd_layout = init_keyboard_layout(name2keysym, keyboard_layout,
> +                                          &error_fatal);
>      }
>  }
>  
> diff --git a/ui/keymaps.c b/ui/keymaps.c
> index b05fb028dc..085889b555 100644
> --- a/ui/keymaps.c
> +++ b/ui/keymaps.c
> @@ -27,6 +27,7 @@
>  #include "sysemu/sysemu.h"
>  #include "trace.h"
>  #include "qemu/error-report.h"
> +#include "qapi/error.h"
>  
>  struct keysym2code {
>      uint32_t count;
> @@ -81,7 +82,7 @@ static void add_keysym(char *line, int keysym, int keycode, kbd_layout_t *k)
>  
>  static int parse_keyboard_layout(kbd_layout_t *k,
>                                   const name2keysym_t *table,
> -                                 const char *language)
> +                                 const char *language, Error **errp)
>  {
>      int ret;
>      FILE *f;
> @@ -95,7 +96,7 @@ static int parse_keyboard_layout(kbd_layout_t *k,
>      f = filename ? fopen(filename, "r") : NULL;
>      g_free(filename);
>      if (!f) {
> -        fprintf(stderr, "Could not read keymap file: '%s'\n", language);
> +        error_setg(errp, "could not read keymap file: '%s'", language);
>          return -1;
>      }
>  
> @@ -114,7 +115,7 @@ static int parse_keyboard_layout(kbd_layout_t *k,
>              continue;
>          }
>          if (!strncmp(line, "include ", 8)) {
> -            if (parse_keyboard_layout(k, table, line + 8) < 0) {
> +            if (parse_keyboard_layout(k, table, line + 8, errp) < 0) {
>                  ret = -1;
>                  goto out;
>              }
> @@ -172,13 +173,13 @@ out:
>  
>  
>  kbd_layout_t *init_keyboard_layout(const name2keysym_t *table,
> -                                   const char *language)
> +                                   const char *language, Error **errp)
>  {
>      kbd_layout_t *k;
>  
>      k = g_new0(kbd_layout_t, 1);
>      k->hash = g_hash_table_new(NULL, NULL);
> -    if (parse_keyboard_layout(k, table, language) < 0) {
> +    if (parse_keyboard_layout(k, table, language, errp) < 0) {
>          g_hash_table_unref(k->hash);
>          g_free(k);
>          return NULL;
> diff --git a/ui/keymaps.h b/ui/keymaps.h
> index 0693588225..98213a4191 100644
> --- a/ui/keymaps.h
> +++ b/ui/keymaps.h
> @@ -53,7 +53,7 @@ typedef struct {
>  typedef struct kbd_layout_t kbd_layout_t;
>  
>  kbd_layout_t *init_keyboard_layout(const name2keysym_t *table,
> -                                   const char *language);
> +                                   const char *language, Error **errp);
>  int keysym2scancode(kbd_layout_t *k, int keysym,
>                      bool shift, bool altgr, bool ctrl);
>  int keycode_is_keypad(kbd_layout_t *k, int keycode);
> diff --git a/ui/sdl.c b/ui/sdl.c
> index a5fd503c25..190b16f575 100644
> --- a/ui/sdl.c
> +++ b/ui/sdl.c
> @@ -29,6 +29,7 @@
>  #include <SDL.h>
>  #include <SDL_syswm.h>
>  
> +#include "qapi/error.h"
>  #include "qemu-common.h"
>  #include "qemu/cutils.h"
>  #include "ui/console.h"
> @@ -917,9 +918,8 @@ static void sdl1_display_init(DisplayState *ds, DisplayOptions *o)
>          keyboard_layout = "en-us";
>  #endif
>      if(keyboard_layout) {
> -        kbd_layout = init_keyboard_layout(name2keysym, keyboard_layout);
> -        if (!kbd_layout)
> -            exit(1);
> +        kbd_layout = init_keyboard_layout(name2keysym, keyboard_layout,
> +                                          &error_fatal);
>      }
>  
>      g_printerr("Running QEMU with SDL 1.2 is deprecated, and will be removed\n"
> diff --git a/ui/vnc.c b/ui/vnc.c
> index cf221c83cc..98e3d3b1d8 100644
> --- a/ui/vnc.c
> +++ b/ui/vnc.c
> @@ -3205,7 +3205,7 @@ static const DisplayChangeListenerOps dcl_ops = {
>      .dpy_cursor_define    = vnc_dpy_cursor_define,
>  };
>  
> -void vnc_display_init(const char *id)
> +void vnc_display_init(const char *id, Error **errp)
>  {
>      VncDisplay *vd;
>  
> @@ -3222,13 +3222,14 @@ void vnc_display_init(const char *id)
>  
>      if (keyboard_layout) {
>          trace_vnc_key_map_init(keyboard_layout);
> -        vd->kbd_layout = init_keyboard_layout(name2keysym, keyboard_layout);
> +        vd->kbd_layout = init_keyboard_layout(name2keysym,
> +                                              keyboard_layout, errp);
>      } else {
> -        vd->kbd_layout = init_keyboard_layout(name2keysym, "en-us");
> +        vd->kbd_layout = init_keyboard_layout(name2keysym, "en-us", errp);
>      }
>  
>      if (!vd->kbd_layout) {
> -        exit(1);
> +        return;
>      }
>  
>      vd->share_policy = VNC_SHARE_POLICY_ALLOW_EXCLUSIVE;
> @@ -4079,7 +4080,11 @@ int vnc_init_func(void *opaque, QemuOpts *opts, Error **errp)
>      char *id = (char *)qemu_opts_id(opts);
>  
>      assert(id);
> -    vnc_display_init(id);
> +    vnc_display_init(id, &local_err);
> +    if (local_err) {
> +        error_report_err(local_err);
> +        exit(1);
> +    }
>      vnc_display_open(id, &local_err);
>      if (local_err != NULL) {
>          error_reportf_err(local_err, "Failed to start VNC server: ");
> 

  reply	other threads:[~2018-10-15 22:42 UTC|newest]

Thread overview: 50+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-10-15 11:52 [Qemu-devel] [PATCH v2 00/35] Replace some unwise uses of error_report() & friends Markus Armbruster
2018-10-15 11:52 ` [Qemu-devel] [PATCH v2 01/35] error: Fix use of error_prepend() with &error_fatal, &error_abort Markus Armbruster
2018-10-15 18:49   ` Eric Blake
2018-10-15 22:52   ` Philippe Mathieu-Daudé
2018-10-15 11:52 ` [Qemu-devel] [PATCH v2 02/35] Use error_fatal to simplify obvious fatal errors (again) Markus Armbruster
2018-10-15 11:52 ` [Qemu-devel] [PATCH v2 03/35] block: Use warn_report() & friends to report warnings Markus Armbruster
2018-10-15 11:52 ` [Qemu-devel] [PATCH v2 04/35] cpus hw target: " Markus Armbruster
2018-10-15 11:52 ` [Qemu-devel] [PATCH v2 05/35] vfio: " Markus Armbruster
2018-10-15 18:53   ` Eric Blake
2018-10-15 11:52 ` [Qemu-devel] [PATCH v2 06/35] vfio: Clean up error reporting after previous commit Markus Armbruster
2018-10-15 11:52 ` [Qemu-devel] [PATCH v2 07/35] char: Use error_printf() to print help and such Markus Armbruster
2018-10-15 11:52 ` [Qemu-devel] [PATCH v2 08/35] 9pfs: Fix CLI parsing crash on error Markus Armbruster
2018-10-15 19:00   ` Eric Blake
2018-10-15 11:52 ` [Qemu-devel] [PATCH v2 09/35] pc: Fix machine property nvdimm-persistence error handling Markus Armbruster
2018-10-15 11:52 ` [Qemu-devel] [PATCH v2 10/35] ioapic: Fix error handling in realize() Markus Armbruster
2018-10-15 11:52 ` [Qemu-devel] [PATCH v2 11/35] smbios: Clean up error handling in smbios_add() Markus Armbruster
2018-10-15 11:52 ` [Qemu-devel] [PATCH v2 12/35] migration: Fix !replay_can_snapshot() error handling Markus Armbruster
2018-10-15 11:52 ` [Qemu-devel] [PATCH v2 13/35] l2tpv3: Improve -netdev/netdev_add/-net/... error reporting Markus Armbruster
2018-10-15 11:52 ` [Qemu-devel] [PATCH v2 14/35] net/socket: Fix invalid socket type error handling Markus Armbruster
2018-10-15 11:52 ` [Qemu-devel] [PATCH v2 15/35] numa: Fix QMP command set-numa-node " Markus Armbruster
2018-10-15 11:52 ` [Qemu-devel] [PATCH v2 16/35] xen/pt: Fix incomplete conversion to realize() Markus Armbruster
2018-10-15 11:52 ` [Qemu-devel] [PATCH v2 17/35] seccomp: Clean up error reporting in parse_sandbox() Markus Armbruster
2018-10-15 11:52 ` [Qemu-devel] [PATCH v2 18/35] vl: Clean up error reporting in parse_add_fd() Markus Armbruster
2018-10-15 11:52 ` [Qemu-devel] [PATCH v2 19/35] qom: Clean up error reporting in user_creatable_add_opts_foreach() Markus Armbruster
2018-10-15 11:52 ` [Qemu-devel] [PATCH v2 20/35] vl: Clean up error reporting in chardev_init_func() Markus Armbruster
2018-10-15 11:52 ` [Qemu-devel] [PATCH v2 21/35] vl: Clean up error reporting in machine_set_property() Markus Armbruster
2018-10-15 11:52 ` [Qemu-devel] [PATCH v2 22/35] vl: Clean up error reporting in mon_init_func() Markus Armbruster
2018-10-15 11:52 ` [Qemu-devel] [PATCH v2 23/35] vl: Clean up error reporting in parse_fw_cfg() Markus Armbruster
2018-10-15 11:52 ` [Qemu-devel] [PATCH v2 24/35] vl: Clean up error reporting in device_init_func() Markus Armbruster
2018-10-15 11:52 ` [Qemu-devel] [PATCH v2 25/35] ui/keymaps: Fix handling of erroneous include files Markus Armbruster
2018-10-15 11:53 ` [Qemu-devel] [PATCH v2 26/35] ui: Convert vnc_display_init(), init_keyboard_layout() to Error Markus Armbruster
2018-10-15 22:42   ` Philippe Mathieu-Daudé [this message]
2018-10-15 11:53 ` [Qemu-devel] [PATCH v2 27/35] vnc: Clean up error reporting in vnc_init_func() Markus Armbruster
2018-10-15 12:51   ` Fei Li
2018-10-16  4:08     ` Markus Armbruster
2018-10-16  6:52       ` Gerd Hoffmann
2018-10-16 11:21         ` Markus Armbruster
2018-10-15 22:41   ` Philippe Mathieu-Daudé
2018-10-15 11:53 ` [Qemu-devel] [PATCH v2 28/35] numa: Clean up error reporting in parse_numa() Markus Armbruster
2018-10-15 11:53 ` [Qemu-devel] [PATCH v2 29/35] tpm: Clean up error reporting in tpm_init_tpmdev() Markus Armbruster
2018-10-15 11:53 ` [Qemu-devel] [PATCH v2 30/35] spice: Clean up error reporting in add_channel() Markus Armbruster
2018-10-15 11:53 ` [Qemu-devel] [PATCH v2 31/35] fsdev: Clean up error reporting in qemu_fsdev_add() Markus Armbruster
2018-10-15 11:53 ` [Qemu-devel] [PATCH v2 32/35] vl: Assert drive_new() does not fail in default_drive() Markus Armbruster
2018-10-15 11:53 ` [Qemu-devel] [PATCH v2 33/35] blockdev: Convert drive_new() to Error Markus Armbruster
2018-10-15 14:48   ` Max Reitz
2018-10-15 18:54     ` Eric Blake
2018-10-15 22:38     ` Philippe Mathieu-Daudé
2018-10-16  4:09       ` Markus Armbruster
2018-10-15 11:53 ` [Qemu-devel] [PATCH v2 34/35] vl: Fix exit status for -drive format=help Markus Armbruster
2018-10-15 11:53 ` [Qemu-devel] [PATCH v2 35/35] vl: Simplify call of parse_name() Markus Armbruster

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=532d19dd-2ce3-c17e-84ea-a7244ce2c52a@redhat.com \
    --to=philmd@redhat.com \
    --cc=armbru@redhat.com \
    --cc=fli@suse.com \
    --cc=kraxel@redhat.com \
    --cc=qemu-devel@nongnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.