From a3f47f48b085a23ee006b66b2fc7e534be12378f Mon Sep 17 00:00:00 2001 From: Lennart Poettering Date: Tue, 22 Mar 2022 12:58:31 +0100 Subject: [PATCH 1/2] sd-device: fix trivial typo --- src/libsystemd/sd-device/device-enumerator-private.h | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/libsystemd/sd-device/device-enumerator-private.h b/src/libsystemd/sd-device/device-enumerator-private.h index 54fc13c43b..11378d8937 100644 --- a/src/libsystemd/sd-device/device-enumerator-private.h +++ b/src/libsystemd/sd-device/device-enumerator-private.h @@ -12,8 +12,8 @@ typedef enum MatchInitializedType { _MATCH_INITIALIZED_INVALID = -EINVAL, } MatchInitializedType; -int device_enumerator_scan_devices(sd_device_enumerator *enumeartor); -int device_enumerator_scan_subsystems(sd_device_enumerator *enumeartor); +int device_enumerator_scan_devices(sd_device_enumerator *enumerator); +int device_enumerator_scan_subsystems(sd_device_enumerator *enumerator); int device_enumerator_scan_devices_and_subsystems(sd_device_enumerator *enumerator); int device_enumerator_add_device(sd_device_enumerator *enumerator, sd_device *device); int device_enumerator_add_match_is_initialized(sd_device_enumerator *enumerator, MatchInitializedType type); From 63aac21c5e91473e25dcfcc1d00396c0c02316cf Mon Sep 17 00:00:00 2001 From: Lennart Poettering Date: Tue, 22 Mar 2022 12:58:55 +0100 Subject: [PATCH 2/2] sd-device: use path_compare() rather than strcmp() for sorting paths When sorting paths it actually matters to use the right comparison function. Example: ``` a/x a-b/y a_/z ``` I think people would probably expect this: ``` a/x a-b/y a_a/z ``` but if you use strcmp() instead of path_compare() you'd instead get: ``` a-b/y a/x a_a/z ``` That's because `/` is between `-` and `a` in the ascii table. I think that's quite confusing, and we shouldn#t order that way hence. As discussed: https://github.com/systemd/systemd/pull/22662#discussion_r831174776 --- src/libsystemd/sd-device/device-enumerator.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/libsystemd/sd-device/device-enumerator.c b/src/libsystemd/sd-device/device-enumerator.c index 1379764156..14794fb3af 100644 --- a/src/libsystemd/sd-device/device-enumerator.c +++ b/src/libsystemd/sd-device/device-enumerator.c @@ -323,7 +323,7 @@ static int device_compare(sd_device * const *a, sd_device * const *b) { if (r != 0) return r; - return strcmp(devpath_a, devpath_b); + return path_compare(devpath_a, devpath_b); } static int enumerator_sort_devices(sd_device_enumerator *enumerator) {