]> git.ipfire.org Git - thirdparty/systemd.git/commitdiff
tree-wide: always drop unnecessary dot in path
authorYu Watanabe <watanabe.yu+github@gmail.com>
Sat, 8 May 2021 08:43:49 +0000 (17:43 +0900)
committerYu Watanabe <watanabe.yu+github@gmail.com>
Fri, 28 May 2021 04:44:38 +0000 (13:44 +0900)
41 files changed:
src/basic/cgroup-util.c
src/basic/fileio.c
src/basic/fs-util.c
src/basic/path-util.c
src/basic/path-util.h
src/basic/sysctl-util.c
src/basic/tmpfile-util.c
src/basic/unit-name.c
src/basic/user-util.c
src/cgls/cgls.c
src/cgtop/cgtop.c
src/core/automount.c
src/core/cgroup.c
src/core/dbus-execute.c
src/core/dbus-path.c
src/core/dbus-service.c
src/core/dbus-socket.c
src/core/dbus-unit.c
src/core/execute.c
src/core/load-fragment.c
src/core/manager.c
src/core/mount.c
src/core/service.c
src/core/socket.c
src/core/swap.c
src/core/unit.c
src/delta/delta.c
src/fstab-generator/fstab-generator.c
src/libsystemd/sd-device/sd-device.c
src/mount/mount-tool.c
src/portable/portable.c
src/shared/discover-image.c
src/shared/install.c
src/shared/mount-setup.c
src/shared/parse-argument.c
src/sysusers/sysusers.c
src/test/test-path-util.c
src/test/test-tmpfile-util.c
src/test/test-unit-name.c
src/tmpfiles/tmpfiles.c
src/udev/test-udev-event.c

index e39bfd9bc747ac16024be261abcf28b9f41a406b..1ff6160dc88d86ad606a6ba7f45b07d0c3b31ac7 100644 (file)
@@ -506,7 +506,7 @@ int cg_get_path(const char *controller, const char *path, const char *suffix, ch
                 if (!t)
                         return -ENOMEM;
 
-                *fs = path_simplify(t, false);
+                *fs = path_simplify(t);
                 return 0;
         }
 
@@ -523,7 +523,7 @@ int cg_get_path(const char *controller, const char *path, const char *suffix, ch
         if (r < 0)
                 return r;
 
-        path_simplify(*fs, false);
+        path_simplify(*fs);
         return 0;
 }
 
@@ -919,7 +919,7 @@ int cg_split_spec(const char *spec, char **ret_controller, char **ret_path) {
                         if (!path)
                                 return -ENOMEM;
 
-                        path_simplify(path, false);
+                        path_simplify(path);
                 }
 
         } else {
@@ -942,7 +942,7 @@ int cg_split_spec(const char *spec, char **ret_controller, char **ret_path) {
                                     !path_is_absolute(path))
                                         return -EINVAL;
 
-                                path_simplify(path, false);
+                                path_simplify(path);
                         }
 
                 } else {
@@ -979,7 +979,7 @@ int cg_mangle_path(const char *path, char **result) {
                 if (!t)
                         return -ENOMEM;
 
-                *result = path_simplify(t, false);
+                *result = path_simplify(t);
                 return 0;
         }
 
index 16f36359ebca002c0f047434ab4698cce910cf91..213f9cef7b682897457646f3663672bf9e1f2531 100644 (file)
@@ -972,7 +972,7 @@ static int search_and_fopen_internal(
                 f = fopen(p, mode);
                 if (f) {
                         if (ret_path)
-                                *ret_path = path_simplify(TAKE_PTR(p), true);
+                                *ret_path = path_simplify(TAKE_PTR(p));
 
                         *ret = f;
                         return 0;
@@ -1013,7 +1013,7 @@ int search_and_fopen(
                         if (!p)
                                 return -ENOMEM;
 
-                        *ret_path = path_simplify(p, true);
+                        *ret_path = path_simplify(p);
                 }
 
                 *ret = TAKE_PTR(f);
@@ -1051,7 +1051,7 @@ int search_and_fopen_nulstr(
                         if (!p)
                                 return -ENOMEM;
 
-                        *ret_path = path_simplify(p, true);
+                        *ret_path = path_simplify(p);
                 }
 
                 *ret = TAKE_PTR(f);
index e9fdb75a232d92ef2f640fa2d10c18d923a47efe..f2999ba077faab393b61c7933f33a0be3e1d53fe 100644 (file)
@@ -866,7 +866,7 @@ int chase_symlinks(const char *path, const char *original_root, unsigned flags,
                  * anyway. Moreover at the end of this function after processing everything we'll always turn
                  * the empty string back to "/". */
                 delete_trailing_chars(root, "/");
-                path_simplify(root, true);
+                path_simplify(root);
 
                 if (flags & CHASE_PREFIX_ROOT) {
                         /* We don't support relative paths in combination with a root directory */
index 0be5af8da156a549ec3d133dce0b10cc3bb9e5c1..82d6a28257a6f742bbd05e73a8f5efc8f4707089 100644 (file)
@@ -145,7 +145,7 @@ int path_make_relative(const char *from, const char *to, char **ret) {
                                 if (!result)
                                         return -ENOMEM;
 
-                                path_simplify(result, true);
+                                path_simplify(result);
 
                                 if (!path_is_valid(result))
                                         return -EINVAL;
@@ -191,7 +191,7 @@ int path_make_relative(const char *from, const char *to, char **ret) {
 
         strcpy(p, t);
 
-        path_simplify(result, true);
+        path_simplify(result);
 
         if (!path_is_valid(result))
                 return -EINVAL;
@@ -227,7 +227,7 @@ int path_strv_make_absolute_cwd(char **l) {
                 if (r < 0)
                         return r;
 
-                path_simplify(t, false);
+                path_simplify(t);
                 free_and_replace(*s, t);
         }
 
@@ -327,7 +327,7 @@ char **path_strv_resolve_uniq(char **l, const char *root) {
         return strv_uniq(l);
 }
 
-char *path_simplify(char *path, bool kill_dots) {
+char *path_simplify(char *path) {
         char *f, *t;
         bool slash = false, ignore_slash = false, absolute;
 
@@ -348,7 +348,7 @@ char *path_simplify(char *path, bool kill_dots) {
         absolute = path_is_absolute(path);
 
         f = path;
-        if (kill_dots && *f == '.' && IN_SET(f[1], 0, '/')) {
+        if (*f == '.' && IN_SET(f[1], 0, '/')) {
                 ignore_slash = true;
                 f++;
         }
@@ -361,7 +361,7 @@ char *path_simplify(char *path, bool kill_dots) {
                 }
 
                 if (slash) {
-                        if (kill_dots && *f == '.' && IN_SET(f[1], 0, '/'))
+                        if (*f == '.' && IN_SET(f[1], 0, '/'))
                                 continue;
 
                         slash = false;
@@ -418,7 +418,7 @@ int path_simplify_and_warn(
                                           lvalue, fatal ? "" : ", ignoring", path);
         }
 
-        path_simplify(path, true);
+        path_simplify(path);
 
         if (!path_is_valid(path))
                 return log_syntax(unit, LOG_ERR, filename, line, SYNTHETIC_ERRNO(EINVAL),
@@ -711,7 +711,7 @@ int find_executable_full(const char *name, bool use_path_envvar, char **ret_file
 
                 /* Found it! */
                 if (ret_filename)
-                        *ret_filename = path_simplify(TAKE_PTR(element), false);
+                        *ret_filename = path_simplify(TAKE_PTR(element));
                 if (ret_fd)
                         *ret_fd = TAKE_FD(fd);
 
@@ -1116,7 +1116,7 @@ int path_extract_directory(const char *path, char **ret) {
         if (!a)
                 return -ENOMEM;
 
-        path_simplify(a, true);
+        path_simplify(a);
 
         if (!path_is_valid(a))
                 return -EINVAL;
index e447608d40b0436eeb5124741342bc36c28a4ac5..c6d4668794bfd8235b508da18507a0614534fb49 100644 (file)
@@ -71,7 +71,7 @@ char* path_extend_internal(char **x, ...);
 #define path_extend(x, ...) path_extend_internal(x, __VA_ARGS__, POINTER_MAX)
 #define path_join(...) path_extend_internal(NULL, __VA_ARGS__, POINTER_MAX)
 
-char* path_simplify(char *path, bool kill_dots);
+char* path_simplify(char *path);
 
 enum {
         PATH_CHECK_FATAL    = 1 << 0,  /* If not set, then error message is appended with 'ignoring'. */
@@ -109,7 +109,7 @@ int fsck_exists(const char *fstype);
  * directory. Excludes the specified directory itself */
 #define PATH_FOREACH_PREFIX(prefix, path)                               \
         for (char *_slash = ({                                          \
-                                path_simplify(strcpy(prefix, path), false); \
+                                path_simplify(strcpy(prefix, path));    \
                                 streq(prefix, "/") ? NULL : strrchr(prefix, '/'); \
                         });                                             \
              _slash && ((*_slash = 0), true);                           \
@@ -118,7 +118,7 @@ int fsck_exists(const char *fstype);
 /* Same as PATH_FOREACH_PREFIX but also includes the specified path itself */
 #define PATH_FOREACH_PREFIX_MORE(prefix, path)                          \
         for (char *_slash = ({                                          \
-                                path_simplify(strcpy(prefix, path), false); \
+                                path_simplify(strcpy(prefix, path));    \
                                 if (streq(prefix, "/"))                 \
                                         prefix[0] = 0;                  \
                                 strrchr(prefix, 0);                     \
index c96b5cd77f0eddd7be061edd28dafa71646c1dbf..8913e6ff85bf962afe2e1627ea6b31505b8ae994 100644 (file)
@@ -33,7 +33,7 @@ char *sysctl_normalize(char *s) {
                         n = strpbrk(n + 1, "/.");
                 } while (n);
 
-        path_simplify(s, true);
+        path_simplify(s);
 
         /* Kill the leading slash, but keep the first character of the string in the same place. */
         if (*s == '/' && *(s+1))
index 9eb654c1407bf18180f5caab0bca91c9de4efaca..91c8ff172549a992b30e3cf3a22354df4b6bb0ca 100644 (file)
@@ -126,7 +126,7 @@ int tempfn_xxxxxx(const char *p, const char *extra, char **ret) {
                 if (!path_extend(&d, nf))
                         return -ENOMEM;
 
-                *ret = path_simplify(TAKE_PTR(d), false);
+                *ret = path_simplify(TAKE_PTR(d));
         } else
                 *ret = TAKE_PTR(nf);
 
@@ -168,7 +168,7 @@ int tempfn_random(const char *p, const char *extra, char **ret) {
                 if (!path_extend(&d, nf))
                         return -ENOMEM;
 
-                *ret = path_simplify(TAKE_PTR(d), false);
+                *ret = path_simplify(TAKE_PTR(d));
         } else
                 *ret = TAKE_PTR(nf);
 
@@ -213,7 +213,7 @@ int tempfn_random_child(const char *p, const char *extra, char **ret) {
 
         *x = 0;
 
-        *ret = path_simplify(t, false);
+        *ret = path_simplify(t);
         return 0;
 }
 
index dbc9f5baa26886cd320b4e61824cd7a12573796b..29ffd81ea9a576b1c4ac7c482d8cbbf4a21e5445 100644 (file)
@@ -387,7 +387,7 @@ int unit_name_path_escape(const char *f, char **ret) {
         if (!p)
                 return -ENOMEM;
 
-        path_simplify(p, false);
+        path_simplify(p);
 
         if (empty_or_root(p))
                 s = strdup("-");
index 3756e80c30d799742b8d8cf20e55cdfefa8c2768..385ec514b4171832aa948be95a2f658febc7fffb 100644 (file)
@@ -571,7 +571,7 @@ int get_home_dir(char **_h) {
                 if (!h)
                         return -ENOMEM;
 
-                *_h = path_simplify(h, true);
+                *_h = path_simplify(h);
                 return 0;
         }
 
@@ -609,7 +609,7 @@ int get_home_dir(char **_h) {
         if (!h)
                 return -ENOMEM;
 
-        *_h = path_simplify(h, true);
+        *_h = path_simplify(h);
         return 0;
 }
 
@@ -628,7 +628,7 @@ int get_shell(char **_s) {
                 if (!s)
                         return -ENOMEM;
 
-                *_s = path_simplify(s, true);
+                *_s = path_simplify(s);
                 return 0;
         }
 
@@ -666,7 +666,7 @@ int get_shell(char **_s) {
         if (!s)
                 return -ENOMEM;
 
-        *_s = path_simplify(s, true);
+        *_s = path_simplify(s);
         return 0;
 }
 
index 6868049c18f36a4b0d979c2f726e7440047afda5..f39aa53da0b9123e3deec4fa064449e10abef223 100644 (file)
@@ -243,7 +243,7 @@ static int run(int argc, char *argv[]) {
                                         if (!j)
                                                 return log_oom();
 
-                                        path_simplify(j, false);
+                                        path_simplify(j);
                                         path = j;
                                 } else
                                         path = root;
index 5424f2c90f78cee45f545eff639a9ce650092031..9cc2f275918a22f458f7aac9c1fd24d184c2dc19 100644 (file)
@@ -472,7 +472,7 @@ static int refresh_one(
                 if (!p)
                         return -ENOMEM;
 
-                path_simplify(p, false);
+                path_simplify(p);
 
                 r = refresh_one(controller, p, a, b, iteration, depth + 1, &child);
                 if (r < 0)
index dc92f9c0e4456f0411affc27985081bb288f6fb9..8d75346d97c26d1a195152da2f6bcfec56d7a7d4 100644 (file)
@@ -199,7 +199,7 @@ static int automount_set_where(Automount *a) {
         if (r < 0)
                 return r;
 
-        path_simplify(a->where, false);
+        path_simplify(a->where);
         return 1;
 }
 
index 5b00faa6f6297f6483025348e77f0261e4a7c7a6..6a46e14556d60bb4c7f306b818cc09f8c070768f 100644 (file)
@@ -2113,7 +2113,7 @@ static int unit_attach_pid_to_cgroup_via_bus(Unit *u, pid_t pid, const char *suf
                 return -EINVAL;
 
         pp = strjoina("/", pp, suffix_path);
-        path_simplify(pp, false);
+        path_simplify(pp);
 
         r = sd_bus_call_method(u->manager->system_bus,
                                "org.freedesktop.systemd1",
index 9c141d73b1052dc7a768ee51e3cd564657737214..50daef67021e748af9f375bd6fba202e504d1dca 100644 (file)
@@ -1451,7 +1451,7 @@ int bus_set_transient_exec_command(
                         } else
                                 c->flags = b ? EXEC_COMMAND_IGNORE_FAILURE : 0;
 
-                        path_simplify(c->path, false);
+                        path_simplify(c->path);
                         exec_command_append_list(exec_command, c);
                 }
 
@@ -3062,7 +3062,7 @@ int bus_exec_context_set_transient_property(
                         if (!path_is_absolute(i + offset))
                                 return sd_bus_error_setf(error, SD_BUS_ERROR_INVALID_ARGS, "Invalid %s", name);
 
-                        path_simplify(i + offset, false);
+                        path_simplify(i + offset);
                 }
 
                 if (!UNIT_WRITE_FLAGS_NOOP(flags)) {
index e132cd2b3cf94f021b5f7223a1914bb4af007951..e025c31532ce2b8c423754551d3bca1b6278251f 100644 (file)
@@ -103,7 +103,7 @@ static int bus_path_set_transient_property(
                                 if (!k)
                                         return -ENOMEM;
 
-                                path_simplify(k, false);
+                                path_simplify(k);
 
                                 s = new0(PathSpec, 1);
                                 if (!s)
index 4dea8d5aec1f333e0d214f18a4b16b658e797543..13d555041e5a354c122acfae16da53b1d0d5de60 100644 (file)
@@ -475,7 +475,7 @@ static int bus_service_set_transient_property(
                         if (!n)
                                 return -ENOMEM;
 
-                        path_simplify(n, true);
+                        path_simplify(n);
 
                         if (!path_is_normalized(n))
                                 return sd_bus_error_setf(error, SD_BUS_ERROR_INVALID_ARGS, "PIDFile= path '%s' is not valid", n);
index 2c9da7412a1f78be780a3678eaa5d6a9ad698a31..61c2f1a19938c79020129108886a0cab7520b64d 100644 (file)
@@ -390,7 +390,7 @@ static int bus_socket_set_transient_property(
                                 if (!p->path)
                                         return log_oom();
 
-                                path_simplify(p->path, false);
+                                path_simplify(p->path);
 
                         } else if (streq(t, "Netlink")) {
                                 r = socket_address_parse_netlink(&p->address, a);
index 8875ba082d14cc765dc2be33c9dbbb8db6c9db71..6c04c6e5db8962cc2969e5905d4717a495f88643 100644 (file)
@@ -2265,7 +2265,7 @@ static int bus_unit_set_transient_property(
                         return r;
 
                 STRV_FOREACH(p, l) {
-                        path_simplify(*p, true);
+                        path_simplify(*p);
 
                         if (!path_is_absolute(*p))
                                 return sd_bus_error_setf(error, SD_BUS_ERROR_INVALID_ARGS, "Path specified in %s is not absolute: %s", name, *p);
index f577b790e6afdd1c76f1e37c0f367bdcb61960e8..3d750ee06ea537c58ca0b2836c0f7f5524fceedf 100644 (file)
@@ -1846,7 +1846,7 @@ static int build_environment(
                 if (!x)
                         return -ENOMEM;
 
-                path_simplify(x + 5, true);
+                path_simplify(x + 5);
                 our_env[n_env++] = x;
         }
 
@@ -1867,7 +1867,7 @@ static int build_environment(
                 if (!x)
                         return -ENOMEM;
 
-                path_simplify(x + 6, true);
+                path_simplify(x + 6);
                 our_env[n_env++] = x;
         }
 
index d31d6420170fe4edde58eadb0ef76a8c6adbf3f0..c6fca7135ccf6221377df97b68c04509dd49f70f 100644 (file)
@@ -810,7 +810,7 @@ int config_parse_exec(
                         n[nlen] = NULL;
                 }
 
-                path_simplify(path, false);
+                path_simplify(path);
 
                 while (!isempty(p)) {
                         _cleanup_free_ char *word = NULL, *resolved = NULL;
index 419bab5b9d7966f92d157a6b1e0a37664545486b..d96280667a67bd202331fdc278fbc7ee62623b36 100644 (file)
@@ -4589,7 +4589,7 @@ Set *manager_get_units_requiring_mounts_for(Manager *m, const char *path) {
         assert(path);
 
         strcpy(p, path);
-        path_simplify(p, false);
+        path_simplify(p);
 
         return hashmap_get(m->units_requiring_mounts_for, streq(p, "/") ? "" : p);
 }
index b496268164510ae64889e6371b6abce7b1617831..07d8e7b98574acc44ed0c3ee4dfc0116bb2e8b32 100644 (file)
@@ -634,7 +634,7 @@ static int mount_add_extras(Mount *m) {
                         return r;
         }
 
-        path_simplify(m->where, false);
+        path_simplify(m->where);
 
         if (!u->description) {
                 r = unit_set_description(u, m->where);
index f11b8f55579223e0440837ff9b849899baae719a..792ec99a00b80b995d90129fcf00e9d6e724c5eb 100644 (file)
@@ -3148,7 +3148,7 @@ static int service_demand_pid_file(Service *s) {
                 return -ENOMEM;
         }
 
-        path_simplify(ps->path, false);
+        path_simplify(ps->path);
 
         /* PATH_CHANGED would not be enough. There are daemons (sendmail) that
          * keep their PID file open all the time. */
index 8be01aa8e18cc9f3cfc3ec9db8bb998cfe296e9c..10777e4e8082e29febdf8c2eee7347173b9c9b8f 100644 (file)
@@ -1347,7 +1347,7 @@ static int usbffs_dispatch_eps(SocketPort *p) {
                         goto fail;
                 }
 
-                path_simplify(ep, false);
+                path_simplify(ep);
 
                 r = usbffs_address_create(ep);
                 if (r < 0)
index a81b1928b89986fc432b4fa4d6e14da5b5a57701..74da2428c2993d21375899180c9b521316668b8f 100644 (file)
@@ -342,7 +342,7 @@ static int swap_add_extras(Swap *s) {
                         return -ENOMEM;
         }
 
-        path_simplify(s->what, false);
+        path_simplify(s->what);
 
         if (!UNIT(s)->description) {
                 r = unit_set_description(UNIT(s), s->what);
index 9c97a9274635c1b5fa8b1ab9dcc74aa3a8ce256f..e48e7602c27c3a08b1d1c6a0339ea45022f377e5 100644 (file)
@@ -4601,7 +4601,7 @@ int unit_require_mounts_for(Unit *u, const char *path, UnitDependencyMask mask)
         if (!p)
                 return -ENOMEM;
 
-        path = path_simplify(p, true);
+        path = path_simplify(p);
 
         if (!path_is_normalized(path))
                 return -EPERM;
index 8c702459c1ea5583f91cf42883dc1fa52ecb41b7..9ebe435a498e4ca7d18d46c01149f05504ede824 100644 (file)
@@ -656,7 +656,7 @@ static int run(int argc, char *argv[]) {
                 int i;
 
                 for (i = optind; i < argc; i++) {
-                        path_simplify(argv[i], false);
+                        path_simplify(argv[i]);
 
                         k = process_suffix_chop(argv[i]);
                         if (k < 0)
index 1d8ee93013a93226e27c367b6a344ccfb91d916e..a4e3ea531101a485d4f14c589de0be830274a443 100644 (file)
@@ -610,7 +610,7 @@ static int parse_fstab(bool initrd) {
                         return log_oom();
 
                 if (is_path(where)) {
-                        path_simplify(where, false);
+                        path_simplify(where);
 
                         /* Follow symlinks here; see 5261ba901845c084de5a8fd06500ed09bfb0bd80 which makes sense for
                          * mount units, but causes problems since it historically worked to have symlinks in e.g.
index a5bd7d8d84dacd4918e89719b4f77fed097d6658..de0798f4d820fc2092255d7ad964f260c52da587 100644 (file)
@@ -171,7 +171,7 @@ int device_set_syspath(sd_device *device, const char *_syspath, bool verify) {
                                 return -ENOMEM;
 
                         free_and_replace(syspath, new_syspath);
-                        path_simplify(syspath, false);
+                        path_simplify(syspath);
                 }
 
                 if (path_startswith(syspath,  "/sys/devices/")) {
index 2e69a99bc6ff4ab8f2cda30655f33330d5cdac74..1d78ff28c8ae51cae88bff19235c8816440b48db 100644 (file)
@@ -386,7 +386,7 @@ static int parse_argv(int argc, char *argv[]) {
                         if (!arg_mount_what)
                                 return log_oom();
 
-                        path_simplify(arg_mount_what, false);
+                        path_simplify(arg_mount_what);
 
                         if (!path_is_absolute(arg_mount_what))
                                 return log_error_errno(SYNTHETIC_ERRNO(EINVAL),
@@ -403,7 +403,7 @@ static int parse_argv(int argc, char *argv[]) {
                                 if (!arg_mount_where)
                                         return log_oom();
 
-                                path_simplify(arg_mount_where, false);
+                                path_simplify(arg_mount_where);
 
                                 if (!path_is_absolute(arg_mount_where))
                                         return log_error_errno(SYNTHETIC_ERRNO(EINVAL),
@@ -985,7 +985,7 @@ static int action_umount(
                         if (!p)
                                 return log_oom();
 
-                        path_simplify(p, false);
+                        path_simplify(p);
 
                         r = stop_mounts(bus, p);
                         if (r < 0)
index 2eebdc08aeca9493f2223fa4a203fd4c3c15426c..9e33299ed51e3c0ba095ef255e85d3237c8f8cfe 100644 (file)
@@ -688,14 +688,14 @@ static int portable_changes_add(
         if (!p)
                 return -ENOMEM;
 
-        path_simplify(p, false);
+        path_simplify(p);
 
         if (source) {
                 s = strdup(source);
                 if (!s)
                         return -ENOMEM;
 
-                path_simplify(s, false);
+                path_simplify(s);
         }
 
         c[(*n_changes)++] = (PortableChange) {
index 8d04ba04fc3dc33f6b1b6e47b1f50bdf3d5b75ef..c572e8dae814a4c2f07f0e5e41fad0079cf6a053 100644 (file)
@@ -160,7 +160,7 @@ static int image_new(
         if (!i->path)
                 return -ENOMEM;
 
-        path_simplify(i->path, false);
+        path_simplify(i->path);
 
         *ret = TAKE_PTR(i);
 
index 3723ec031c115406eac8617bdaefa99ca1b8d371..48e632f4dfe43339a7506c58766fccd778cf6299 100644 (file)
@@ -289,14 +289,14 @@ int unit_file_changes_add(
         if (!p)
                 return -ENOMEM;
 
-        path_simplify(p, false);
+        path_simplify(p);
 
         if (source) {
                 s = strdup(source);
                 if (!s)
                         return -ENOMEM;
 
-                path_simplify(s, false);
+                path_simplify(s);
         }
 
         c[(*n_changes)++] = (UnitFileChange) {
@@ -515,7 +515,7 @@ static int mark_symlink_for_removal(
         if (!n)
                 return -ENOMEM;
 
-        path_simplify(n, false);
+        path_simplify(n);
 
         r = set_consume(*remove_symlinks_to, n);
         if (r == -EEXIST)
@@ -597,7 +597,7 @@ static int remove_marked_symlinks_fd(
                         p = path_make_absolute(de->d_name, path);
                         if (!p)
                                 return -ENOMEM;
-                        path_simplify(p, false);
+                        path_simplify(p);
 
                         q = chase_symlinks(p, NULL, CHASE_NONEXISTENT, &dest, NULL);
                         if (q == -ENOENT)
index 1e4bbfb1ab0870151eb88bd1f0ab7b02f460fce5..ef3527e9a7f68b035e9277d4c00795111be2c515 100644 (file)
@@ -454,7 +454,7 @@ static int relabel_extra(void) {
                         if (r == 0) /* EOF */
                                 break;
 
-                        path_simplify(line, true);
+                        path_simplify(line);
 
                         if (!path_is_normalized(line)) {
                                 log_warning("Path to relabel is not normalized, ignoring: %s", line);
index 68c55a54c9e8965fb35a5d948e550f3f47f8538c..145bd119ac7a2cc7d2241a9c909e5bb15ac1d824 100644 (file)
@@ -73,7 +73,7 @@ int parse_path_argument(const char *path, bool suppress_root, char **arg) {
         if (r < 0)
                 return log_error_errno(r, "Failed to parse path \"%s\" and make it absolute: %m", path);
 
-        path_simplify(p, false);
+        path_simplify(p);
         if (suppress_root && empty_or_root(p))
                 p = mfree(p);
 
index c9eda29b49f8a34b43bf67e815c415a4097ac95c..d76556e75d300194b1765d12f4a6e9fa22e8e9c7 100644 (file)
@@ -1651,7 +1651,7 @@ static int parse_line(const char *fname, unsigned line, const char *buffer) {
                 if (resolved_id) {
                         if (path_is_absolute(resolved_id)) {
                                 i->uid_path = TAKE_PTR(resolved_id);
-                                path_simplify(i->uid_path, false);
+                                path_simplify(i->uid_path);
                         } else {
                                 _cleanup_free_ char *uid = NULL, *gid = NULL;
                                 if (split_pair(resolved_id, ":", &uid, &gid) == 0) {
@@ -1706,7 +1706,7 @@ static int parse_line(const char *fname, unsigned line, const char *buffer) {
                 if (resolved_id) {
                         if (path_is_absolute(resolved_id)) {
                                 i->gid_path = TAKE_PTR(resolved_id);
-                                path_simplify(i->gid_path, false);
+                                path_simplify(i->gid_path);
                         } else {
                                 r = parse_gid(resolved_id, &i->gid);
                                 if (r < 0)
index c07c22a4072414998ea0a8d29201d669f35ca467..8e8802b72f52d02ffc5ff5defde1c1a62636939c 100644 (file)
@@ -21,16 +21,13 @@ static void test_print_paths(void) {
         log_info("DEFAULT_USER_PATH=%s", DEFAULT_USER_PATH);
 }
 
-static void test_path_simplify(const char *in, const char *out, const char *out_dot) {
+static void test_path_simplify(const char *in, const char *out) {
         char *p;
 
         log_info("/* %s */", __func__);
 
         p = strdupa(in);
-        assert_se(streq(path_simplify(p, false), out));
-
-        p = strdupa(in);
-        assert_se(streq(path_simplify(p, true), out_dot));
+        assert_se(streq(path_simplify(p), out));
 }
 
 static void test_path(void) {
@@ -48,27 +45,23 @@ static void test_path(void) {
         assert_se(streq(basename("/aa///file..."), "file..."));
         assert_se(streq(basename("file.../"), ""));
 
-        test_path_simplify("aaa/bbb////ccc", "aaa/bbb/ccc", "aaa/bbb/ccc");
-        test_path_simplify("//aaa/.////ccc", "/aaa/./ccc", "/aaa/ccc");
-        test_path_simplify("///", "/", "/");
-        test_path_simplify("///.//", "/.", "/");
-        test_path_simplify("///.//.///", "/./.", "/");
-        test_path_simplify("////.././///../.", "/.././../.", "/../..");
-        test_path_simplify(".", ".", ".");
-        test_path_simplify("./", ".", ".");
-        test_path_simplify(".///.//./.", "./././.", ".");
-        test_path_simplify(".///.//././/", "./././.", ".");
+        test_path_simplify("aaa/bbb////ccc", "aaa/bbb/ccc");
+        test_path_simplify("//aaa/.////ccc", "/aaa/ccc");
+        test_path_simplify("///", "/");
+        test_path_simplify("///.//", "/");
+        test_path_simplify("///.//.///", "/");
+        test_path_simplify("////.././///../.", "/../..");
+        test_path_simplify(".", ".");
+        test_path_simplify("./", ".");
+        test_path_simplify(".///.//./.", ".");
+        test_path_simplify(".///.//././/", ".");
         test_path_simplify("//./aaa///.//./.bbb/..///c.//d.dd///..eeee/.",
-                           "/./aaa/././.bbb/../c./d.dd/..eeee/.",
                            "/aaa/.bbb/../c./d.dd/..eeee");
         test_path_simplify("//./aaa///.//./.bbb/..///c.//d.dd///..eeee/..",
-                           "/./aaa/././.bbb/../c./d.dd/..eeee/..",
                            "/aaa/.bbb/../c./d.dd/..eeee/..");
         test_path_simplify(".//./aaa///.//./.bbb/..///c.//d.dd///..eeee/..",
-                           "././aaa/././.bbb/../c./d.dd/..eeee/..",
                            "aaa/.bbb/../c./d.dd/..eeee/..");
         test_path_simplify("..//./aaa///.//./.bbb/..///c.//d.dd///..eeee/..",
-                           ".././aaa/././.bbb/../c./d.dd/..eeee/..",
                            "../aaa/.bbb/../c./d.dd/..eeee/..");
 
         assert_se(PATH_IN_SET("/bin", "/", "/bin", "/foo"));
index af18df1bd571c50ab3fc5f5826b817d49e2d98cd..9f2e6158674e2510612b5d4421b8f5dbe5165443 100644 (file)
@@ -37,8 +37,8 @@ static void test_tempfn_random(void) {
         test_tempfn_random_one("foo", "bar", ".#barfoo", 0);
         test_tempfn_random_one("/tmp/foo", NULL, "/tmp/.#foo", 0);
         test_tempfn_random_one("/tmp/foo", "bar", "/tmp/.#barfoo", 0);
-        test_tempfn_random_one("./foo", NULL, "./.#foo", 0);
-        test_tempfn_random_one("./foo", "bar", "./.#barfoo", 0);
+        test_tempfn_random_one("./foo", NULL, ".#foo", 0);
+        test_tempfn_random_one("./foo", "bar", ".#barfoo", 0);
         test_tempfn_random_one("../foo", NULL, "../.#foo", 0);
         test_tempfn_random_one("../foo", "bar", "../.#barfoo", 0);
 
@@ -46,8 +46,8 @@ static void test_tempfn_random(void) {
         test_tempfn_random_one("foo/", "bar", ".#barfoo", 0);
         test_tempfn_random_one("/tmp/foo/", NULL, "/tmp/.#foo", 0);
         test_tempfn_random_one("/tmp/foo/", "bar", "/tmp/.#barfoo", 0);
-        test_tempfn_random_one("./foo/", NULL, "./.#foo", 0);
-        test_tempfn_random_one("./foo/", "bar", "./.#barfoo", 0);
+        test_tempfn_random_one("./foo/", NULL, ".#foo", 0);
+        test_tempfn_random_one("./foo/", "bar", ".#barfoo", 0);
         test_tempfn_random_one("../foo/", NULL, "../.#foo", 0);
         test_tempfn_random_one("../foo/", "bar", "../.#barfoo", 0);
 }
@@ -81,8 +81,8 @@ static void test_tempfn_xxxxxx(void) {
         test_tempfn_xxxxxx_one("foo", "bar", ".#barfoo", 0);
         test_tempfn_xxxxxx_one("/tmp/foo", NULL, "/tmp/.#foo", 0);
         test_tempfn_xxxxxx_one("/tmp/foo", "bar", "/tmp/.#barfoo", 0);
-        test_tempfn_xxxxxx_one("./foo", NULL, "./.#foo", 0);
-        test_tempfn_xxxxxx_one("./foo", "bar", "./.#barfoo", 0);
+        test_tempfn_xxxxxx_one("./foo", NULL, ".#foo", 0);
+        test_tempfn_xxxxxx_one("./foo", "bar", ".#barfoo", 0);
         test_tempfn_xxxxxx_one("../foo", NULL, "../.#foo", 0);
         test_tempfn_xxxxxx_one("../foo", "bar", "../.#barfoo", 0);
 
@@ -90,8 +90,8 @@ static void test_tempfn_xxxxxx(void) {
         test_tempfn_xxxxxx_one("foo/", "bar", ".#barfoo", 0);
         test_tempfn_xxxxxx_one("/tmp/foo/", NULL, "/tmp/.#foo", 0);
         test_tempfn_xxxxxx_one("/tmp/foo/", "bar", "/tmp/.#barfoo", 0);
-        test_tempfn_xxxxxx_one("./foo/", NULL, "./.#foo", 0);
-        test_tempfn_xxxxxx_one("./foo/", "bar", "./.#barfoo", 0);
+        test_tempfn_xxxxxx_one("./foo/", NULL, ".#foo", 0);
+        test_tempfn_xxxxxx_one("./foo/", "bar", ".#barfoo", 0);
         test_tempfn_xxxxxx_one("../foo/", NULL, "../.#foo", 0);
         test_tempfn_xxxxxx_one("../foo/", "bar", "../.#barfoo", 0);
 }
index dc4dc7529d31b887ae5a07f7ab29787658962d3a..0bce571fedd95f6d29e360eb66eb8877868bf5c3 100644 (file)
@@ -129,7 +129,7 @@ static void test_unit_name_from_path(void) {
         test_unit_name_from_path_one("/", ".mount", "-.mount", 0);
         test_unit_name_from_path_one("///", ".mount", "-.mount", 0);
         test_unit_name_from_path_one("/foo/../bar", ".mount", NULL, -EINVAL);
-        test_unit_name_from_path_one("/foo/./bar", ".mount", NULL, -EINVAL);
+        test_unit_name_from_path_one("/foo/./bar", ".mount", "foo-bar.mount", 0);
         test_unit_name_from_path_one("/waldoaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", ".mount", NULL, -EINVAL);
 }
 
index 3eac712b0bf76413de0f3607a00afec0e579a126..071070e9f6af5c212ec91c015afeb32cc21e7801 100644 (file)
@@ -445,7 +445,7 @@ static int load_unix_sockets(void) {
                 if (!s)
                         return log_oom();
 
-                path_simplify(s, false);
+                path_simplify(s);
 
                 r = set_consume(sockets, s);
                 if (r == -EEXIST)
@@ -2779,7 +2779,7 @@ static int parse_line(
                         free_and_replace(i.argument, p);
                 }
 
-                path_simplify(i.argument, false);
+                path_simplify(i.argument);
                 break;
 
         case CREATE_CHAR_DEVICE:
@@ -2847,7 +2847,7 @@ static int parse_line(
                                   "Path '%s' not absolute.", i.path);
         }
 
-        path_simplify(i.path, false);
+        path_simplify(i.path);
 
         if (!should_include_path(i.path))
                 return 0;
index 584e5c27ed8c0591aa354b97c9ce7c71e3c5bda7..fd1752c65fd54dad7780249a9ed08e7197f4bf72 100644 (file)
@@ -96,7 +96,7 @@ int main(int argc, char *argv[]) {
         test_event_spawn_cat(false);
 
         assert_se(path_make_absolute_cwd(argv[0], &self) >= 0);
-        path_simplify(self, true);
+        path_simplify(self);
 
         test_event_spawn_self(self, "test1", true);
         test_event_spawn_self(self, "test1", false);