Skip to content

Commit 0058f85

Browse files
penguin42Michael Tokarev
authored andcommitted
envlist: Remove unused envlist_parse
envlist_parse, envlist_parse_set, envlist_parse_unset were added in 2009 but never used, see: 04a6dfe ("linux-user: Add generic env variable handling") Remove them. Signed-off-by: Dr. David Alan Gilbert <[email protected]> Reviewed-by: Michael Tokarev <[email protected]> Signed-off-by: Michael Tokarev <[email protected]>
1 parent d524be2 commit 0058f85

File tree

2 files changed

+0
-71
lines changed

2 files changed

+0
-71
lines changed

include/qemu/envlist.h

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,6 @@ envlist_t *envlist_create(void);
77
void envlist_free(envlist_t *);
88
int envlist_setenv(envlist_t *, const char *);
99
int envlist_unsetenv(envlist_t *, const char *);
10-
int envlist_parse_set(envlist_t *, const char *);
11-
int envlist_parse_unset(envlist_t *, const char *);
1210
char **envlist_to_environ(const envlist_t *, size_t *);
1311

1412
#endif /* ENVLIST_H */

util/envlist.c

Lines changed: 0 additions & 69 deletions
Original file line numberDiff line numberDiff line change
@@ -12,9 +12,6 @@ struct envlist {
1212
size_t el_count; /* number of entries */
1313
};
1414

15-
static int envlist_parse(envlist_t *envlist,
16-
const char *env, int (*)(envlist_t *, const char *));
17-
1815
/*
1916
* Allocates new envlist and returns pointer to it.
2017
*/
@@ -51,72 +48,6 @@ envlist_free(envlist_t *envlist)
5148
g_free(envlist);
5249
}
5350

54-
/*
55-
* Parses comma separated list of set/modify environment
56-
* variable entries and updates given enlist accordingly.
57-
*
58-
* For example:
59-
* envlist_parse(el, "HOME=foo,SHELL=/bin/sh");
60-
*
61-
* inserts/sets environment variables HOME and SHELL.
62-
*
63-
* Returns 0 on success, errno otherwise.
64-
*/
65-
int
66-
envlist_parse_set(envlist_t *envlist, const char *env)
67-
{
68-
return (envlist_parse(envlist, env, &envlist_setenv));
69-
}
70-
71-
/*
72-
* Parses comma separated list of unset environment variable
73-
* entries and removes given variables from given envlist.
74-
*
75-
* Returns 0 on success, errno otherwise.
76-
*/
77-
int
78-
envlist_parse_unset(envlist_t *envlist, const char *env)
79-
{
80-
return (envlist_parse(envlist, env, &envlist_unsetenv));
81-
}
82-
83-
/*
84-
* Parses comma separated list of set, modify or unset entries
85-
* and calls given callback for each entry.
86-
*
87-
* Returns 0 in case of success, errno otherwise.
88-
*/
89-
static int
90-
envlist_parse(envlist_t *envlist, const char *env,
91-
int (*callback)(envlist_t *, const char *))
92-
{
93-
char *tmpenv, *envvar;
94-
char *envsave = NULL;
95-
int ret = 0;
96-
assert(callback != NULL);
97-
98-
if ((envlist == NULL) || (env == NULL))
99-
return (EINVAL);
100-
101-
tmpenv = g_strdup(env);
102-
envsave = tmpenv;
103-
104-
do {
105-
envvar = strchr(tmpenv, ',');
106-
if (envvar != NULL) {
107-
*envvar = '\0';
108-
}
109-
if ((*callback)(envlist, tmpenv) != 0) {
110-
ret = errno;
111-
break;
112-
}
113-
tmpenv = envvar + 1;
114-
} while (envvar != NULL);
115-
116-
g_free(envsave);
117-
return ret;
118-
}
119-
12051
/*
12152
* Sets environment value to envlist in similar manner
12253
* than putenv(3).

0 commit comments

Comments
 (0)