923a60
From 7d6891da40f2f5cfbc5bf02b6a58dc49c1577373 Mon Sep 17 00:00:00 2001
923a60
From: Peter Hutterer <peter.hutterer@who-t.net>
923a60
Date: Fri, 20 Mar 2015 12:48:24 +1000
923a60
Subject: [PATCH] udev: builtin-keyboard: move fetching the device node up
923a60
923a60
No point parsing the properties if we can't get the devnode to apply them
923a60
later. Plus, this makes future additions easier to slot in.
923a60
923a60
(cherry picked from commit 753bd5c7ede5e74c21221fcf59de3ce320d6722d)
923a60
923a60
Resolves: #1500119
923a60
---
923a60
 src/udev/udev-builtin-keyboard.c | 16 ++++++++--------
923a60
 1 file changed, 8 insertions(+), 8 deletions(-)
923a60
923a60
diff --git a/src/udev/udev-builtin-keyboard.c b/src/udev/udev-builtin-keyboard.c
923a60
index d8ee4cbb61..bde7bf07fb 100644
923a60
--- a/src/udev/udev-builtin-keyboard.c
923a60
+++ b/src/udev/udev-builtin-keyboard.c
923a60
@@ -75,6 +75,13 @@ static int builtin_keyboard(struct udev_device *dev, int argc, char *argv[], boo
923a60
         unsigned map_count = 0;
923a60
         unsigned release[1024];
923a60
         unsigned release_count = 0;
923a60
+        const char *node;
923a60
+
923a60
+        node = udev_device_get_devnode(dev);
923a60
+        if (!node) {
923a60
+                log_error("Error, no device node for '%s'", udev_device_get_syspath(dev));
923a60
+                return EXIT_FAILURE;
923a60
+        }
923a60
 
923a60
         udev_list_entry_foreach(entry, udev_device_get_properties_list_entry(dev)) {
923a60
                 const char *key;
923a60
@@ -128,17 +135,10 @@ static int builtin_keyboard(struct udev_device *dev, int argc, char *argv[], boo
923a60
         }
923a60
 
923a60
         if (map_count > 0 || release_count > 0) {
923a60
-                const char *node;
923a60
                 int fd;
923a60
                 unsigned i;
923a60
 
923a60
-                node = udev_device_get_devnode(dev);
923a60
-                if (!node) {
923a60
-                        log_error("Error, no device node for '%s'", udev_device_get_syspath(dev));
923a60
-                        return EXIT_FAILURE;
923a60
-                }
923a60
-
923a60
-                fd = open(udev_device_get_devnode(dev), O_RDWR|O_CLOEXEC|O_NONBLOCK|O_NOCTTY);
923a60
+                fd = open(node, O_RDWR|O_CLOEXEC|O_NONBLOCK|O_NOCTTY);
923a60
                 if (fd < 0) {
923a60
                         log_error_errno(errno, "Error, opening device '%s': %m", node);
923a60
                         return EXIT_FAILURE;