chiark / gitweb /
udev: use startswith() and streq()
[elogind.git] / src / udev / keymap / keymap.c
index 4c30ccf..a2e43f9 100644 (file)
@@ -40,6 +40,7 @@ const struct key* lookup_key (const char *str, unsigned int len);
 
 #include "keys-from-name.h"
 #include "keys-to-name.h"
+#include "util.h"
 
 #define MAX_SCANCODES 1024
 
@@ -48,7 +49,7 @@ static int evdev_open(const char *dev)
         int fd;
         char fn[PATH_MAX];
 
-        if (strncmp(dev, "/dev", 4) != 0) {
+        if (!startswith(dev, "/dev")) {
                 snprintf(fn, sizeof(fn), "/dev/%s", dev);
                 dev = fn;
         }
@@ -418,8 +419,9 @@ int main(int argc, char **argv)
                         /* Keymap file argument is a filename */
                         /* Open override file if present, otherwise default file */
                         char keymap_path[PATH_MAX];
+                        FILE *f;
                         snprintf(keymap_path, sizeof(keymap_path), "%s%s", SYSCONFDIR "/udev/keymaps/", filearg);
-                        FILE *f = fopen(keymap_path, "r");
+                        f = fopen(keymap_path, "r");
                         if (f) {
                                 merge_table(fd, f);
                         } else {