]> git.ipfire.org Git - thirdparty/systemd.git/blobdiff - src/basic/unit-name.c
Add SPDX license identifiers to source files under the LGPL
[thirdparty/systemd.git] / src / basic / unit-name.c
index ba9928375ee457a7b10da60ee52e011c5249f09d..8ef80ca6a8e75ce38b22fae6ce5e5146ac91577b 100644 (file)
@@ -1,3 +1,4 @@
+/* SPDX-License-Identifier: LGPL-2.1+ */
 /***
   This file is part of systemd.
 
@@ -382,19 +383,14 @@ int unit_name_path_escape(const char *f, char **ret) {
         if (STR_IN_SET(p, "/", ""))
                 s = strdup("-");
         else {
-                char *e;
-
                 if (!path_is_safe(p))
                         return -EINVAL;
 
                 /* Truncate trailing slashes */
-                e = endswith(p, "/");
-                if (e)
-                        *e = 0;
+                delete_trailing_chars(p, "/");
 
                 /* Truncate leading slashes */
-                if (p[0] == '/')
-                        p++;
+                p = skip_leading_chars(p, "/");
 
                 s = unit_name_escape(p);
         }