summaryrefslogtreecommitdiffstats
path: root/src/basic
diff options
context:
space:
mode:
authorMike Yuan <me@yhndnzj.com>2024-04-05 20:06:38 +0200
committerMike Yuan <me@yhndnzj.com>2024-04-05 20:16:53 +0200
commit99f3b67f3ffbf7a4f6ee311e3732a07250caf7c7 (patch)
tree462460fee564015588df39c319cc2a33c86863c5 /src/basic
parentMerge pull request #31435 from bluca/portable_fix_versioned (diff)
downloadsystemd-99f3b67f3ffbf7a4f6ee311e3732a07250caf7c7.tar.xz
systemd-99f3b67f3ffbf7a4f6ee311e3732a07250caf7c7.zip
os-util: use ENDSWITH_SET where appropriate
Addresses https://github.com/systemd/systemd/pull/31435#discussion_r1553969156 Co-authored-by: Lennart Poettering <lennart@poettering.net>
Diffstat (limited to 'src/basic')
-rw-r--r--src/basic/os-util.c13
1 files changed, 4 insertions, 9 deletions
diff --git a/src/basic/os-util.c b/src/basic/os-util.c
index 985d89bc7e..0d26d189d1 100644
--- a/src/basic/os-util.c
+++ b/src/basic/os-util.c
@@ -72,16 +72,11 @@ int path_extract_image_name(const char *path, char **ret) {
r = path_extract_filename(path, &fn);
if (r < 0)
return r;
-
if (r != O_DIRECTORY) {
- /* Chop off any image suffixes we recognize (unless we already know this must refer to some dir */
- FOREACH_STRING(suffix, ".sysext.raw", ".confext.raw", ".raw") {
- char *m = endswith(fn, suffix);
- if (m) {
- *m = 0;
- break;
- }
- }
+ /* Chop off any image suffixes we recognize (unless we already know this must refer to some dir) */
+ char *m = ENDSWITH_SET(fn, ".sysext.raw", ".confext.raw", ".raw");
+ if (m)
+ *m = 0;
}
/* Truncate the version/counting suffixes */