chiark / gitweb /
busctl: show machine name of all registered names
[elogind.git] / src / shared / install.c
index 5a780fe915f1a3ad41bbb7e0a20b0a95ed08b7d0..cfd4a5af8acad9f038ed4b2b4473cd74f93ee0d7 100644 (file)
@@ -44,10 +44,7 @@ typedef struct {
         Hashmap *have_installed;
 } InstallContext;
 
-#define _cleanup_lookup_paths_free_ \
-        __attribute__((cleanup(lookup_paths_free)))
-#define _cleanup_install_context_done_ \
-        __attribute__((cleanup(install_context_done)))
+#define _cleanup_install_context_done_ _cleanup_(install_context_done)
 
 static int lookup_paths_init_from_scope(LookupPaths *paths, UnitFileScope scope) {
         assert(paths);
@@ -1621,6 +1618,7 @@ int unit_file_get_default(
 
         STRV_FOREACH(p, paths.unit_path) {
                 _cleanup_free_ char *path = NULL, *tmp = NULL;
+                char *n;
 
                 if (isempty(root_dir))
                         path = strappend(*p, "/default.target");
@@ -1633,13 +1631,14 @@ int unit_file_get_default(
                 r = readlink_malloc(path, &tmp);
                 if (r == -ENOENT)
                         continue;
-                else if (r < 0)
+                if (r < 0)
                         return r;
 
-                *name = strdup(path_get_file_name(tmp));
-                if (!*name)
+                n = strdup(path_get_file_name(tmp));
+                if (!n)
                         return -ENOMEM;
 
+                *name = n;
                 return 0;
         }