[PATCH v2 4/8] run-command.c: add an initializer for "struct parallel_processes"
From: Ævar Arnfjörð Bjarmason <hidden>
Date: 2022-05-18 20:06:12
Subsystem:
the rest · Maintainer:
Linus Torvalds
From: Ævar Arnfjörð Bjarmason <hidden>
Date: 2022-05-18 20:06:12
Subsystem:
the rest · Maintainer:
Linus Torvalds
Add a PARALLEL_PROCESSES_INIT macro for "struct parallel_processes", this allows us to do away with a call to strbuf_init(), in subsequent commits we'll be able to rely on other fields being NULL'd. Signed-off-by: Ævar Arnfjörð Bjarmason <redacted> --- run-command.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-)
diff --git a/run-command.c b/run-command.c
index 8c156fd080e..839c85d12e5 100644
--- a/run-command.c
+++ b/run-command.c@@ -1498,6 +1498,9 @@ struct parallel_processes { int output_owner; struct strbuf buffered_output; /* of finished children */ }; +#define PARALLEL_PROCESSES_INIT { \ + .buffered_output = STRBUF_INIT, \ +} static int default_start_failure(struct strbuf *out, void *pp_cb,
@@ -1562,7 +1565,6 @@ static void pp_init(struct parallel_processes *pp, pp->shutdown = 0; CALLOC_ARRAY(pp->children, n); CALLOC_ARRAY(pp->pfd, n); - strbuf_init(&pp->buffered_output, 0); for (i = 0; i < n; i++) { strbuf_init(&pp->children[i].err, 0);
@@ -1744,7 +1746,7 @@ int run_processes_parallel(struct run_process_parallel_opts *opts) int i, code; int output_timeout = 100; int spawn_cap = 4; - struct parallel_processes pp; + struct parallel_processes pp = PARALLEL_PROCESSES_INIT; const char *tr2_category = opts->tr2_category; const char *tr2_label = opts->tr2_label; const int do_trace2 = tr2_category && tr2_label;
--
2.36.1.952.g0ae626f6cd7