chiark / gitweb /
Use enums to make it obvious what boolean params mean
authorZbigniew Jędrzejewski-Szmek <zbyszek@in.waw.pl>
Thu, 26 Dec 2013 20:30:22 +0000 (15:30 -0500)
committerZbigniew Jędrzejewski-Szmek <zbyszek@in.waw.pl>
Thu, 26 Dec 2013 20:49:54 +0000 (15:49 -0500)
Suggested-by: Russ Allbery <rra@debian.org>
15 files changed:
src/core/dbus-unit.c
src/core/device.c
src/core/load-fragment.c
src/core/manager.c
src/core/snapshot.c
src/core/unit.c
src/dbus1-generator/dbus1-generator.c
src/journal/journalctl.c
src/run/run.c
src/shared/cgroup-util.c
src/shared/install.c
src/shared/unit-name.c
src/shared/unit-name.h
src/systemctl/systemctl.c
src/test/test-unit-name.c

index 4d3e3cc..37c1e8c 100644 (file)
@@ -813,7 +813,7 @@ static int bus_unit_set_transient_property(
                 if (r < 0)
                         return r;
 
                 if (r < 0)
                         return r;
 
-                if (!unit_name_is_valid(s, false) || !endswith(s, ".slice"))
+                if (!unit_name_is_valid(s, TEMPLATE_INVALID) || !endswith(s, ".slice"))
                         return sd_bus_error_setf(error, SD_BUS_ERROR_INVALID_ARGS, "Invalid slice name %s", s);
 
                 if (isempty(s)) {
                         return sd_bus_error_setf(error, SD_BUS_ERROR_INVALID_ARGS, "Invalid slice name %s", s);
 
                 if (isempty(s)) {
@@ -865,7 +865,7 @@ static int bus_unit_set_transient_property(
                         return r;
 
                 while ((r = sd_bus_message_read(message, "s", &other)) > 0) {
                         return r;
 
                 while ((r = sd_bus_message_read(message, "s", &other)) > 0) {
-                        if (!unit_name_is_valid(other, false))
+                        if (!unit_name_is_valid(other, TEMPLATE_INVALID))
                                 return sd_bus_error_setf(error, SD_BUS_ERROR_INVALID_ARGS, "Invalid unit name %s", other);
 
                         if (mode != UNIT_CHECK) {
                                 return sd_bus_error_setf(error, SD_BUS_ERROR_INVALID_ARGS, "Invalid unit name %s", other);
 
                         if (mode != UNIT_CHECK) {
index d3976c9..c7bc1e2 100644 (file)
@@ -268,7 +268,7 @@ static int device_update_unit(Manager *m, struct udev_device *dev, const char *p
                                 memcpy(e, w, l);
                                 e[l] = 0;
 
                                 memcpy(e, w, l);
                                 e[l] = 0;
 
-                                n = unit_name_mangle(e, false);
+                                n = unit_name_mangle(e, MANGLE_NOGLOB);
                                 if (!n) {
                                         r = -ENOMEM;
                                         goto fail;
                                 if (!n) {
                                         r = -ENOMEM;
                                         goto fail;
index 183c43d..7a2d32d 100644 (file)
@@ -2433,7 +2433,7 @@ static int open_follow(char **filename, FILE **_f, Set *names, char **_final) {
                  * unit name. */
                 name = basename(*filename);
 
                  * unit name. */
                 name = basename(*filename);
 
-                if (unit_name_is_valid(name, true)) {
+                if (unit_name_is_valid(name, TEMPLATE_VALID)) {
 
                         id = set_get(names, name);
                         if (!id) {
 
                         id = set_get(names, name);
                         if (!id) {
index 6b33c18..f69ae07 100644 (file)
@@ -1115,7 +1115,7 @@ int manager_load_unit_prepare(
 
         t = unit_name_to_type(name);
 
 
         t = unit_name_to_type(name);
 
-        if (t == _UNIT_TYPE_INVALID || !unit_name_is_valid(name, false))
+        if (t == _UNIT_TYPE_INVALID || !unit_name_is_valid(name, TEMPLATE_INVALID))
                 return sd_bus_error_setf(e, SD_BUS_ERROR_INVALID_ARGS, "Unit name %s is not valid.", name);
 
         ret = manager_get_unit(m, name);
                 return sd_bus_error_setf(e, SD_BUS_ERROR_INVALID_ARGS, "Unit name %s is not valid.", name);
 
         ret = manager_get_unit(m, name);
index 21e89ac..d914af2 100644 (file)
@@ -200,7 +200,7 @@ int snapshot_create(Manager *m, const char *name, bool cleanup, sd_bus_error *e,
         assert(_s);
 
         if (name) {
         assert(_s);
 
         if (name) {
-                if (!unit_name_is_valid(name, false))
+                if (!unit_name_is_valid(name, TEMPLATE_INVALID))
                         return sd_bus_error_setf(e, SD_BUS_ERROR_INVALID_ARGS, "Unit name %s is not valid.", name);
 
                 if (unit_name_to_type(name) != UNIT_SNAPSHOT)
                         return sd_bus_error_setf(e, SD_BUS_ERROR_INVALID_ARGS, "Unit name %s is not valid.", name);
 
                 if (unit_name_to_type(name) != UNIT_SNAPSHOT)
index 160a346..e3b6206 100644 (file)
@@ -119,7 +119,7 @@ int unit_add_name(Unit *u, const char *text) {
         if (!s)
                 return -ENOMEM;
 
         if (!s)
                 return -ENOMEM;
 
-        if (!unit_name_is_valid(s, false)) {
+        if (!unit_name_is_valid(s, TEMPLATE_INVALID)) {
                 r = -EINVAL;
                 goto fail;
         }
                 r = -EINVAL;
                 goto fail;
         }
index d7ecd7f..5470bc9 100644 (file)
@@ -190,7 +190,7 @@ static int add_dbus(const char *path, const char *fname, const char *type) {
         }
 
         if (service) {
         }
 
         if (service) {
-                if (!unit_name_is_valid(service, false)) {
+                if (!unit_name_is_valid(service, TEMPLATE_INVALID)) {
                         log_warning("Unit name %s is not valid, ignoring.", service);
                         return 0;
                 }
                         log_warning("Unit name %s is not valid, ignoring.", service);
                         return 0;
                 }
index fdee9d4..42c16f6 100644 (file)
@@ -991,7 +991,7 @@ static int add_units(sd_journal *j) {
         assert(j);
 
         STRV_FOREACH(i, arg_system_units) {
         assert(j);
 
         STRV_FOREACH(i, arg_system_units) {
-                u = unit_name_mangle(*i, false);
+                u = unit_name_mangle(*i, MANGLE_NOGLOB);
                 if (!u)
                         return log_oom();
                 r = add_matches_for_unit(j, u);
                 if (!u)
                         return log_oom();
                 r = add_matches_for_unit(j, u);
@@ -1003,7 +1003,7 @@ static int add_units(sd_journal *j) {
         }
 
         STRV_FOREACH(i, arg_user_units) {
         }
 
         STRV_FOREACH(i, arg_user_units) {
-                u = unit_name_mangle(*i, false);
+                u = unit_name_mangle(*i, MANGLE_NOGLOB);
                 if (!u)
                         return log_oom();
 
                 if (!u)
                         return log_oom();
 
index ef2015f..1b14e40 100644 (file)
@@ -208,7 +208,7 @@ static int message_start_transient_unit_new(sd_bus *bus, const char *name, sd_bu
         if (!isempty(arg_slice)) {
                 _cleanup_free_ char *slice;
 
         if (!isempty(arg_slice)) {
                 _cleanup_free_ char *slice;
 
-                slice = unit_name_mangle_with_suffix(arg_slice, false, ".slice");
+                slice = unit_name_mangle_with_suffix(arg_slice, MANGLE_NOGLOB, ".slice");
                 if (!slice)
                         return -ENOMEM;
 
                 if (!slice)
                         return -ENOMEM;
 
@@ -255,7 +255,7 @@ static int start_transient_service(
         int r;
 
         if (arg_unit)
         int r;
 
         if (arg_unit)
-                name = unit_name_mangle_with_suffix(arg_unit, false, ".service");
+                name = unit_name_mangle_with_suffix(arg_unit, MANGLE_NOGLOB, ".service");
         else
                 asprintf(&name, "run-%lu.service", (unsigned long) getpid());
         if (!name)
         else
                 asprintf(&name, "run-%lu.service", (unsigned long) getpid());
         if (!name)
@@ -342,7 +342,7 @@ static int start_transient_scope(
         assert(bus);
 
         if (arg_unit)
         assert(bus);
 
         if (arg_unit)
-                name = unit_name_mangle_with_suffix(arg_unit, false, ".scope");
+                name = unit_name_mangle_with_suffix(arg_unit, MANGLE_NOGLOB, ".scope");
         else
                 asprintf(&name, "run-%lu.scope", (unsigned long) getpid());
         if (!name)
         else
                 asprintf(&name, "run-%lu.scope", (unsigned long) getpid());
         if (!name)
index 27eee8e..f2af8dc 100644 (file)
@@ -1152,7 +1152,7 @@ int cg_path_decode_unit(const char *cgroup, char **unit){
         c = strndupa(cgroup, e - cgroup);
         c = cg_unescape(c);
 
         c = strndupa(cgroup, e - cgroup);
         c = cg_unescape(c);
 
-        if (!unit_name_is_valid(c, false))
+        if (!unit_name_is_valid(c, TEMPLATE_INVALID))
                 return -EINVAL;
 
         s = strdup(c);
                 return -EINVAL;
 
         s = strdup(c);
@@ -1566,7 +1566,7 @@ int cg_slice_to_path(const char *unit, char **ret) {
         assert(unit);
         assert(ret);
 
         assert(unit);
         assert(ret);
 
-        if (!unit_name_is_valid(unit, false))
+        if (!unit_name_is_valid(unit, TEMPLATE_INVALID))
                 return -EINVAL;
 
         if (!endswith(unit, ".slice"))
                 return -EINVAL;
 
         if (!endswith(unit, ".slice"))
@@ -1583,7 +1583,7 @@ int cg_slice_to_path(const char *unit, char **ret) {
 
                 strcpy(stpncpy(n, p, dash - p), ".slice");
 
 
                 strcpy(stpncpy(n, p, dash - p), ".slice");
 
-                if (!unit_name_is_valid(n, false))
+                if (!unit_name_is_valid(n, TEMPLATE_INVALID))
                         return -EINVAL;
 
                 escaped = cg_escape(n);
                         return -EINVAL;
 
                 escaped = cg_escape(n);
index 233d64b..62151d9 100644 (file)
@@ -575,7 +575,7 @@ int unit_file_mask(
         STRV_FOREACH(i, files) {
                 _cleanup_free_ char *path = NULL;
 
         STRV_FOREACH(i, files) {
                 _cleanup_free_ char *path = NULL;
 
-                if (!unit_name_is_valid(*i, true)) {
+                if (!unit_name_is_valid(*i, TEMPLATE_VALID)) {
                         if (r == 0)
                                 r = -EINVAL;
                         continue;
                         if (r == 0)
                                 r = -EINVAL;
                         continue;
@@ -643,7 +643,7 @@ int unit_file_unmask(
         STRV_FOREACH(i, files) {
                 char *path;
 
         STRV_FOREACH(i, files) {
                 char *path;
 
-                if (!unit_name_is_valid(*i, true)) {
+                if (!unit_name_is_valid(*i, TEMPLATE_VALID)) {
                         if (r == 0)
                                 r = -EINVAL;
                         continue;
                         if (r == 0)
                                 r = -EINVAL;
                         continue;
@@ -719,7 +719,7 @@ int unit_file_link(
                 fn = basename(*i);
 
                 if (!path_is_absolute(*i) ||
                 fn = basename(*i);
 
                 if (!path_is_absolute(*i) ||
-                    !unit_name_is_valid(fn, true)) {
+                    !unit_name_is_valid(fn, TEMPLATE_VALID)) {
                         if (r == 0)
                                 r = -EINVAL;
                         continue;
                         if (r == 0)
                                 r = -EINVAL;
                         continue;
@@ -861,7 +861,7 @@ static int install_info_add(
         if (!name)
                 name = basename(path);
 
         if (!name)
                 name = basename(path);
 
-        if (!unit_name_is_valid(name, true))
+        if (!unit_name_is_valid(name, TEMPLATE_VALID))
                 return -EINVAL;
 
         if (hashmap_get(c->have_installed, name) ||
                 return -EINVAL;
 
         if (hashmap_get(c->have_installed, name) ||
@@ -1235,7 +1235,7 @@ static int install_info_symlink_wants(
                 if (q < 0)
                         return q;
 
                 if (q < 0)
                         return q;
 
-                if (!unit_name_is_valid(dst, true)) {
+                if (!unit_name_is_valid(dst, TEMPLATE_VALID)) {
                         r = -EINVAL;
                         continue;
                 }
                         r = -EINVAL;
                         continue;
                 }
@@ -1272,7 +1272,7 @@ static int install_info_symlink_requires(
                 if (q < 0)
                         return q;
 
                 if (q < 0)
                         return q;
 
-                if (!unit_name_is_valid(dst, true)) {
+                if (!unit_name_is_valid(dst, TEMPLATE_VALID)) {
                         r = -EINVAL;
                         continue;
                 }
                         r = -EINVAL;
                         continue;
                 }
@@ -1675,7 +1675,7 @@ UnitFileState unit_file_get_state(
         if (root_dir && scope != UNIT_FILE_SYSTEM)
                 return -EINVAL;
 
         if (root_dir && scope != UNIT_FILE_SYSTEM)
                 return -EINVAL;
 
-        if (!unit_name_is_valid(name, true))
+        if (!unit_name_is_valid(name, TEMPLATE_VALID))
                 return -EINVAL;
 
         r = lookup_paths_init_from_scope(&paths, scope);
                 return -EINVAL;
 
         r = lookup_paths_init_from_scope(&paths, scope);
@@ -1845,7 +1845,7 @@ int unit_file_preset(
 
         STRV_FOREACH(i, files) {
 
 
         STRV_FOREACH(i, files) {
 
-                if (!unit_name_is_valid(*i, true))
+                if (!unit_name_is_valid(*i, TEMPLATE_VALID))
                         return -EINVAL;
 
                 r = unit_file_query_preset(scope, *i);
                         return -EINVAL;
 
                 r = unit_file_query_preset(scope, *i);
@@ -1949,7 +1949,7 @@ int unit_file_get_list(
                         if (ignore_file(de->d_name))
                                 continue;
 
                         if (ignore_file(de->d_name))
                                 continue;
 
-                        if (!unit_name_is_valid(de->d_name, true))
+                        if (!unit_name_is_valid(de->d_name, TEMPLATE_VALID))
                                 continue;
 
                         if (hashmap_get(h, de->d_name))
                                 continue;
 
                         if (hashmap_get(h, de->d_name))
index 832b926..408323b 100644 (file)
@@ -62,7 +62,7 @@ static const char* const unit_load_state_table[_UNIT_LOAD_STATE_MAX] = {
 
 DEFINE_STRING_TABLE_LOOKUP(unit_load_state, UnitLoadState);
 
 
 DEFINE_STRING_TABLE_LOOKUP(unit_load_state, UnitLoadState);
 
-bool unit_name_is_valid(const char *n, bool template_ok) {
+bool unit_name_is_valid(const char *n, enum template_valid template_ok) {
         const char *e, *i, *at;
 
         /* Valid formats:
         const char *e, *i, *at;
 
         /* Valid formats:
@@ -72,6 +72,7 @@ bool unit_name_is_valid(const char *n, bool template_ok) {
          */
 
         assert(n);
          */
 
         assert(n);
+        assert(IN_SET(template_ok, TEMPLATE_VALID, TEMPLATE_INVALID));
 
         if (strlen(n) >= UNIT_NAME_MAX)
                 return false;
 
         if (strlen(n) >= UNIT_NAME_MAX)
                 return false;
@@ -96,7 +97,7 @@ bool unit_name_is_valid(const char *n, bool template_ok) {
                 if (at == n)
                         return false;
 
                 if (at == n)
                         return false;
 
-                if (!template_ok && at+1 == e)
+                if (!template_ok == TEMPLATE_VALID && at+1 == e)
                         return false;
         }
 
                         return false;
         }
 
@@ -186,7 +187,7 @@ char *unit_name_change_suffix(const char *n, const char *suffix) {
         size_t a, b;
 
         assert(n);
         size_t a, b;
 
         assert(n);
-        assert(unit_name_is_valid(n, true));
+        assert(unit_name_is_valid(n, TEMPLATE_VALID));
         assert(suffix);
         assert(suffix[0] == '.');
 
         assert(suffix);
         assert(suffix[0] == '.');
 
@@ -486,12 +487,13 @@ int unit_name_from_dbus_path(const char *path, char **name) {
  *  Try to turn a string that might not be a unit name into a
  *  sensible unit name.
  */
  *  Try to turn a string that might not be a unit name into a
  *  sensible unit name.
  */
-char *unit_name_mangle(const char *name, bool allow_globs) {
+char *unit_name_mangle(const char *name, enum unit_name_mangle allow_globs) {
         char *r, *t;
         const char *f;
         char *r, *t;
         const char *f;
-        const char* valid_chars = allow_globs ? "@" VALID_CHARS "[]!-*?" : "@" VALID_CHARS;
+        const char* valid_chars = allow_globs == MANGLE_GLOB ? "@" VALID_CHARS "[]!-*?" : "@" VALID_CHARS;
 
         assert(name);
 
         assert(name);
+        assert(IN_SET(allow_globs, MANGLE_GLOB, MANGLE_NOGLOB));
 
         if (is_device_path(name))
                 return unit_name_from_path(name, ".device");
 
         if (is_device_path(name))
                 return unit_name_from_path(name, ".device");
@@ -528,7 +530,7 @@ char *unit_name_mangle(const char *name, bool allow_globs) {
  *  Similar to unit_name_mangle(), but is called when we know
  *  that this is about a specific unit type.
  */
  *  Similar to unit_name_mangle(), but is called when we know
  *  that this is about a specific unit type.
  */
-char *unit_name_mangle_with_suffix(const char *name, bool allow_globs, const char *suffix) {
+char *unit_name_mangle_with_suffix(const char *name, enum unit_name_mangle allow_globs, const char *suffix) {
         char *r, *t;
         const char *f;
 
         char *r, *t;
         const char *f;
 
index 362ff0c..d06d2b2 100644 (file)
@@ -69,7 +69,12 @@ int unit_name_to_instance(const char *n, char **instance);
 char* unit_name_to_prefix(const char *n);
 char* unit_name_to_prefix_and_instance(const char *n);
 
 char* unit_name_to_prefix(const char *n);
 char* unit_name_to_prefix_and_instance(const char *n);
 
-bool unit_name_is_valid(const char *n, bool template_ok) _pure_;
+enum template_valid {
+        TEMPLATE_INVALID,
+        TEMPLATE_VALID,
+};
+
+bool unit_name_is_valid(const char *n, enum template_valid template_ok) _pure_;
 bool unit_prefix_is_valid(const char *p) _pure_;
 bool unit_instance_is_valid(const char *i) _pure_;
 
 bool unit_prefix_is_valid(const char *p) _pure_;
 bool unit_instance_is_valid(const char *i) _pure_;
 
@@ -98,7 +103,12 @@ char *unit_name_to_path(const char *name);
 char *unit_dbus_path_from_name(const char *name);
 int unit_name_from_dbus_path(const char *path, char **name);
 
 char *unit_dbus_path_from_name(const char *name);
 int unit_name_from_dbus_path(const char *path, char **name);
 
-char *unit_name_mangle(const char *name, bool allow_globs);
-char *unit_name_mangle_with_suffix(const char *name, bool allow_globs, const char *suffix);
+enum unit_name_mangle {
+        MANGLE_NOGLOB,
+        MANGLE_GLOB,
+};
+
+char *unit_name_mangle(const char *name, enum unit_name_mangle allow_globs);
+char *unit_name_mangle_with_suffix(const char *name, enum unit_name_mangle allow_globs, const char *suffix);
 
 int build_subslice(const char *slice, const char*name, char **subslice);
 
 int build_subslice(const char *slice, const char*name, char **subslice);
index 03b9dd9..3a9bca9 100644 (file)
@@ -1375,7 +1375,7 @@ static int list_dependencies(sd_bus *bus, char **args) {
         assert(bus);
 
         if (args[1]) {
         assert(bus);
 
         if (args[1]) {
-                unit = unit_name_mangle(args[1], false);
+                unit = unit_name_mangle(args[1], MANGLE_NOGLOB);
                 if (!unit)
                         return log_oom();
                 u = unit;
                 if (!unit)
                         return log_oom();
                 u = unit;
@@ -1475,7 +1475,7 @@ static int set_default(sd_bus *bus, char **args) {
         unsigned n_changes = 0;
         int r;
 
         unsigned n_changes = 0;
         int r;
 
-        unit = unit_name_mangle_with_suffix(args[1], false, ".target");
+        unit = unit_name_mangle_with_suffix(args[1], MANGLE_NOGLOB, ".target");
         if (!unit)
                 return log_oom();
 
         if (!unit)
                 return log_oom();
 
@@ -1924,7 +1924,7 @@ static int check_one_unit(sd_bus *bus, const char *name, const char *good_states
 
         assert(name);
 
 
         assert(name);
 
-        n = unit_name_mangle(name, false);
+        n = unit_name_mangle(name, MANGLE_NOGLOB);
         if (!n)
                 return log_oom();
 
         if (!n)
                 return log_oom();
 
@@ -1981,7 +1981,7 @@ static int check_triggering_units(
         char **i;
         int r;
 
         char **i;
         int r;
 
-        n = unit_name_mangle(name, false);
+        n = unit_name_mangle(name, MANGLE_NOGLOB);
         if (!n)
                 return log_oom();
 
         if (!n)
                 return log_oom();
 
@@ -2111,9 +2111,9 @@ static int expand_names(sd_bus *bus, char **names, const char* suffix, char ***r
                 char *t;
 
                 if (suffix)
                 char *t;
 
                 if (suffix)
-                        t = unit_name_mangle_with_suffix(*name, true, suffix);
+                        t = unit_name_mangle_with_suffix(*name, MANGLE_GLOB, suffix);
                 else
                 else
-                        t = unit_name_mangle(*name, true);
+                        t = unit_name_mangle(*name, MANGLE_GLOB);
                 if (!t)
                         return log_oom();
 
                 if (!t)
                         return log_oom();
 
@@ -4117,7 +4117,7 @@ static int set_property(sd_bus *bus, char **args) {
         if (r < 0)
                 return bus_log_create_error(r);
 
         if (r < 0)
                 return bus_log_create_error(r);
 
-        n = unit_name_mangle(args[1], false);
+        n = unit_name_mangle(args[1], MANGLE_NOGLOB);
         if (!n)
                 return log_oom();
 
         if (!n)
                 return log_oom();
 
@@ -4164,7 +4164,7 @@ static int snapshot(sd_bus *bus, char **args) {
         int r;
 
         if (strv_length(args) > 1)
         int r;
 
         if (strv_length(args) > 1)
-                n = unit_name_mangle_with_suffix(args[1], false, ".snapshot");
+                n = unit_name_mangle_with_suffix(args[1], MANGLE_NOGLOB, ".snapshot");
         else
                 n = strdup("");
         if (!n)
         else
                 n = strdup("");
         if (!n)
@@ -4619,7 +4619,7 @@ static int mangle_names(char **original_names, char ***mangled_names) {
                 if (is_path(*name))
                         *i = strdup(*name);
                 else
                 if (is_path(*name))
                         *i = strdup(*name);
                 else
-                        *i = unit_name_mangle(*name, false);
+                        *i = unit_name_mangle(*name, MANGLE_NOGLOB);
 
                 if (!*i) {
                         strv_free(l);
 
                 if (!*i) {
                         strv_free(l);
index ad664bc..c10ec60 100644 (file)
@@ -63,7 +63,7 @@ static void test_replacements(void) {
                 puts(t);                                           \
                 k = unit_name_to_path(t);                          \
                 puts(k);                                           \
                 puts(t);                                           \
                 k = unit_name_to_path(t);                          \
                 puts(k);                                           \
-                assert(streq(k, expected ? expected : path));     \
+                assert(streq(k, expected ? expected : path));      \
         }
 
         expect("/waldo", ".mount", NULL);
         }
 
         expect("/waldo", ".mount", NULL);
@@ -74,12 +74,12 @@ static void test_replacements(void) {
 
         puts("-------------------------------------------------");
 #undef expect
 
         puts("-------------------------------------------------");
 #undef expect
-#define expect(pattern, path, suffix, expected)                         \
-        {                                                               \
-                _cleanup_free_ char *t =                                \
+#define expect(pattern, path, suffix, expected)                              \
+        {                                                                    \
+                _cleanup_free_ char *t =                                     \
                         unit_name_from_path_instance(pattern, path, suffix); \
                         unit_name_from_path_instance(pattern, path, suffix); \
-                puts(t);                                                \
-                assert(streq(t, expected));                             \
+                puts(t);                                                     \
+                assert(streq(t, expected));                                  \
         }
 
         expect("waldo", "/waldo", ".mount", "waldo@waldo.mount");
         }
 
         expect("waldo", "/waldo", ".mount", "waldo@waldo.mount");
@@ -89,13 +89,13 @@ static void test_replacements(void) {
 
         puts("-------------------------------------------------");
 #undef expect
 
         puts("-------------------------------------------------");
 #undef expect
-#define expect(pattern)                                                 \
-        {                                                               \
-                _cleanup_free_ char *k, *t;                             \
-                assert_se(t = unit_name_mangle(pattern, false));        \
-                assert_se(k = unit_name_mangle(t, false));              \
-                puts(t);                                                \
-                assert_se(streq(t, k));                                 \
+#define expect(pattern)                                                     \
+        {                                                                   \
+                _cleanup_free_ char *k, *t;                                 \
+                assert_se(t = unit_name_mangle(pattern, MANGLE_NOGLOB));    \
+                assert_se(k = unit_name_mangle(t, MANGLE_NOGLOB));          \
+                puts(t);                                                    \
+                assert_se(streq(t, k));                                     \
         }
 
         expect("/home");
         }
 
         expect("/home");