aboutsummaryrefslogtreecommitdiff
path: root/util
diff options
context:
space:
mode:
authorOlga Krishtal <okrishtal@parallels.com>2015-02-06 20:59:53 +0300
committerMichael Roth <mdroth@linux.vnet.ibm.com>2015-02-16 16:20:02 -0600
commit459db780be10f7adac723a5d3a4ffeac8ae6e768 (patch)
tree346611ce5e2480d5efa40c7e43c7a8fead9adeef /util
parent215a2771a7b6b29037ee8deba484815d816b6fdd (diff)
downloadqemu-459db780be10f7adac723a5d3a4ffeac8ae6e768.zip
qemu-459db780be10f7adac723a5d3a4ffeac8ae6e768.tar.gz
qemu-459db780be10f7adac723a5d3a4ffeac8ae6e768.tar.bz2
utils: drop strtok_r from envlist_parse
The problem is that mingw 4.9.1 fails to compile the code with the following warning: /mingw/include/string.h:88:9: note: previous declaration of 'strtok_r' was here char *strtok_r(char * __restrict__ _Str, const char * __restrict__ _Delim, char ** __restrict__ __last); /include/sysemu/os-win32.h:83:7: warning: redundant redeclaration of 'strtok_r' [-Wredundant-decls] char *strtok_r(char *str, const char *delim, char **saveptr); The problem is that compiles just fine on previous versions of mingw. Compiler version check here is not a good idea. Though fortunately strtok_r is used only once in the code and we could simply rewrite the code without it. Signed-off-by: Olga Krishtal <okrishtal@parallels.com> Signed-off-by: Denis V. Lunev <den@openvz.org> CC: Eric Blake <eblake@redhat.com> CC: Michael Roth <mdroth@linux.vnet.ibm.com> Signed-off-by: Michael Roth <mdroth@linux.vnet.ibm.com>
Diffstat (limited to 'util')
-rw-r--r--util/envlist.c32
1 files changed, 16 insertions, 16 deletions
diff --git a/util/envlist.c b/util/envlist.c
index ebc06cf..099a544 100644
--- a/util/envlist.c
+++ b/util/envlist.c
@@ -94,30 +94,30 @@ envlist_parse(envlist_t *envlist, const char *env,
{
char *tmpenv, *envvar;
char *envsave = NULL;
-
- assert(callback != NULL);
+ int ret = 0;
+ assert(callback != NULL);
if ((envlist == NULL) || (env == NULL))
return (EINVAL);
- /*
- * We need to make temporary copy of the env string
- * as strtok_r(3) modifies it while it tokenizes.
- */
if ((tmpenv = strdup(env)) == NULL)
return (errno);
-
- envvar = strtok_r(tmpenv, ",", &envsave);
- while (envvar != NULL) {
- if ((*callback)(envlist, envvar) != 0) {
- free(tmpenv);
- return (errno);
+ envsave = tmpenv;
+
+ do {
+ envvar = strchr(tmpenv, ',');
+ if (envvar != NULL) {
+ *envvar = '\0';
+ }
+ if ((*callback)(envlist, tmpenv) != 0) {
+ ret = errno;
+ break;
}
- envvar = strtok_r(NULL, ",", &envsave);
- }
+ tmpenv = envvar + 1;
+ } while (envvar != NULL);
- free(tmpenv);
- return (0);
+ free(envsave);
+ return ret;
}
/*