chiark / gitweb /
resolved: remove unused variable
[elogind.git] / src / udev / udev-rules.c
index 26302640a6405c157c7a6c39ba5688cefc9abe7b..9864016d1447c1ab041ead6ed0d515d22f73d5a8 100644 (file)
@@ -1533,15 +1533,19 @@ static int parse_file(struct udev_rules *rules, const char *filename)
         int line_nr = 0;
         unsigned int i;
 
-        if (null_or_empty_path(filename)) {
-                log_debug("skip empty file: %s", filename);
-                return 0;
+        f = fopen(filename, "re");
+        if (!f) {
+                if (errno == ENOENT)
+                        return 0;
+                else
+                        return -errno;
         }
-        log_debug("read rules file: %s", filename);
 
-        f = fopen(filename, "re");
-        if (f == NULL)
-                return -1;
+        if (null_or_empty_fd(fileno(f))) {
+                log_debug("Skipping empty file: %s", filename);
+                return 0;
+        } else
+                log_debug("Reading rules file: %s", filename);
 
         first_token = rules->token_cur;
         filename_off = rules_add_string(rules, filename);
@@ -2027,7 +2031,7 @@ int udev_rules_apply_to_event(struct udev_rules *rules, struct udev_event *event
                 case TK_M_PROGRAM: {
                         char program[UTIL_PATH_SIZE];
                         char **envp;
-                        char result[UTIL_PATH_SIZE];
+                        char result[UTIL_LINE_SIZE];
 
                         free(event->program_result);
                         event->program_result = NULL;
@@ -2555,10 +2559,15 @@ int udev_rules_apply_static_dev_perms(struct udev_rules *rules)
                         struct stat stats;
 
                         /* we assure, that the permissions tokens are sorted before the static token */
+
                         if (mode == 0 && uid == 0 && gid == 0 && tags == NULL)
                                 goto next;
 
                         strscpyl(device_node, sizeof(device_node), "/dev/", rules_str(rules, cur->key.value_off), NULL);
+                        if (stat(device_node, &stats) != 0)
+                                break;
+                        if (!S_ISBLK(stats.st_mode) && !S_ISCHR(stats.st_mode))
+                                break;
 
                         /* export the tags to a directory as symlinks, allowing otherwise dead nodes to be tagged */
                         if (tags) {
@@ -2588,11 +2597,6 @@ int udev_rules_apply_static_dev_perms(struct udev_rules *rules)
                         if (mode == 0 && uid == 0 && gid == 0)
                                 break;
 
-                        if (stat(device_node, &stats) != 0)
-                                break;
-                        if (!S_ISBLK(stats.st_mode) && !S_ISCHR(stats.st_mode))
-                                break;
-
                         if (mode == 0) {
                                 if (gid > 0)
                                         mode = 0660;