]> git.ipfire.org Git - thirdparty/systemd.git/commitdiff
os-util: use ENDSWITH_SET where appropriate
authorMike Yuan <me@yhndnzj.com>
Fri, 5 Apr 2024 18:06:38 +0000 (02:06 +0800)
committerMike Yuan <me@yhndnzj.com>
Fri, 5 Apr 2024 18:16:53 +0000 (02:16 +0800)
Addresses https://github.com/systemd/systemd/pull/31435#discussion_r1553969156

Co-authored-by: Lennart Poettering <lennart@poettering.net>
src/basic/os-util.c

index 985d89bc7eb5465cfa02c153cead025ca75a354d..0d26d189d16d807d2572760c91bca1c52172ab6f 100644 (file)
@@ -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 */