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

spectral (Kyle Lippincott) phabricator at mercurial-scm.org
Tue Jan 28 13:57:11 EST 2020


spectral updated this revision to Diff 19655.

REPOSITORY
  rHG Mercurial

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

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

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** environ);
 
 #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);



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


More information about the Mercurial-devel mailing list