chiark / gitweb /
nspawn: use automatic cleanup
authorZbigniew Jędrzejewski-Szmek <zbyszek@in.waw.pl>
Sun, 16 Sep 2012 13:09:47 +0000 (15:09 +0200)
committerZbigniew Jędrzejewski-Szmek <zbyszek@in.waw.pl>
Sun, 16 Sep 2012 14:20:09 +0000 (16:20 +0200)
This one actually clears up a (totally harmless) memleak.

src/nspawn/nspawn.c

index 770019bb8a4e2740bd43cb953d51bba3322f38d8..c46f63ba29a4d7ab89bf9dec972e010db18e60e2 100644 (file)
@@ -46,6 +46,7 @@
 #include "log.h"
 #include "util.h"
 #include "mkdir.h"
+#include "macro.h"
 #include "audit.h"
 #include "missing.h"
 #include "cgroup-util.h"
@@ -283,7 +284,7 @@ static int mount_all(const char *dest) {
 
         unsigned k;
         int r = 0;
-        char *where;
+        char _cleanup_free_ *where = NULL;
 
         for (k = 0; k < ELEMENTSOF(mount_table); k++) {
                 int t;
@@ -300,7 +301,6 @@ static int mount_all(const char *dest) {
                 t = path_is_mount_point(where, true);
                 if (t < 0) {
                         log_error("Failed to detect whether %s is a mount point: %s", where, strerror(-t));
-                        free(where);
 
                         if (r == 0)
                                 r = t;
@@ -326,8 +326,6 @@ static int mount_all(const char *dest) {
                         if (r == 0)
                                 r = -errno;
                 }
-
-                free(where);
         }
 
         return r;