{"thread":{"id":"43014","subject":"[PATCH] use CHILD_PROCESS_INIT to initialize automatic variables","startedAt":"2016-08-05T20:39:20Z","lastAt":"2016-08-05T20:39:20Z","messageCount":1,"participants":["René Scharfe"],"isPatch":true,"patchVersion":1,"patchTotal":null},"messages":[{"id":"293230","messageId":"57A4F954.5090607@web.de","threadId":"43014","inReplyTo":null,"subject":"[PATCH] use CHILD_PROCESS_INIT to initialize automatic variables","fromName":"René Scharfe","fromEmail":"l.s.r@web.de","sentAt":"2016-08-05T20:38:44Z","receivedAt":"2016-08-05T20:39:20Z","isPatch":true,"sender":{"key":"l.s.r@web.de","avatar":"https://avatars.githubusercontent.com/u/26122331?v=4"},"body":"Initialize struct child_process variables already when they're defined.\nThat's shorter and saves a function call.\n\nSigned-off-by: Rene Scharfe <l.s.r@web.de>\n---\n builtin/submodule--helper.c | 3 +--\n builtin/worktree.c          | 6 ++----\n 2 files changed, 3 insertions(+), 6 deletions(-)\n\ndiff --git a/builtin/submodule--helper.c b/builtin/submodule--helper.c\nindex b22352b..957f42a 100644\n--- a/builtin/submodule--helper.c\n+++ b/builtin/submodule--helper.c\n@@ -444,8 +444,7 @@ static int module_name(int argc, const char **argv, const char *prefix)\n static int clone_submodule(const char *path, const char *gitdir, const char *url,\n \t\t\t   const char *depth, const char *reference, int quiet)\n {\n-\tstruct child_process cp;\n-\tchild_process_init(&cp);\n+\tstruct child_process cp = CHILD_PROCESS_INIT;\n \n \targv_array_push(&cp.args, \"clone\");\n \targv_array_push(&cp.args, \"--no-checkout\");\ndiff --git a/builtin/worktree.c b/builtin/worktree.c\nindex 5a41788..6dcf7bd 100644\n--- a/builtin/worktree.c\n+++ b/builtin/worktree.c\n@@ -194,7 +194,7 @@ static int add_worktree(const char *path, const char *refname,\n \tstruct strbuf sb = STRBUF_INIT;\n \tconst char *name;\n \tstruct stat st;\n-\tstruct child_process cp;\n+\tstruct child_process cp = CHILD_PROCESS_INIT;\n \tstruct argv_array child_env = ARGV_ARRAY_INIT;\n \tint counter = 0, len, ret;\n \tstruct strbuf symref = STRBUF_INIT;\n@@ -273,7 +273,6 @@ static int add_worktree(const char *path, const char *refname,\n \n \targv_array_pushf(&child_env, \"%s=%s\", GIT_DIR_ENVIRONMENT, sb_git.buf);\n \targv_array_pushf(&child_env, \"%s=%s\", GIT_WORK_TREE_ENVIRONMENT, path);\n-\tmemset(&cp, 0, sizeof(cp));\n \tcp.git_cmd = 1;\n \n \tif (commit)\n@@ -365,8 +364,7 @@ static int add(int ac, const char **av, const char *prefix)\n \t}\n \n \tif (opts.new_branch) {\n-\t\tstruct child_process cp;\n-\t\tmemset(&cp, 0, sizeof(cp));\n+\t\tstruct child_process cp = CHILD_PROCESS_INIT;\n \t\tcp.git_cmd = 1;\n \t\targv_array_push(&cp.args, \"branch\");\n \t\tif (opts.force_new_branch)\n-- \n2.9.2\n\n"}]}