From 29fda24dd11e90583f3ea9ff2f90ee9acacd7792 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C3=86var=20Arnfj=C3=B6r=C3=B0=20Bjarmason?= Date: Thu, 2 Jun 2022 11:09:50 +0200 Subject: run-command API: rename "env_array" to "env" MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Start following-up on the rename mentioned in c7c4bdeccf3 (run-command API: remove "env" member, always use "env_array", 2021-11-25) of "env_array" to "env". The "env_array" name was picked in 19a583dc39e (run-command: add env_array, an optional argv_array for env, 2014-10-19) because "env" was taken. Let's not forever keep the oddity of "*_array" for this "struct strvec", but not for its "args" sibling. This commit is almost entirely made with a coccinelle rule[1]. The only manual change here is in run-command.h to rename the struct member itself and to change "env_array" to "env" in the CHILD_PROCESS_INIT initializer. The rest of this is all a result of applying [1]: * make contrib/coccinelle/run_command.cocci.patch * patch -p1 env_array + E->env I've avoided changing any comments and derived variable names here, that will all be done in the next commit. Signed-off-by: Ævar Arnfjörð Bjarmason Signed-off-by: Junio C Hamano --- daemon.c | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) (limited to 'daemon.c') diff --git a/daemon.c b/daemon.c index 94a5b8a364..a1d211debe 100644 --- a/daemon.c +++ b/daemon.c @@ -484,7 +484,7 @@ static int upload_pack(const struct strvec *env) strvec_pushl(&cld.args, "upload-pack", "--strict", NULL); strvec_pushf(&cld.args, "--timeout=%u", timeout); - strvec_pushv(&cld.env_array, env->v); + strvec_pushv(&cld.env, env->v); return run_service_command(&cld); } @@ -494,7 +494,7 @@ static int upload_archive(const struct strvec *env) struct child_process cld = CHILD_PROCESS_INIT; strvec_push(&cld.args, "upload-archive"); - strvec_pushv(&cld.env_array, env->v); + strvec_pushv(&cld.env, env->v); return run_service_command(&cld); } @@ -504,7 +504,7 @@ static int receive_pack(const struct strvec *env) struct child_process cld = CHILD_PROCESS_INIT; strvec_push(&cld.args, "receive-pack"); - strvec_pushv(&cld.env_array, env->v); + strvec_pushv(&cld.env, env->v); return run_service_command(&cld); } @@ -904,16 +904,16 @@ static void handle(int incoming, struct sockaddr *addr, socklen_t addrlen) char buf[128] = ""; struct sockaddr_in *sin_addr = (void *) addr; inet_ntop(addr->sa_family, &sin_addr->sin_addr, buf, sizeof(buf)); - strvec_pushf(&cld.env_array, "REMOTE_ADDR=%s", buf); - strvec_pushf(&cld.env_array, "REMOTE_PORT=%d", + strvec_pushf(&cld.env, "REMOTE_ADDR=%s", buf); + strvec_pushf(&cld.env, "REMOTE_PORT=%d", ntohs(sin_addr->sin_port)); #ifndef NO_IPV6 } else if (addr->sa_family == AF_INET6) { char buf[128] = ""; struct sockaddr_in6 *sin6_addr = (void *) addr; inet_ntop(AF_INET6, &sin6_addr->sin6_addr, buf, sizeof(buf)); - strvec_pushf(&cld.env_array, "REMOTE_ADDR=[%s]", buf); - strvec_pushf(&cld.env_array, "REMOTE_PORT=%d", + strvec_pushf(&cld.env, "REMOTE_ADDR=[%s]", buf); + strvec_pushf(&cld.env, "REMOTE_PORT=%d", ntohs(sin6_addr->sin6_port)); #endif } -- cgit v1.2.3