Patchwork D8021: chg: switch to using global `environ` instead of envp from main

login
register
mail settings
Submitter phabricator
Date Jan. 28, 2020, 6:58 p.m.
Message ID <5db89196ae042080db6e7967c1f39c57@localhost.localdomain>
Download mbox | patch
Permalink /patch/44710/
State Not Applicable
Headers show

Comments

phabricator - Jan. 28, 2020, 6:58 p.m.
spectral updated this revision to Diff 19657.

REPOSITORY
  rHG Mercurial

CHANGES SINCE LAST UPDATE
  https://phab.mercurial-scm.org/D8021?vs=19655&id=19657

BRANCH
  default

CHANGES SINCE LAST ACTION
  https://phab.mercurial-scm.org/D8021/new/

REVISION DETAIL
  https://phab.mercurial-scm.org/D8021

AFFECTED FILES
  contrib/chg/chg.c
  contrib/chg/hgclient.c
  contrib/chg/hgclient.h

CHANGE DETAILS




To: spectral, #hg-reviewers
Cc: yuja, pulkit, mercurial-devel

Patch

diff --git a/contrib/chg/hgclient.h b/contrib/chg/hgclient.h
--- a/contrib/chg/hgclient.h
+++ b/contrib/chg/hgclient.h
@@ -25,6 +25,6 @@ 
                           size_t argsize);
 int hgc_runcommand(hgclient_t *hgc, const char *const args[], size_t argsize);
 void hgc_attachio(hgclient_t *hgc);
-void hgc_setenv(hgclient_t *hgc, const char *const envp[]);
+void hgc_setenv(hgclient_t *hgc, const char** envp);
 
 #endif /* HGCLIENT_H_ */
diff --git a/contrib/chg/hgclient.c b/contrib/chg/hgclient.c
--- a/contrib/chg/hgclient.c
+++ b/contrib/chg/hgclient.c
@@ -644,7 +644,7 @@ 
  * @param envp  list of environment variables in "NAME=VALUE" format,
  *              terminated by NULL.
  */
-void hgc_setenv(hgclient_t *hgc, const char *const envp[])
+void hgc_setenv(hgclient_t *hgc, const char** envp)
 {
 	assert(hgc && envp);
 	if (!(hgc->capflags & CAP_SETENV)) {
diff --git a/contrib/chg/chg.c b/contrib/chg/chg.c
--- a/contrib/chg/chg.c
+++ b/contrib/chg/chg.c
@@ -30,6 +30,8 @@ 
 #define PATH_MAX 4096
 #endif
 
+extern char **environ;
+
 struct cmdserveropts {
 	char sockname[PATH_MAX];
 	char initsockname[PATH_MAX];
@@ -394,7 +396,7 @@ 
 		abortmsgerrno("failed to exec original hg");
 }
 
-int main(int argc, const char *argv[], const char *envp[])
+int main(int argc, const char *argv[])
 {
 	if (getenv("CHGDEBUG"))
 		enabledebugmsg();
@@ -429,7 +431,7 @@ 
 		hgc = connectcmdserver(&opts);
 		if (!hgc)
 			abortmsg("cannot open hg client");
-		hgc_setenv(hgc, envp);
+		hgc_setenv(hgc, (const char**)environ);
 		const char **insts = hgc_validate(hgc, argv + 1, argc - 1);
 		int needreconnect = runinstructions(&opts, insts);
 		free(insts);