chiark / gitweb /
busctl: show machine name of all registered names
[elogind.git] / src / shared / install.c
index 9722ed4e1c7df42057f02d58c940f2a68cfab5c6..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;
         }
 
@@ -1874,6 +1873,7 @@ static void unitfilelist_free(UnitFileList **f) {
         free((*f)->path);
         free(*f);
 }
+#define _cleanup_unitfilelist_free_ _cleanup_(unitfilelist_free)
 
 int unit_file_get_list(
                 UnitFileScope scope,
@@ -1925,8 +1925,7 @@ int unit_file_get_list(
                 for (;;) {
                         struct dirent *de;
                         union dirent_storage buffer;
-                        UnitFileList __attribute__((cleanup(unitfilelist_free)))
-                                *f = NULL;
+                        _cleanup_unitfilelist_free_ UnitFileList *f = NULL;
 
                         r = readdir_r(d, &buffer.de, &de);
                         if (r != 0)