chiark / gitweb /
use more _cleanup_ macro
[elogind.git] / src / core / execute.c
index 78fb81f7262771d97002512bb3e5ea964bfa0c67..1ea646334bce13edac6fb57567bc7a828fd77937 100644 (file)
@@ -561,7 +561,7 @@ static int restore_confirm_stdio(int *saved_stdin,
 
 static int ask_for_confirmation(char *response, char **argv) {
         int saved_stdout = -1, saved_stdin = -1, r;
-        char *line;
+        _cleanup_free_ char *line = NULL;
 
         r = setup_confirm_stdio(&saved_stdin, &saved_stdout);
         if (r < 0)
@@ -572,7 +572,6 @@ static int ask_for_confirmation(char *response, char **argv) {
                 return -ENOMEM;
 
         r = ask(response, "yns", "Execute %s? [Yes, No, Skip] ", line);
-        free(line);
 
         restore_confirm_stdio(&saved_stdin, &saved_stdout);
 
@@ -2058,8 +2057,8 @@ int exec_context_load_environment(const ExecContext *c, char ***l) {
 }
 
 static bool tty_may_match_dev_console(const char *tty) {
-        char *active = NULL, *console;
-        bool b;
+        _cleanup_free_ char *active = NULL;
+       char *console;
 
         if (startswith(tty, "/dev/"))
                 tty += 5;
@@ -2074,10 +2073,7 @@ static bool tty_may_match_dev_console(const char *tty) {
                 return true;
 
         /* "tty0" means the active VC, so it may be the same sometimes */
-        b = streq(console, tty) || (streq(console, "tty0") && tty_is_vc(tty));
-        free(active);
-
-        return b;
+        return streq(console, tty) || (streq(console, "tty0") && tty_is_vc(tty));
 }
 
 bool exec_context_may_touch_console(ExecContext *ec) {
@@ -2467,10 +2463,10 @@ char *exec_command_line(char **argv) {
 }
 
 void exec_command_dump(ExecCommand *c, FILE *f, const char *prefix) {
-        char *p2;
+        _cleanup_free_ char *p2 = NULL;
         const char *prefix2;
 
-        char *cmd;
+        _cleanup_free_ char *cmd = NULL;
 
         assert(c);
         assert(f);
@@ -2486,11 +2482,7 @@ void exec_command_dump(ExecCommand *c, FILE *f, const char *prefix) {
                 "%sCommand Line: %s\n",
                 prefix, cmd ? cmd : strerror(ENOMEM));
 
-        free(cmd);
-
         exec_status_dump(&c->exec_status, f, prefix2);
-
-        free(p2);
 }
 
 void exec_command_dump_list(ExecCommand *c, FILE *f, const char *prefix) {