Adapt to new VIR_STRNDUP behavior

With previous patch, we accept negative value as length of string to
duplicate. So there is no need to pass strlen(src) in case we want to do
duplicate the whole string.
This commit is contained in:
Michal Privoznik 2013-05-24 11:21:36 +02:00
parent c93571968b
commit 0fc5d09cbb
4 changed files with 11 additions and 15 deletions

View File

@ -17370,8 +17370,7 @@ virDomainGraphicsListenSetAddress(virDomainGraphicsDefPtr def,
return 0; return 0;
} }
if (VIR_STRNDUP(listenInfo->address, address, if (VIR_STRNDUP(listenInfo->address, address, len) < 0)
len == -1 ? strlen(address) : len) < 0)
return -1; return -1;
return 0; return 0;
} }
@ -17409,8 +17408,7 @@ virDomainGraphicsListenSetNetwork(virDomainGraphicsDefPtr def,
return 0; return 0;
} }
if (VIR_STRNDUP(listenInfo->network, network, if (VIR_STRNDUP(listenInfo->network, network, len) < 0)
len == -1 ? strlen(network) : len) < 0)
return -1; return -1;
return 0; return 0;
} }

View File

@ -8674,7 +8674,7 @@ static int qemuStringToArgvEnv(const char *args,
if (!next) if (!next)
next = strchr(curr, '\n'); next = strchr(curr, '\n');
if (VIR_STRNDUP(arg, curr, next ? next - curr : strlen(curr)) < 0) if (VIR_STRNDUP(arg, curr, next ? next - curr : -1) < 0)
goto error; goto error;
if (next && (*next == '\'' || *next == '"')) if (next && (*next == '\'' || *next == '"'))
@ -9566,16 +9566,14 @@ qemuParseCommandLineChr(virDomainChrSourceDefPtr source,
if (VIR_STRNDUP(source->data.tcp.host, val, svc - val) < 0) if (VIR_STRNDUP(source->data.tcp.host, val, svc - val) < 0)
goto error; goto error;
svc++; svc++;
if (VIR_STRNDUP(source->data.tcp.service, svc, if (VIR_STRNDUP(source->data.tcp.service, svc, opt ? opt - svc : -1) < 0)
opt ? opt - svc : strlen(svc)) < 0)
goto error; goto error;
} else if (STRPREFIX(val, "unix:")) { } else if (STRPREFIX(val, "unix:")) {
const char *opt; const char *opt;
val += strlen("unix:"); val += strlen("unix:");
opt = strchr(val, ','); opt = strchr(val, ',');
source->type = VIR_DOMAIN_CHR_TYPE_UNIX; source->type = VIR_DOMAIN_CHR_TYPE_UNIX;
if (VIR_STRNDUP(source->data.nix.path, val, if (VIR_STRNDUP(source->data.nix.path, val, opt ? opt - val : -1) < 0)
opt ? opt - val : strlen(val)) < 0)
goto error; goto error;
} else if (STRPREFIX(val, "/dev")) { } else if (STRPREFIX(val, "/dev")) {
@ -9634,7 +9632,7 @@ qemuParseCommandLineCPU(virDomainDefPtr dom,
next++; next++;
if (p == val) { if (p == val) {
if (VIR_STRNDUP(model, p, next ? next - p - 1 : strlen(p)) < 0) if (VIR_STRNDUP(model, p, next ? next - p - 1 : -1) < 0)
goto error; goto error;
if (!STREQ(model, "qemu32") && !STREQ(model, "qemu64")) { if (!STREQ(model, "qemu32") && !STREQ(model, "qemu64")) {
@ -9658,7 +9656,7 @@ qemuParseCommandLineCPU(virDomainDefPtr dom,
if (*p == '\0' || *p == ',') if (*p == '\0' || *p == ',')
goto syntax; goto syntax;
if (VIR_STRNDUP(feature, p, next ? next - p - 1 : strlen(p)) < 0) if (VIR_STRNDUP(feature, p, next ? next - p - 1 : -1) < 0)
goto error; goto error;
if (STREQ(feature, "kvmclock")) { if (STREQ(feature, "kvmclock")) {
@ -9717,7 +9715,7 @@ qemuParseCommandLineCPU(virDomainDefPtr dom,
if (*p == '\0' || *p == ',') if (*p == '\0' || *p == ',')
goto syntax; goto syntax;
if (VIR_STRNDUP(feature, p, next ? next - p - 1 : strlen(p)) < 0) if (VIR_STRNDUP(feature, p, next ? next - p - 1 : -1) < 0)
goto error; goto error;
dom->features |= (1 << VIR_DOMAIN_FEATURE_HYPERV); dom->features |= (1 << VIR_DOMAIN_FEATURE_HYPERV);

View File

@ -120,7 +120,7 @@ sexpr_string(const char *str, ssize_t len)
return ret; return ret;
ret->kind = SEXPR_VALUE; ret->kind = SEXPR_VALUE;
if (VIR_STRNDUP(ret->u.value, str, len > 0 ? len : strlen(str)) < 0) if (VIR_STRNDUP(ret->u.value, str, len) < 0)
VIR_FREE(ret); VIR_FREE(ret);
return ret; return ret;

View File

@ -242,7 +242,7 @@ xenParseSxprChar(const char *value,
offset2 = strchr(offset, ','); offset2 = strchr(offset, ',');
offset++; offset++;
if (VIR_STRNDUP(def->source.data.tcp.service, offset, if (VIR_STRNDUP(def->source.data.tcp.service, offset,
offset2 ? offset2 - offset : strlen(offset)) < 0) offset2 ? offset2 - offset : -1) < 0)
goto error; goto error;
if (offset2 && strstr(offset2, ",server")) if (offset2 && strstr(offset2, ",server"))
@ -296,7 +296,7 @@ xenParseSxprChar(const char *value,
{ {
const char *offset = strchr(value, ','); const char *offset = strchr(value, ',');
if (VIR_STRNDUP(def->source.data.nix.path, value, if (VIR_STRNDUP(def->source.data.nix.path, value,
offset ? offset - value : strlen(value)) < 0) offset ? offset - value : -1) < 0)
goto error; goto error;
if (offset != NULL && if (offset != NULL &&