From a8e40d0287f05f6e444035431b1cc7b340fe8d79 Mon Sep 17 00:00:00 2001 From: Laurent Bercot Date: Fri, 22 Dec 2017 16:44:47 +0000 Subject: Deprecate env_get --- src/libstddjb/child_spawn.c | 20 +++++++++----------- src/libstddjb/child_spawn0.c | 3 +-- src/libstddjb/child_spawn1_internal.c | 6 +++--- src/libstddjb/child_spawn2.c | 10 +++++----- src/libstddjb/env_get.c | 4 ++-- src/libstddjb/pathexec_run.c | 4 ++-- src/libstddjb/ucspi_get.c | 5 +++-- 7 files changed, 25 insertions(+), 27 deletions(-) (limited to 'src/libstddjb') diff --git a/src/libstddjb/child_spawn.c b/src/libstddjb/child_spawn.c index 62d13cb..82edf8a 100644 --- a/src/libstddjb/child_spawn.c +++ b/src/libstddjb/child_spawn.c @@ -10,10 +10,6 @@ #include #include #include -#include -#include -#include -#include #ifdef SKALIBS_HASPOSIXSPAWN @@ -28,8 +24,10 @@ #endif -#define NOFDVAR "SKALIBS_CHILD_SPAWN_FDS" - +#include +#include +#include +#include /* If n = 0 : child's stdin and stdout are the same as the parent's @@ -48,10 +46,10 @@ pid_t child_spawn (char const *prog, char const *const *argv, char const *const int p[n ? n : 1][2] ; pid_t pid ; int e ; - size_t m = sizeof(NOFDVAR) ; + size_t m = sizeof(SKALIBS_CHILD_SPAWN_FDS_ENVVAR) ; unsigned int i = 0 ; char modifs[m + 1 + n * UINT_FMT] ; - memcpy(modifs, NOFDVAR "=", sizeof(NOFDVAR)) ; + memcpy(modifs, SKALIBS_CHILD_SPAWN_FDS_ENVVAR "=", sizeof(SKALIBS_CHILD_SPAWN_FDS_ENVVAR)) ; for (; i < n ; i++) if (pipe(p[i]) < 0) { e = errno ; goto errpi ; } for (i = 0 ; i < n ; i++) if ((ndelay_on(p[i][i & 1]) < 0) || (coe(p[i][i & 1]) < 0)) @@ -94,7 +92,7 @@ pid_t child_spawn (char const *prog, char const *const *argv, char const *const if (e) goto erractions ; } { - int haspath = !!env_get("PATH") ; + int haspath = !!getenv("PATH") ; size_t envlen = env_len(envp) ; char const *newenv[envlen + 2] ; if (!env_merge(newenv, envlen+2, envp, envlen, modifs, m)) goto errsp ; @@ -137,8 +135,8 @@ pid_t child_spawn (char const *prog, char const *const *argv, char const *const syncdie: { - unsigned char c = errno ; - fd_write(syncpipe[1], (char const *)&c, 1) ; + char c = errno ; + fd_write(syncpipe[1], &c, 1) ; } _exit(127) ; } diff --git a/src/libstddjb/child_spawn0.c b/src/libstddjb/child_spawn0.c index a01739a..31d44e2 100644 --- a/src/libstddjb/child_spawn0.c +++ b/src/libstddjb/child_spawn0.c @@ -9,14 +9,13 @@ #include #include #include -#include pid_t child_spawn0 (char const *prog, char const *const *argv, char const *const *envp) { posix_spawnattr_t attr ; int e ; pid_t pid ; - int haspath = !!env_get("PATH") ; + int haspath = !!getenv("PATH") ; e = posix_spawnattr_init(&attr) ; if (e) goto err ; { diff --git a/src/libstddjb/child_spawn1_internal.c b/src/libstddjb/child_spawn1_internal.c index eea4f09..38a6e60 100644 --- a/src/libstddjb/child_spawn1_internal.c +++ b/src/libstddjb/child_spawn1_internal.c @@ -3,7 +3,6 @@ #include #include #include -#include #ifdef SKALIBS_HASPOSIXSPAWN @@ -11,7 +10,7 @@ #include #include #include -#include +#include pid_t child_spawn1_internal (char const *prog, char const *const *argv, char const *const *envp, int *p, int to) { @@ -19,7 +18,7 @@ pid_t child_spawn1_internal (char const *prog, char const *const *argv, char con posix_spawnattr_t attr ; int e ; pid_t pid ; - int haspath = !!env_get("PATH") ; + int haspath = !!getenv("PATH") ; if (coe(p[!(to & 1)]) < 0) { e = errno ; goto err ; } e = posix_spawnattr_init(&attr) ; if (e) goto err ; @@ -69,6 +68,7 @@ pid_t child_spawn1_internal (char const *prog, char const *const *argv, char con #include #include #include +#include pid_t child_spawn1_internal (char const *prog, char const *const *argv, char const *const *envp, int *p, int to) { diff --git a/src/libstddjb/child_spawn2.c b/src/libstddjb/child_spawn2.c index 0f08b3d..01f144d 100644 --- a/src/libstddjb/child_spawn2.c +++ b/src/libstddjb/child_spawn2.c @@ -9,14 +9,12 @@ #include #include #include -#include #ifdef SKALIBS_HASPOSIXSPAWN #include #include #include -#include #else @@ -27,6 +25,8 @@ #endif +#include + pid_t child_spawn2 (char const *prog, char const *const *argv, char const *const *envp, int *fds) { #ifdef SKALIBS_HASPOSIXSPAWN @@ -65,7 +65,7 @@ pid_t child_spawn2 (char const *prog, char const *const *argv, char const *const e = posix_spawn_file_actions_addclose(&actions, p[0][1]) ; if (e) goto erractions ; { - int haspath = !!env_get("PATH") ; + int haspath = !!getenv("PATH") ; if (!haspath && (setenv("PATH", SKALIBS_DEFAULTPATH, 0) < 0)) { e = errno ; goto erractions ; @@ -98,8 +98,8 @@ pid_t child_spawn2 (char const *prog, char const *const *argv, char const *const syncdie: { - unsigned char c = errno ; - fd_write(syncpipe[1], (char const *)&c, 1) ; + char c = errno ; + fd_write(syncpipe[1], &c, 1) ; } _exit(127) ; } diff --git a/src/libstddjb/env_get.c b/src/libstddjb/env_get.c index f523f45..d809461 100644 --- a/src/libstddjb/env_get.c +++ b/src/libstddjb/env_get.c @@ -1,9 +1,9 @@ /* ISC license. */ -#include +#include #include char const *env_get (char const *s) { - return env_get2((char const **)environ, s) ; + return getenv(s) ; } diff --git a/src/libstddjb/pathexec_run.c b/src/libstddjb/pathexec_run.c index ff3211d..5888ba2 100644 --- a/src/libstddjb/pathexec_run.c +++ b/src/libstddjb/pathexec_run.c @@ -1,13 +1,13 @@ /* ISC license. */ +#include #include -#include #include #include void pathexec_run (char const *file, char const *const *argv, char const *const *envp) { - char const *path = env_get("PATH") ; + char const *path = getenv("PATH") ; if (!path) path = SKALIBS_DEFAULTPATH ; execvep(file, argv, envp, path) ; } diff --git a/src/libstddjb/ucspi_get.c b/src/libstddjb/ucspi_get.c index b4572d1..71fd14b 100644 --- a/src/libstddjb/ucspi_get.c +++ b/src/libstddjb/ucspi_get.c @@ -2,11 +2,12 @@ #include #include +#include #include char const *ucspi_get (char const *s) { - char const *x = env_get("PROTO") ; + char const *x = getenv("PROTO") ; if (x) { size_t len = strlen(s) ; @@ -14,7 +15,7 @@ char const *ucspi_get (char const *s) char tmp[len + xlen + 1] ; memcpy(tmp, x, xlen) ; memcpy(tmp + xlen, s, len + 1) ; - x = env_get(tmp) ; + x = getenv(tmp) ; if (!x) errno = ENOENT ; } else errno = EINVAL ; -- cgit v1.2.3