提交 fe006368 编写于 作者: J John Ferlan

openvz: Use virStringSplitCount instead of strtok_r

When parsing the barrier:limit values, use virStringSplitCount in order
to split the pair and make the approriate checks to get the data.
Signed-off-by: NJohn Ferlan <jferlan@redhat.com>
上级 b2ce5b02
......@@ -133,35 +133,25 @@ openvzParseBarrierLimit(const char* value,
unsigned long long *barrier,
unsigned long long *limit)
{
char *token;
char *saveptr = NULL;
char *str;
char **tmp = NULL;
size_t ntmp = 0;
int ret = -1;
if (VIR_STRDUP(str, value) < 0)
if (!(tmp = virStringSplitCount(value, ":", 0, &ntmp)))
goto error;
token = strtok_r(str, ":", &saveptr);
if (token == NULL) {
goto error;
} else {
if (barrier != NULL) {
if (virStrToLong_ull(token, NULL, 10, barrier))
if (ntmp != 2)
goto error;
}
}
token = strtok_r(NULL, ":", &saveptr);
if (token == NULL) {
if (barrier && virStrToLong_ull(tmp[0], NULL, 10, barrier) < 0)
goto error;
} else {
if (limit != NULL) {
if (virStrToLong_ull(token, NULL, 10, limit))
if (limit && virStrToLong_ull(tmp[1], NULL, 10, limit) < 0)
goto error;
}
}
ret = 0;
error:
VIR_FREE(str);
virStringFreeListCount(tmp, ntmp);
return ret;
}
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册