summaryrefslogtreecommitdiff
path: root/src/libsystemd
diff options
context:
space:
mode:
authorLennart Poettering <lennart@poettering.net>2023-04-14 12:48:14 +0200
committerLennart Poettering <lennart@poettering.net>2023-04-14 16:56:15 +0200
commitd791013ff529cbbb74d4cc5f1455f172befab1e6 (patch)
treea52a2742502f99537ba58cdae318336c89687aba /src/libsystemd
parentbb7b1da8fedd9ba057809a8aca06594c56f0a409 (diff)
downloadsystemd-d791013ff529cbbb74d4cc5f1455f172befab1e6.tar.gz
string-util: add strstrafter()
strstrafter() is like strstr() but returns a pointer to the first character *after* the found substring, not on the substring itself. Quite often this is what we actually want. Inspired by #27267 I think it makes sense to add a helper for this, to avoid the potentially fragile manual pointer increment afterwards.
Diffstat (limited to 'src/libsystemd')
-rw-r--r--src/libsystemd/sd-device/device-enumerator.c3
1 files changed, 1 insertions, 2 deletions
diff --git a/src/libsystemd/sd-device/device-enumerator.c b/src/libsystemd/sd-device/device-enumerator.c
index 0bd2c89eb6..f3f59e2ac3 100644
--- a/src/libsystemd/sd-device/device-enumerator.c
+++ b/src/libsystemd/sd-device/device-enumerator.c
@@ -281,11 +281,10 @@ static int sound_device_compare(const char *devpath_a, const char *devpath_b) {
* kernel makes this guarantee when creating those devices, and hence we should too when
* enumerating them. */
- sound_a = strstr(devpath_a, "/sound/card");
+ sound_a = strstrafter(devpath_a, "/sound/card");
if (!sound_a)
return 0;
- sound_a += STRLEN("/sound/card");
sound_a = strchr(devpath_a, '/');
if (!sound_a)
return 0;