summaryrefslogtreecommitdiff
path: root/src/systemctl
diff options
context:
space:
mode:
authorHarald Hoyer <harald@redhat.com>2013-04-17 12:03:20 +0200
committerHarald Hoyer <harald@redhat.com>2013-04-17 12:03:20 +0200
commit4b6756a88dc67baf3d0fea34157660ef22bb229f (patch)
tree1ab7f1479c0a83b9e81b9655f36c8d79c6971a13 /src/systemctl
parentdb5372091664c977a937f6bc0fe4484363be0669 (diff)
systemctl:enable_sysv_units() more _cleanup_free_
Diffstat (limited to 'src/systemctl')
-rw-r--r--src/systemctl/systemctl.c19
1 files changed, 4 insertions, 15 deletions
diff --git a/src/systemctl/systemctl.c b/src/systemctl/systemctl.c
index b738a6d1d7..29f12fcb8d 100644
--- a/src/systemctl/systemctl.c
+++ b/src/systemctl/systemctl.c
@@ -4009,11 +4009,11 @@ static int enable_sysv_units(char **args) {
r = 0;
for (f = 1; args[f]; f++) {
const char *name;
- char *p;
+ char _cleanup_free_ *p = NULL, *q = NULL;
bool found_native = false, found_sysv;
unsigned c = 1;
const char *argv[6] = { "/sbin/chkconfig", NULL, NULL, NULL, NULL };
- char **k, *l, *q = NULL;
+ char **k, *l;
int j;
pid_t pid;
siginfo_t status;
@@ -4027,8 +4027,6 @@ static int enable_sysv_units(char **args) {
continue;
STRV_FOREACH(k, paths.unit_path) {
- p = NULL;
-
if (!isempty(arg_root))
asprintf(&p, "%s/%s/%s", arg_root, *k, name);
else
@@ -4041,6 +4039,7 @@ static int enable_sysv_units(char **args) {
found_native = access(p, F_OK) >= 0;
free(p);
+ p = NULL;
if (found_native)
break;
@@ -4049,7 +4048,6 @@ static int enable_sysv_units(char **args) {
if (found_native)
continue;
- p = NULL;
if (!isempty(arg_root))
asprintf(&p, "%s/" SYSTEM_SYSVINIT_PATH "/%s", arg_root, name);
else
@@ -4062,10 +4060,8 @@ static int enable_sysv_units(char **args) {
p[strlen(p) - sizeof(".service") + 1] = 0;
found_sysv = access(p, F_OK) >= 0;
- if (!found_sysv) {
- free(p);
+ if (!found_sysv)
continue;
- }
/* Mark this entry, so that we don't try enabling it as native unit */
args[f] = (char*) "";
@@ -4083,8 +4079,6 @@ static int enable_sysv_units(char **args) {
l = strv_join((char**)argv, " ");
if (!l) {
- free(q);
- free(p);
r = log_oom();
goto finish;
}
@@ -4095,8 +4089,6 @@ static int enable_sysv_units(char **args) {
pid = fork();
if (pid < 0) {
log_error("Failed to fork: %m");
- free(p);
- free(q);
r = -errno;
goto finish;
} else if (pid == 0) {
@@ -4106,9 +4098,6 @@ static int enable_sysv_units(char **args) {
_exit(EXIT_FAILURE);
}
- free(p);
- free(q);
-
j = wait_for_terminate(pid, &status);
if (j < 0) {
log_error("Failed to wait for child: %s", strerror(-r));