From f1acf85a36f4c32d69511fe1bfa12f66e28fa80d Mon Sep 17 00:00:00 2001 From: =?utf8?q?Zbigniew=20J=C4=99drzejewski-Szmek?= Date: Thu, 18 Dec 2014 12:29:24 -0500 Subject: [PATCH] core: make exec_command_free_list return NULL --- src/core/dbus-service.c | 6 ++---- src/core/execute.c | 10 +++++----- src/core/execute.h | 2 +- src/core/load-fragment.c | 3 +-- 4 files changed, 9 insertions(+), 12 deletions(-) diff --git a/src/core/dbus-service.c b/src/core/dbus-service.c index 5a881e824..2b50ac93d 100644 --- a/src/core/dbus-service.c +++ b/src/core/dbus-service.c @@ -187,10 +187,8 @@ static int bus_service_set_transient_property( ExecCommand *c; size_t size = 0; - if (n == 0) { - exec_command_free_list(s->exec_command[SERVICE_EXEC_START]); - s->exec_command[SERVICE_EXEC_START] = NULL; - } + if (n == 0) + s->exec_command[SERVICE_EXEC_START] = exec_command_free_list(s->exec_command[SERVICE_EXEC_START]); f = open_memstream(&buf, &size); if (!f) diff --git a/src/core/execute.c b/src/core/execute.c index ae2a52d44..bc925cd80 100644 --- a/src/core/execute.c +++ b/src/core/execute.c @@ -2007,7 +2007,7 @@ void exec_command_done_array(ExecCommand *c, unsigned n) { exec_command_done(c+i); } -void exec_command_free_list(ExecCommand *c) { +ExecCommand* exec_command_free_list(ExecCommand *c) { ExecCommand *i; while ((i = c)) { @@ -2015,15 +2015,15 @@ void exec_command_free_list(ExecCommand *c) { exec_command_done(i); free(i); } + + return NULL; } void exec_command_free_array(ExecCommand **c, unsigned n) { unsigned i; - for (i = 0; i < n; i++) { - exec_command_free_list(c[i]); - c[i] = NULL; - } + for (i = 0; i < n; i++) + c[i] = exec_command_free_list(c[i]); } int exec_context_load_environment(const ExecContext *c, const char *unit_id, char ***l) { diff --git a/src/core/execute.h b/src/core/execute.h index 5ed750534..2c201399e 100644 --- a/src/core/execute.h +++ b/src/core/execute.h @@ -228,7 +228,7 @@ int exec_spawn(ExecCommand *command, void exec_command_done(ExecCommand *c); void exec_command_done_array(ExecCommand *c, unsigned n); -void exec_command_free_list(ExecCommand *c); +ExecCommand* exec_command_free_list(ExecCommand *c); void exec_command_free_array(ExecCommand **c, unsigned n); char *exec_command_line(char **argv); diff --git a/src/core/load-fragment.c b/src/core/load-fragment.c index 358d36beb..e8dfa1a51 100644 --- a/src/core/load-fragment.c +++ b/src/core/load-fragment.c @@ -538,8 +538,7 @@ int config_parse_exec(const char *unit, if (isempty(rvalue)) { /* An empty assignment resets the list */ - exec_command_free_list(*e); - *e = NULL; + *e = exec_command_free_list(*e); return 0; } -- 2.30.2