daandemeyer / rpms / systemd

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