chiark / gitweb /
execute: simplify appending to execution list
authorLennart Poettering <lennart@poettering.net>
Sun, 14 Feb 2010 00:05:55 +0000 (01:05 +0100)
committerLennart Poettering <lennart@poettering.net>
Sun, 14 Feb 2010 00:05:55 +0000 (01:05 +0100)
execute.c
execute.h
load-fragment.c

index 8720af9e2579815420af8d4dd876391829f980c3..4c6aa4eea98cc1f1703c483ab18d2385a2b59f98 100644 (file)
--- a/execute.c
+++ b/execute.c
@@ -749,6 +749,20 @@ void exec_command_dump_list(ExecCommand *c, FILE *f, const char *prefix) {
                 exec_command_dump(c, f, prefix);
 }
 
+void exec_command_append_list(ExecCommand **l, ExecCommand *e) {
+        ExecCommand *end;
+
+        assert(l);
+        assert(e);
+
+        if (*l) {
+                /* It's kinda important that we keep the order here */
+                LIST_FIND_TAIL(ExecCommand, command, *l, end);
+                LIST_INSERT_AFTER(ExecCommand, command, *l, end, e);
+        } else
+              *l = e;
+}
+
 static const char* const exec_output_table[_EXEC_OUTPUT_MAX] = {
         [EXEC_OUTPUT_CONSOLE] = "console",
         [EXEC_OUTPUT_NULL] = "null",
index 737973dad90e8fe112e380bd11d4aa27fa1ce4da..3e332105c1ab15f12bea9d4b82a95e76b15a995c 100644 (file)
--- a/execute.h
+++ b/execute.h
@@ -154,6 +154,7 @@ void exec_command_free_array(ExecCommand **c, unsigned n);
 char *exec_command_line(ExecCommand *c);
 void exec_command_dump(ExecCommand *c, FILE *f, const char *prefix);
 void exec_command_dump_list(ExecCommand *c, FILE *f, const char *prefix);
+void exec_command_append_list(ExecCommand **l, ExecCommand *e);
 
 void exec_context_init(ExecContext *c);
 void exec_context_done(ExecContext *c);
index 4183b5c8fa912eec2ed5f412804c7eb6e1b29659..9bc9b2b6a1768420cddb11e40cbd71ff4204f843 100644 (file)
@@ -328,7 +328,7 @@ static int config_parse_exec(
                 void *data,
                 void *userdata) {
 
-        ExecCommand **e = data, *ee, *nce = NULL;
+        ExecCommand **e = data, *nce = NULL;
         char **n;
         char *w;
         unsigned k;
@@ -367,12 +367,7 @@ static int config_parse_exec(
         if (!(nce->path = strdup(n[0])))
                 goto fail;
 
-        if (*e) {
-                /* It's kinda important that we keep the order here */
-                LIST_FIND_TAIL(ExecCommand, command, *e, ee);
-                LIST_INSERT_AFTER(ExecCommand, command, *e, ee, nce);
-        } else
-                *e = nce;
+        exec_command_append_list(e, nce);
 
         return 0;