From c7d6ebb13e1d3df0726735ce48861931318fe7de Mon Sep 17 00:00:00 2001 From: Yu Watanabe Date: Fri, 4 Jun 2021 17:28:34 +0900 Subject: [PATCH] sd-device: do not try to read uevent file multiple times --- src/libsystemd/sd-device/sd-device.c | 13 ++++--------- 1 file changed, 4 insertions(+), 9 deletions(-) diff --git a/src/libsystemd/sd-device/sd-device.c b/src/libsystemd/sd-device/sd-device.c index ecb4c429c77..f31416da530 100644 --- a/src/libsystemd/sd-device/sd-device.c +++ b/src/libsystemd/sd-device/sd-device.c @@ -539,22 +539,17 @@ int device_read_uevent_file(sd_device *device) { if (r < 0) return r; + device->uevent_loaded = true; + path = strjoina(syspath, "/uevent"); r = read_full_virtual_file(path, &uevent, &uevent_len); - if (r == -EACCES) { - /* empty uevent files may be write-only */ - device->uevent_loaded = true; - return 0; - } - if (r == -ENOENT) - /* some devices may not have uevent files, see device_set_syspath() */ + if (IN_SET(r, -EACCES, -ENOENT)) + /* The uevent files may be write-only, or the device may not have uevent file. */ return 0; if (r < 0) return log_device_debug_errno(device, r, "sd-device: Failed to read uevent file '%s': %m", path); - device->uevent_loaded = true; - for (size_t i = 0; i < uevent_len; i++) switch (state) { case PRE_KEY: -- 2.47.3