chiark / gitweb /
core: make exec_command_free_list return NULL
authorZbigniew Jędrzejewski-Szmek <zbyszek@in.waw.pl>
Thu, 18 Dec 2014 17:29:24 +0000 (12:29 -0500)
committerZbigniew Jędrzejewski-Szmek <zbyszek@in.waw.pl>
Fri, 19 Dec 2014 00:26:21 +0000 (19:26 -0500)
src/core/dbus-service.c
src/core/execute.c
src/core/execute.h
src/core/load-fragment.c

index 5a881e8249c63ca8589d9523880ff067e372951b..2b50ac93d832fe6d0c56a6fd171fe62eda8fa75b 100644 (file)
@@ -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)
index ae2a52d44a05cc7fc0cb98a8630bcfef61e157e3..bc925cd80cfd3bf188ea078badd58f0c6df1a19a 100644 (file)
@@ -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) {
index 5ed750534d0ecca86e34c086646973c34f1d4a31..2c201399e3d987672e9b5cc5249b4b5e1ffd69bb 100644 (file)
@@ -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);
index 358d36beb69deace4f8a220c71c9030ed7857be0..e8dfa1a5119b7949aff14080a6b50a9c0dfd9c93 100644 (file)
@@ -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;
         }