[systemd-commits] 2 commits - src/udev

Martin Pitt martin at kemper.freedesktop.org
Thu Oct 18 23:06:41 PDT 2012


 src/udev/keymap/keymap.c |   12 ++++++------
 1 file changed, 6 insertions(+), 6 deletions(-)

New commits:
commit accfdb7abfe0dad7c8e7e5364d93ad962895acfc
Author: Martin Pitt <martinpitt at gnome.org>
Date:   Fri Oct 19 08:03:09 2012 +0200

    keymap: Tolerate invalid entries in keymaps
    
    Some keymaps apply to a large range of computer models, not all of which have
    all of the scan codes in the maps. If a single scan code is invalid, do not
    abort but continue with the next entry in the map. Instead just show the error
    message for that particular scan code, to help with debugging.

diff --git a/src/udev/keymap/keymap.c b/src/udev/keymap/keymap.c
index a6f97dd..0db56d2 100644
--- a/src/udev/keymap/keymap.c
+++ b/src/udev/keymap/keymap.c
@@ -71,7 +71,7 @@ static int evdev_get_keycode(int fd, unsigned scancode, int e)
                 if (e && errno == EINVAL) {
                         return -2;
                 } else {
-                        fprintf(stderr, "EVIOCGKEYCODE: %m\n");
+                        fprintf(stderr, "EVIOCGKEYCODE for scan code 0x%x: %m\n", scancode);
                         return -1;
                 }
         }
@@ -226,19 +226,19 @@ static int merge_table(int fd, FILE *f) {
 
                 if ((old_keycode = evdev_get_keycode(fd, scancode, 0)) < 0) {
                         r = -1;
-                        goto fail;
+                        continue;
                 }
 
                 if (evdev_set_keycode(fd, scancode, new_keycode) < 0) {
                         r = -1;
-                        goto fail;
+                        continue;
                 }
 
                 if (new_keycode != old_keycode)
                         fprintf(stderr, "Remapped scancode 0x%02x to 0x%02x (prior: 0x%02x)\n",
                                 scancode, new_keycode, old_keycode);
         }
-fail:
+
         fclose(f);
         return r;
 }

commit 3bb9434b69b8562117b8ec34b4498aa208907316
Author: Martin Pitt <martinpitt at gnome.org>
Date:   Fri Oct 19 08:01:47 2012 +0200

    keymap: Fix parsing of hex scan codes in tables
    
    Commit b1f87c76b1 changed sscanf from %i to %u, as scan codes are unsigned
    numbers which can be > 0x7FFFFFFF. However, sscanf doesn't accept hexadecimal
    numbers for %u. It works fine with %i, so revert this back.

diff --git a/src/udev/keymap/keymap.c b/src/udev/keymap/keymap.c
index 0db33b9..a6f97dd 100644
--- a/src/udev/keymap/keymap.c
+++ b/src/udev/keymap/keymap.c
@@ -204,11 +204,11 @@ static int merge_table(int fd, FILE *f) {
                 if (*p == '#' || *p == '\n')
                         continue;
 
-                if (sscanf(p, "%u %i", &scancode, &new_keycode) != 2) {
+                if (sscanf(p, "%i %i", &scancode, &new_keycode) != 2) {
                         char t[105] = "KEY_UNKNOWN";
                         const struct key *k;
 
-                        if (sscanf(p, "%u %100s", &scancode, t+4) != 2) {
+                        if (sscanf(p, "%i %100s", &scancode, t+4) != 2) {
                                 fprintf(stderr, "WARNING: Parse failure at line %i, ignoring.\n", line);
                                 r = -1;
                                 continue;



More information about the systemd-commits mailing list