chiark / gitweb /
cgls: automatic cleanup
authorZbigniew Jędrzejewski-Szmek <zbyszek@in.waw.pl>
Mon, 19 Nov 2012 19:19:39 +0000 (20:19 +0100)
committerZbigniew Jędrzejewski-Szmek <zbyszek@in.waw.pl>
Sat, 1 Dec 2012 15:38:32 +0000 (16:38 +0100)
src/cgls/cgls.c

index b2cd968..ad59c01 100644 (file)
@@ -138,7 +138,7 @@ int main(int argc, char *argv[]) {
                 }
 
         } else {
-                char *p;
+                char _cleanup_free_ *p;
 
                 p = get_current_dir_name();
                 if (!p) {
@@ -150,7 +150,7 @@ int main(int argc, char *argv[]) {
                         printf("Working Directory %s:\n", p);
                         r = show_cgroup_by_path(p, NULL, 0, arg_kernel_threads, arg_all);
                 } else {
-                        char *root = NULL;
+                        char _cleanup_free_ *root = NULL;
                         const char *t = NULL;
 
                         r = cg_get_by_pid(SYSTEMD_CGROUP_CONTROLLER, 1, &root);
@@ -164,10 +164,7 @@ int main(int argc, char *argv[]) {
                         }
 
                         r = show_cgroup(SYSTEMD_CGROUP_CONTROLLER, t, NULL, 0, arg_kernel_threads, arg_all);
-                        free(root);
                 }
-
-                free(p);
         }
 
         if (r < 0)