summaryrefslogtreecommitdiff
path: root/util.c
diff options
context:
space:
mode:
authorJim Meyering <meyering@redhat.com>2009-11-20 18:54:38 +0100
committerJim Meyering <meyering@redhat.com>2009-11-20 19:29:31 +0100
commitbbb664482ab9f3fb959a04588e8490fd2d9fea5c (patch)
tree6c85a716d228538f6af758104cf27be93734a3bd /util.c
parente67b41c47c96cede8a89dd7403791a2e245a01d1 (diff)
downloadgzip-bbb664482ab9f3fb959a04588e8490fd2d9fea5c.tar.gz
build: util.c: avoid warnings about add_envopt
* util.c (add_envopt): The parameter "env" was used for two conflicting purposes. One use required a const char* parameter, while the other was used as an argument to free, which must not be "const". Rename the parameter and use a new local variable for the second role.
Diffstat (limited to 'util.c')
-rw-r--r--util.c17
1 files changed, 9 insertions, 8 deletions
diff --git a/util.c b/util.c
index 6bd0987..d0d7774 100644
--- a/util.c
+++ b/util.c
@@ -360,20 +360,21 @@ int strcspn(s, reject)
char *add_envopt(
int *argcp, /* pointer to argc */
char ***argvp, /* pointer to argv */
- char const *env) /* name of environment variable */
+ char const *envvar_name) /* name of environment variable */
{
char *p; /* running pointer through env variable */
char **oargv; /* runs through old argv array */
char **nargv; /* runs through new argv array */
int oargc = *argcp; /* old argc */
int nargc = 0; /* number of arguments in env variable */
+ char *env_val;
- env = (char*)getenv(env);
- if (env == NULL) return NULL;
+ env_val = getenv(envvar_name);
+ if (env_val == NULL) return NULL;
- env = xstrdup (env);
+ env_val = xstrdup (env_val);
- for (p = env; *p; nargc++ ) { /* move through env */
+ for (p = env_val; *p; nargc++ ) { /* move through env_val */
p += strspn(p, SEPARATOR); /* skip leading separators */
if (*p == '\0') break;
@@ -381,7 +382,7 @@ char *add_envopt(
if (*p) *p++ = '\0'; /* mark it */
}
if (nargc == 0) {
- free(env);
+ free(env_val);
return NULL;
}
*argcp += nargc;
@@ -398,7 +399,7 @@ char *add_envopt(
*(nargv++) = *(oargv++);
/* Then copy the environment args */
- for (p = env; nargc > 0; nargc--) {
+ for (p = env_val; nargc > 0; nargc--) {
p += strspn(p, SEPARATOR); /* skip separators */
*(nargv++) = p; /* store start */
while (*p++) ; /* skip over word */
@@ -407,7 +408,7 @@ char *add_envopt(
/* Finally copy the old args and add a NULL (usual convention) */
while (oargc--) *(nargv++) = *(oargv++);
*nargv = NULL;
- return env;
+ return env_val;
}
/* ========================================================================