summaryrefslogtreecommitdiff
path: root/src/core
diff options
context:
space:
mode:
Diffstat (limited to 'src/core')
-rw-r--r--src/core/automount.c3
-rw-r--r--src/core/execute.c20
-rw-r--r--src/core/killall.c4
-rw-r--r--src/core/umount.c16
4 files changed, 12 insertions, 31 deletions
diff --git a/src/core/automount.c b/src/core/automount.c
index 65e6d6f179..73a8ce17e4 100644
--- a/src/core/automount.c
+++ b/src/core/automount.c
@@ -144,7 +144,7 @@ static int automount_add_default_dependencies(Automount *a) {
static int automount_verify(Automount *a) {
bool b;
- char *e;
+ _cleanup_free_ char *e = NULL;
assert(a);
if (UNIT(a)->load_state != UNIT_LOADED)
@@ -160,7 +160,6 @@ static int automount_verify(Automount *a) {
return -ENOMEM;
b = unit_has_name(UNIT(a), e);
- free(e);
if (!b) {
log_error_unit(UNIT(a)->id, "%s's Where setting doesn't match unit name. Refusing.", UNIT(a)->id);
diff --git a/src/core/execute.c b/src/core/execute.c
index 78fb81f726..1ea646334b 100644
--- a/src/core/execute.c
+++ b/src/core/execute.c
@@ -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) {
diff --git a/src/core/killall.c b/src/core/killall.c
index eab48f7dca..291e1f90ee 100644
--- a/src/core/killall.c
+++ b/src/core/killall.c
@@ -202,7 +202,7 @@ static int killall(int sig, Set *pids, bool send_sighup) {
void broadcast_signal(int sig, bool wait_for_exit, bool send_sighup) {
sigset_t mask, oldmask;
- Set *pids = NULL;
+ _cleanup_set_free_ Set *pids = NULL;
if (wait_for_exit)
pids = set_new(trivial_hash_func, trivial_compare_func);
@@ -223,6 +223,4 @@ void broadcast_signal(int sig, bool wait_for_exit, bool send_sighup) {
wait_for_children(pids, &mask);
assert_se(sigprocmask(SIG_SETMASK, &oldmask, NULL) == 0);
-
- set_free(pids);
}
diff --git a/src/core/umount.c b/src/core/umount.c
index a30f6740fa..cffa45327b 100644
--- a/src/core/umount.c
+++ b/src/core/umount.c
@@ -126,9 +126,8 @@ static int mount_points_list_get(MountPoint **head) {
}
static int swap_list_get(MountPoint **head) {
- FILE *proc_swaps;
+ _cleanup_fclose_ FILE *proc_swaps = NULL;
unsigned int i;
- int r;
assert(head);
@@ -168,26 +167,19 @@ static int swap_list_get(MountPoint **head) {
free(dev);
if (!d) {
- r = -ENOMEM;
- goto finish;
+ return -ENOMEM;
}
if (!(swap = new0(MountPoint, 1))) {
free(d);
- r = -ENOMEM;
- goto finish;
+ return -ENOMEM;
}
swap->path = d;
LIST_PREPEND(mount_point, *head, swap);
}
- r = 0;
-
-finish:
- fclose(proc_swaps);
-
- return r;
+ return 0;
}
static int loopback_list_get(MountPoint **head) {