udev-rules: avoid issuing redundant diagnostics in verify mode
authorDmitry V. Levin <ldv@strace.io>
Thu, 18 May 2023 17:00:00 +0000 (17:00 +0000)
committerDmitry V. Levin <ldv@strace.io>
Thu, 18 May 2023 17:00:00 +0000 (17:00 +0000)
When udevadm verify is given an argument that doesn't point to an
existing file, there used to be two diagnostics messages, the first one
at a warning level, and the second one at an error level:

$ build/udevadm verify /no/such/directory
Failed to open /no/such/directory, ignoring: No such file or directory
Failed to parse rules file /no/such/directory: No such file or directory

Fix this by issuing just the error message.

src/udev/udev-rules.c

index fc1ef34964ec6da3408cb96b5ffe8e2c5cd49376..e5a25bd1191cf02b7350e1a00fabb295e27afd51 100644 (file)
@@ -1454,7 +1454,10 @@ int udev_rules_parse_file(UdevRules *rules, const char *filename, bool extra_che
 
         f = fopen(filename, "re");
         if (!f) {
-                if (!extra_checks && errno == ENOENT)
+                if (extra_checks)
+                        return -errno;
+
+                if (errno == ENOENT)
                         return 0;
 
                 return log_warning_errno(errno, "Failed to open %s, ignoring: %m", filename);