udev-rules: avoid issuing redundant diagnostics in verify mode

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.
This commit is contained in:
Dmitry V. Levin 2023-05-18 17:00:00 +00:00
parent 75390455cb
commit f366434090

View 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);