From d3180279322c7450a47decf8833de47f444ca93f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ren=C3=A9=20Scharfe?= Date: Tue, 19 Aug 2014 21:09:35 +0200 Subject: run-command: introduce CHILD_PROCESS_INIT Most struct child_process variables are cleared using memset first after declaration. Provide a macro, CHILD_PROCESS_INIT, that can be used to initialize them statically instead. That's shorter, doesn't require a function call and is slightly more readable (especially given that we already have STRBUF_INIT, ARGV_ARRAY_INIT etc.). Helped-by: Johannes Sixt Signed-off-by: Rene Scharfe Signed-off-by: Junio C Hamano --- upload-pack.c | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) (limited to 'upload-pack.c') diff --git a/upload-pack.c b/upload-pack.c index 01de944a0a..c9ea1d3be6 100644 --- a/upload-pack.c +++ b/upload-pack.c @@ -80,7 +80,7 @@ static int write_one_shallow(const struct commit_graft *graft, void *cb_data) static void create_pack_file(void) { - struct child_process pack_objects; + struct child_process pack_objects = CHILD_PROCESS_INIT; char data[8193], progress[128]; char abort_msg[] = "aborting due to possible repository " "corruption on the remote side."; @@ -108,7 +108,6 @@ static void create_pack_file(void) argv[arg++] = "--include-tag"; argv[arg++] = NULL; - memset(&pack_objects, 0, sizeof(pack_objects)); pack_objects.in = -1; pack_objects.out = -1; pack_objects.err = -1; @@ -448,7 +447,7 @@ static void check_non_tip(void) static const char *argv[] = { "rev-list", "--stdin", NULL, }; - static struct child_process cmd; + static struct child_process cmd = CHILD_PROCESS_INIT; struct object *o; char namebuf[42]; /* ^ + SHA-1 + LF */ int i; -- cgit v1.2.1