Skip to content

Commit 32a3200

Browse files
poetteringbluca
authored andcommitted
sd-device: remove debug log message when dirs are missing
This is a common case, and nothing noteworthy at all. For example, if we establish an enumerator for listing all devices tagged by some tag, then the per-tag dir is not going to exist if there are currently no devices tagged that way, but that's a really common case, and doesn't really deserve any mention, not even at debug level. (cherry picked from commit a68c97a) (cherry picked from commit 8aa9e60) (cherry picked from commit a321caf)
1 parent 11c456a commit 32a3200

File tree

1 file changed

+13
-21
lines changed

1 file changed

+13
-21
lines changed

src/libsystemd/sd-device/device-enumerator.c

Lines changed: 13 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -685,13 +685,11 @@ static int enumerator_scan_dir_and_add_devices(
685685

686686
dir = opendir(path);
687687
if (!dir) {
688-
bool ignore = errno == ENOENT;
688+
/* This is necessarily racey, so ignore missing directories */
689+
if (errno == ENOENT)
690+
return 0;
689691

690-
/* this is necessarily racey, so ignore missing directories */
691-
log_debug_errno(errno,
692-
"sd-device-enumerator: Failed to open directory %s%s: %m",
693-
path, ignore ? ", ignoring" : "");
694-
return ignore ? 0 : -errno;
692+
return log_debug_errno(errno, "sd-device-enumerator: Failed to open directory '%s': %m", path);
695693
}
696694

697695
FOREACH_DIRENT_ALL(de, dir, return -errno) {
@@ -751,12 +749,10 @@ static int enumerator_scan_dir(
751749

752750
dir = opendir(path);
753751
if (!dir) {
754-
bool ignore = errno == ENOENT;
752+
if (errno == ENOENT)
753+
return 0;
755754

756-
log_debug_errno(errno,
757-
"sd-device-enumerator: Failed to open directory %s%s: %m",
758-
path, ignore ? ", ignoring" : "");
759-
return ignore ? 0 : -errno;
755+
return log_debug_errno(errno, "sd-device-enumerator: Failed to open directory '%s': %m", path);
760756
}
761757

762758
FOREACH_DIRENT_ALL(de, dir, return -errno) {
@@ -788,12 +784,10 @@ static int enumerator_scan_devices_tag(sd_device_enumerator *enumerator, const c
788784

789785
dir = opendir(path);
790786
if (!dir) {
791-
bool ignore = errno == ENOENT;
787+
if (errno == ENOENT)
788+
return 0;
792789

793-
log_debug_errno(errno,
794-
"sd-device-enumerator: Failed to open directory %s%s: %m",
795-
path, ignore ? ", ignoring" : "");
796-
return ignore ? 0 : -errno;
790+
return log_debug_errno(errno, "sd-device-enumerator: Failed to open directory '%s': %m", path);
797791
}
798792

799793
/* TODO: filter away subsystems? */
@@ -876,12 +870,10 @@ static int parent_crawl_children(sd_device_enumerator *enumerator, const char *p
876870

877871
dir = opendir(path);
878872
if (!dir) {
879-
bool ignore = errno == ENOENT;
873+
if (errno == ENOENT)
874+
return 0;
880875

881-
log_debug_errno(errno,
882-
"sd-device-enumerator: Failed to open directory %s%s: %m",
883-
path, ignore ? ", ignoring" : "");
884-
return ignore ? 0 : -errno;
876+
return log_debug_errno(errno, "sd-device-enumerator: Failed to open directory '%s': %m", path);
885877
}
886878

887879
FOREACH_DIRENT_ALL(de, dir, return -errno) {

0 commit comments

Comments
 (0)