if (!separator)
goto error;
- if (VIR_STRNDUP(type, arg, separator - arg) < 0)
- goto error;
+ type = g_strndup(arg, separator - arg);
/* Only support com%d */
if (STRPREFIX(type, "com") && type[4] == 0) {
else
separator++; /* Skip comma */
- if (VIR_STRNDUP(slotdef, arg, separator - arg - 1) < 0)
- goto error;
+ slotdef = g_strndup(arg, separator - arg - 1);
conf = strchr(separator+1, ',');
if (conf) {
offset2 = strchr(offset, '@');
if (offset2 != NULL) {
- if (VIR_STRNDUP(def->source->data.udp.connectService,
- offset + 1, offset2 - offset - 1) < 0)
- goto error;
+ def->source->data.udp.connectService = g_strndup(offset + 1,
+ offset2 - offset - 1);
offset3 = strchr(offset2, ':');
if (offset3 == NULL) {
if ((vlanstr = strchr(bridge, '.'))) {
/* 'bridge' string contains a bridge name and single vlan tag */
- if (VIR_STRNDUP(net->data.bridge.brname, bridge, vlanstr - bridge) < 0)
- return -1;
+ net->data.bridge.brname = g_strndup(bridge, vlanstr - bridge);
vlanstr++;
if (virStrToLong_ui(vlanstr, NULL, 10, &tag) < 0)
/* No source file given, eg CDROM with no media */
ignore_value(virDomainDiskSetSource(disk, NULL));
} else {
- if (VIR_STRNDUP(tmp, head, offset - head) < 0)
- goto error;
+ tmp = g_strndup(head, offset - head);
if (virDomainDiskSetSource(disk, tmp) < 0) {
VIR_FREE(tmp);
if (!p)
goto parse_error;
- if (VIR_STRNDUP(result[i].path, temp, p - temp) < 0)
- goto cleanup;
+ result[i].path = g_strndup(temp, p - temp);
/* value */
temp = p + 1;
if (!p)
goto parse_error;
- if (VIR_STRNDUP(result[i].path, temp, p - temp) < 0)
- goto cleanup;
+ result[i].path = g_strndup(temp, p - temp);
/* value */
temp = p + 1;
separator = endmark;
}
- if (VIR_STRNDUP(keyword, start, separator - start) < 0)
- goto error;
+ keyword = g_strndup(start, separator - start);
if (separator < endmark) {
separator++;
- if (VIR_STRNDUP(value, separator, endmark - separator) < 0) {
- VIR_FREE(keyword);
- goto error;
- }
+ value = g_strndup(separator, endmark - separator);
if (strchr(value, ',')) {
char *p = strchr(value, ',') + 1;
char *q = p + 1;
return NULL;
}
- if (VIR_STRNDUP(ret, group->legacy[i].mountPoint,
- tmp - group->legacy[i].mountPoint) < 0)
- return NULL;
+ ret = g_strndup(group->legacy[i].mountPoint,
+ tmp - group->legacy[i].mountPoint);
return ret;
}
/* NB match #0 is the full pattern, so we offset j by 1 */
for (j = 1; j <= nvars[i]; j++)
groups[ngroup++] = g_match_info_fetch(info, j);
-
}
/* We've matched on the last regex, so callback time */
if (i == nregex) {
virConfError(ctxt, VIR_ERR_CONF_SYNTAX, _("unterminated string"));
return NULL;
}
- if (VIR_STRNDUP(ret, base, ctxt->cur - base) < 0)
- return NULL;
+ ret = g_strndup(base, ctxt->cur - base);
NEXT;
} else if ((ctxt->cur + 6 < ctxt->end) &&
(STRPREFIX(ctxt->cur, "\"\"\""))) {
virConfError(ctxt, VIR_ERR_CONF_SYNTAX, _("unterminated string"));
return NULL;
}
- if (VIR_STRNDUP(ret, base, ctxt->cur - base) < 0)
- return NULL;
+ ret = g_strndup(base, ctxt->cur - base);
ctxt->cur += 3;
} else if (CUR == '"') {
NEXT;
virConfError(ctxt, VIR_ERR_CONF_SYNTAX, _("unterminated string"));
return NULL;
}
- if (VIR_STRNDUP(ret, base, ctxt->cur - base) < 0)
- return NULL;
+ ret = g_strndup(base, ctxt->cur - base);
NEXT;
} else if (ctxt->conf->flags & VIR_CONF_FLAG_LXC_FORMAT) {
base = ctxt->cur;
/* Reverse to exclude the trailing blanks from the value */
while ((ctxt->cur > base) && (IS_BLANK(CUR)))
ctxt->cur--;
- if (VIR_STRNDUP(ret, base, ctxt->cur - base) < 0)
- return NULL;
+ ret = g_strndup(base, ctxt->cur - base);
}
return ret;
}
((ctxt->conf->flags & VIR_CONF_FLAG_LXC_FORMAT) &&
(CUR == '.'))))
NEXT;
- if (VIR_STRNDUP(ret, base, ctxt->cur - base) < 0)
- return NULL;
+ ret = g_strndup(base, ctxt->cur - base);
return ret;
}
NEXT;
base = ctxt->cur;
while ((ctxt->cur < ctxt->end) && (!IS_EOL(CUR))) NEXT;
- if (VIR_STRNDUP(comm, base, ctxt->cur - base) < 0)
- return -1;
+ comm = g_strndup(base, ctxt->cur - base);
if (virConfAddEntry(ctxt->conf, NULL, NULL, comm) == NULL) {
VIR_FREE(comm);
return -1;
NEXT;
base = ctxt->cur;
while ((ctxt->cur < ctxt->end) && (!IS_EOL(CUR))) NEXT;
- if (VIR_STRNDUP(comm, base, ctxt->cur - base) < 0) {
- VIR_FREE(name);
- virConfFreeValue(value);
- return -1;
- }
+ comm = g_strndup(base, ctxt->cur - base);
}
if (virConfAddEntry(ctxt->conf, name, value, comm) == NULL) {
VIR_FREE(name);
if (!(next = strchr(current, ' ')))
goto error;
- if (VIR_STRNDUP(iface, current, (next - current)) < 0)
- goto cleanup;
+ iface = g_strndup(current, next - current);
current = next + 1;
return -1;
}
- if (VIR_STRNDUP(ctxt->groupname, name, ctxt->cur - name) < 0)
- return -1;
+ ctxt->groupname = g_strndup(name, ctxt->cur - name);
NEXT;
return -1;
}
- if (VIR_STRNDUP(key, keystart, ctxt->cur - keystart) < 0)
- return -1;
+ key = g_strndup(keystart, ctxt->cur - keystart);
NEXT;
valuestart = ctxt->cur;
return -1;
}
- if (VIR_STRNDUP(protocol, path, p - path) < 0)
- return -1;
+ protocol = g_strndup(path, p - path);
if ((src->protocol = virStorageNetProtocolTypeFromString(protocol)) < 0) {
virReportError(VIR_ERR_INTERNAL_ERROR,
start += 1;
end = strchrnul(start, delim2);
virSkipSpaces(&start);
- if (VIR_STRNDUP(*value, start, end - start) < 0)
- return NULL;
+ *value = g_strndup(start, end - start);
virTrimSpaces(*value, NULL);
return end;
}
return -1;
}
- if (VIR_STRNDUP(*directory, path, separator - path - 1) < 0)
- goto error;
+ *directory = g_strndup(path, separator - path - 1);
*filename = g_strdup(separator);
} else {
}
return 0;
-
- error:
- return -1;
}
void