]> git.ipfire.org Git - thirdparty/systemd.git/commit
sd-device: use path_compare() rather than strcmp() for sorting paths 22821/head
authorLennart Poettering <lennart@poettering.net>
Tue, 22 Mar 2022 11:58:55 +0000 (12:58 +0100)
committerLennart Poettering <lennart@poettering.net>
Tue, 22 Mar 2022 12:10:41 +0000 (13:10 +0100)
commit63aac21c5e91473e25dcfcc1d00396c0c02316cf
treedf29e7a5f7fcdecfde4c9c7ac8b788c518954bc4
parenta3f47f48b085a23ee006b66b2fc7e534be12378f
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