chiark / gitweb /
nss-myhostname: copy first result to preallocated buffer
[elogind.git] / src / core / manager.c
index b538a9a3ae92007687eff628e135ae85d86be5bb..c8d7d70dc405e00a8dea0bac251166e6d967a632 100644 (file)
@@ -621,14 +621,15 @@ int manager_coldplug(Manager *m) {
 
 static void manager_build_unit_path_cache(Manager *m) {
         char **i;
-        DIR *d = NULL;
+        DIR _cleanup_free_ *d = NULL;
         int r;
 
         assert(m);
 
         set_free_free(m->unit_path_cache);
 
-        if (!(m->unit_path_cache = set_new(string_hash_func, string_compare_func))) {
+        m->unit_path_cache = set_new(string_hash_func, string_compare_func);
+        if (!m->unit_path_cache) {
                 log_error("Failed to allocate unit path cache.");
                 return;
         }
@@ -641,7 +642,8 @@ static void manager_build_unit_path_cache(Manager *m) {
 
                 d = opendir(*i);
                 if (!d) {
-                        log_error("Failed to open directory: %m");
+                        if (errno != ENOENT)
+                                log_error("Failed to open directory %s: %m", *i);
                         continue;
                 }
 
@@ -657,7 +659,8 @@ static void manager_build_unit_path_cache(Manager *m) {
                                 goto fail;
                         }
 
-                        if ((r = set_put(m->unit_path_cache, p)) < 0) {
+                        r = set_put(m->unit_path_cache, p);
+                        if (r < 0) {
                                 free(p);
                                 goto fail;
                         }
@@ -674,9 +677,6 @@ fail:
 
         set_free_free(m->unit_path_cache);
         m->unit_path_cache = NULL;
-
-        if (d)
-                closedir(d);
 }
 
 int manager_startup(Manager *m, FILE *serialization, FDSet *fds) {
@@ -2263,7 +2263,8 @@ static int create_generator_dir(Manager *m, char **generator, const char *name)
 
                 r = mkdir_p_label(p, 0755);
                 if (r < 0) {
-                        log_error("Failed to create generator directory: %s", strerror(-r));
+                        log_error("Failed to create generator directory %s: %s",
+                                  p, strerror(-r));
                         free(p);
                         return r;
                 }
@@ -2274,7 +2275,8 @@ static int create_generator_dir(Manager *m, char **generator, const char *name)
 
                 if (!mkdtemp(p)) {
                         free(p);
-                        log_error("Failed to create generator directory: %m");
+                        log_error("Failed to create generator directory %s: %m",
+                                  p);
                         return -errno;
                 }
         }
@@ -2313,7 +2315,8 @@ void manager_run_generators(Manager *m) {
                 if (errno == ENOENT)
                         return;
 
-                log_error("Failed to enumerate generator directory: %m");
+                log_error("Failed to enumerate generator directory %s: %m",
+                          generator_path);
                 return;
         }