From ab4f931e9f0a6e1c6dd6ecd79118efca418d941f Mon Sep 17 00:00:00 2001 From: Fei Li Date: Wed, 17 Oct 2018 10:26:50 +0200 Subject: ui: Convert vnc_display_init(), init_keyboard_layout() to Error MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Fei Li Cc: Gerd Hoffmann Signed-off-by: Markus Armbruster Reviewed-by: Philippe Mathieu-Daudé Message-Id: <20181017082702.5581-27-armbru@redhat.com> Reviewed-by: Gerd Hoffmann --- ui/keymaps.c | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) (limited to 'ui/keymaps.c') 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; -- cgit v1.2.3