summaryrefslogtreecommitdiff
path: root/src/locale
diff options
context:
space:
mode:
authorLennart Poettering <lennart@poettering.net>2023-01-20 13:14:42 +0100
committerLennart Poettering <lennart@poettering.net>2023-01-20 17:27:51 +0100
commite8bec6242bf763afa7de7843d1daae567651c249 (patch)
tree9aba006f260fa4748530edc19fcf6f7a5bd9351d /src/locale
parent71c6f0ac524e174800a23410b121bee45f9e3f67 (diff)
downloadsystemd-e8bec6242bf763afa7de7843d1daae567651c249.tar.gz
string-util: add new strdupcspn()/strdupspn()
These combine strndup() + strspn()/strcspn() into one. There are a bunch of strndupa() calls that could use similar treatment (or should be converted to strdup[c]spn(), but this commit doesn't bother with that.
Diffstat (limited to 'src/locale')
-rw-r--r--src/locale/localed-util.c4
1 files changed, 3 insertions, 1 deletions
diff --git a/src/locale/localed-util.c b/src/locale/localed-util.c
index ddca11d908..4f2d3aaeb8 100644
--- a/src/locale/localed-util.c
+++ b/src/locale/localed-util.c
@@ -505,7 +505,9 @@ int find_legacy_keymap(Context *c, char **ret) {
/* If that didn't work, strip off the
* other layouts from the entry, too */
- x = strndup(a[1], strcspn(a[1], ","));
+ x = strdupcspn(a[1], ",");
+ if (!x)
+ return -ENOMEM;
if (startswith_comma(c->x11_layout, x))
matching = 1;
}