aboutsummaryrefslogtreecommitdiff
path: root/util
diff options
context:
space:
mode:
authorPeter Maydell <peter.maydell@linaro.org>2015-02-25 11:05:10 +0000
committerPeter Maydell <peter.maydell@linaro.org>2015-02-25 11:05:10 +0000
commitc28d4869ea1235b80ef59d5f5e8ca96bc4155c0c (patch)
tree432a030b608fbd50d892d42d430ab527cd6beeea /util
parent73104fd399c6778112f64fe0d439319f24508d9a (diff)
parentee17cbdc3c21f5cb6144a434191ffcd08b7de5fe (diff)
Merge remote-tracking branch 'remotes/mdroth/tags/qga-pull-2015-02-16-v2-tag' into staging
tag for qga-pull-2015-02-16-v2 v2: * generalized QAPI function definition for guest-memory-block-size to guest-memory-block-info for future extensibility (Eric) # gpg: Signature made Tue Feb 17 22:36:08 2015 GMT using RSA key ID F108B584 # gpg: Good signature from "Michael Roth <flukshun@gmail.com>" # gpg: aka "Michael Roth <mdroth@utexas.edu>" # gpg: aka "Michael Roth <mdroth@linux.vnet.ibm.com>" # gpg: WARNING: This key is not certified with a trusted signature! # gpg: There is no indication that the signature belongs to the owner. # Primary key fingerprint: CEAC C9E1 5534 EBAB B82D 3FA0 3353 C9CE F108 B584 * remotes/mdroth/tags/qga-pull-2015-02-16-v2-tag: qemu-ga-win: Fail loudly on bare 'set-time' qga: add memory block command that unsupported qga: implement qmp_guest_get_memory_block_info() for Linux with sysfs qga: implement qmp_guest_set_memory_blocks() for Linux with sysfs qga: implement qmp_guest_get_memory_blocks() for Linux with sysfs qga: introduce three guest memory block commmands with stubs qga: implement file commands for Windows guest guest agent: guest-file-open: refactoring utils: drop strtok_r from envlist_parse qga: add guest-set-user-password command Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
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 ebc06cf0f3..099a544a41 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;
}
/*