diff options
author | Luca Boccassi <bluca@debian.org> | 2024-01-01 19:26:39 +0100 |
---|---|---|
committer | GitHub <noreply@github.com> | 2024-01-01 19:26:39 +0100 |
commit | 86b8b66675d2ec34614ffc4ae972e691abe216e3 (patch) | |
tree | 9d88b6bdc51a32f14a93b8d2209c4e5a1f9913a7 /src/libsystemd/sd-device/device-monitor.c | |
parent | Merge pull request #30593 from yuwata/sd-dhcp-duid (diff) | |
parent | tree-wide: use device_in_subsystem() and device_is_devtype() (diff) | |
download | systemd-86b8b66675d2ec34614ffc4ae972e691abe216e3.tar.xz systemd-86b8b66675d2ec34614ffc4ae972e691abe216e3.zip |
Merge pull request #30591 from yuwata/device-util
device-util: introduce device_in_subsystem() and device_is_devtype() helper functions
Diffstat (limited to 'src/libsystemd/sd-device/device-monitor.c')
-rw-r--r-- | src/libsystemd/sd-device/device-monitor.c | 19 |
1 files changed, 6 insertions, 13 deletions
diff --git a/src/libsystemd/sd-device/device-monitor.c b/src/libsystemd/sd-device/device-monitor.c index bb4f9bd513..49ab56adcb 100644 --- a/src/libsystemd/sd-device/device-monitor.c +++ b/src/libsystemd/sd-device/device-monitor.c @@ -402,8 +402,7 @@ static sd_device_monitor *device_monitor_free(sd_device_monitor *m) { DEFINE_PUBLIC_TRIVIAL_REF_UNREF_FUNC(sd_device_monitor, sd_device_monitor, device_monitor_free); static int check_subsystem_filter(sd_device_monitor *m, sd_device *device) { - const char *s, *subsystem, *d, *devtype = NULL; - int r; + const char *s, *d; assert(m); assert(device); @@ -411,20 +410,14 @@ static int check_subsystem_filter(sd_device_monitor *m, sd_device *device) { if (hashmap_isempty(m->subsystem_filter)) return true; - r = sd_device_get_subsystem(device, &subsystem); - if (r < 0) - return r; - - r = sd_device_get_devtype(device, &devtype); - if (r < 0 && r != -ENOENT) - return r; - HASHMAP_FOREACH_KEY(d, s, m->subsystem_filter) { - if (!streq(s, subsystem)) + if (!device_in_subsystem(device, s)) continue; - if (!d || streq_ptr(d, devtype)) - return true; + if (d && !device_is_devtype(device, d)) + continue; + + return true; } return false; |