virAddr.data.inet4.sin_addr = *(struct in_addr *)addr;
ipstr = virSocketAddrFormat(&virAddr);
- if (VIR_STRDUP(table->t[num].ipaddr, ipstr) < 0)
- goto cleanup;
+ table->t[num].ipaddr = g_strdup(ipstr);
}
if (tb[NDA_LLADDR]) {
virMacAddrFormat(&macaddr, ifmac);
- if (VIR_STRDUP(table->t[num].mac, ifmac) < 0)
- goto cleanup;
+ table->t[num].mac = g_strdup(ifmac);
num++;
}
if (authenv) {
VIR_DEBUG("Using path from env '%s'", authenv);
- if (VIR_STRDUP(*path, authenv) < 0)
- return -1;
+ *path = g_strdup(authenv);
return 0;
}
if (STREQ_NULLABLE(uri->params[i].name, "authfile") &&
uri->params[i].value) {
VIR_DEBUG("Using path from URI '%s'", uri->params[i].value);
- if (VIR_STRDUP(*path, uri->params[i].value) < 0)
- return -1;
+ *path = g_strdup(uri->params[i].value);
return 0;
}
}
VIR_FREE(*path);
- if (VIR_STRDUP(*path, SYSCONFDIR "/libvirt/auth.conf") < 0)
- return -1;
+ *path = g_strdup(SYSCONFDIR "/libvirt/auth.conf");
VIR_DEBUG("Checking for readability of '%s'", *path);
if (access(*path, R_OK) == 0)
&tmp) < 0)
return -1;
- if (VIR_STRDUP(*value, tmp) < 0)
- return -1;
+ *value = g_strdup(tmp);
return 0;
}
if (VIR_ALLOC(auth) < 0)
goto error;
- if (VIR_STRDUP(auth->path, path) < 0)
- goto error;
+ auth->path = g_strdup(path);
if (!(auth->keyfile = virKeyFileNew()))
goto error;
if (VIR_ALLOC(auth) < 0)
goto error;
- if (VIR_STRDUP(auth->path, path) < 0)
- goto error;
+ auth->path = g_strdup(path);
if (!(auth->keyfile = virKeyFileNew()))
goto error;
return;
VIR_FREE(cmd->pidfile);
- if (VIR_STRDUP_QUIET(cmd->pidfile, pidfile) < 0)
- cmd->has_error = ENOMEM;
+ cmd->pidfile = g_strdup(pidfile);
}
#if defined(WITH_SECDRIVER_SELINUX)
VIR_FREE(cmd->seLinuxLabel);
- if (VIR_STRDUP_QUIET(cmd->seLinuxLabel, label) < 0)
- cmd->has_error = ENOMEM;
+ cmd->seLinuxLabel = g_strdup(label);
#endif
return;
}
#if defined(WITH_SECDRIVER_APPARMOR)
VIR_FREE(cmd->appArmorProfile);
- if (VIR_STRDUP_QUIET(cmd->appArmorProfile, profile) < 0)
- cmd->has_error = ENOMEM;
+ cmd->appArmorProfile = g_strdup(profile);
#endif
return;
}
if (!cmd || cmd->has_error)
return;
- if (VIR_STRDUP_QUIET(env, str) < 0) {
- cmd->has_error = ENOMEM;
- return;
- }
+ env = g_strdup(str);
virCommandAddEnv(cmd, env);
}
return;
}
- if (VIR_STRDUP_QUIET(arg, val) < 0) {
- cmd->has_error = ENOMEM;
- return;
- }
+ arg = g_strdup(val);
/* Arg plus trailing NULL. */
if (VIR_RESIZE_N(cmd->args, cmd->maxargs, cmd->nargs, 1 + 1) < 0) {
}
cmd->args[cmd->nargs] = virBufferContentAndReset(buf);
- if (!cmd->args[cmd->nargs]) {
- if (VIR_STRDUP_QUIET(cmd->args[cmd->nargs], "") < 0) {
- cmd->has_error = ENOMEM;
- return;
- }
- }
+ if (!cmd->args[cmd->nargs])
+ cmd->args[cmd->nargs] = g_strdup("");
cmd->nargs++;
}
while (vals[narg] != NULL) {
char *arg;
- if (VIR_STRDUP_QUIET(arg, vals[narg++]) < 0) {
- cmd->has_error = ENOMEM;
- return;
- }
+ arg = g_strdup(vals[narg++]);
cmd->args[cmd->nargs++] = arg;
}
}
char *arg = va_arg(list, char *);
if (!arg)
break;
- if (VIR_STRDUP_QUIET(arg, arg) < 0) {
- cmd->has_error = ENOMEM;
- va_end(list);
- return;
- }
+ arg = g_strdup(arg);
cmd->args[cmd->nargs++] = arg;
}
va_end(list);
cmd->has_error = -1;
VIR_DEBUG("cannot set directory twice");
} else {
- if (VIR_STRDUP_QUIET(cmd->pwd, pwd) < 0)
- cmd->has_error = ENOMEM;
+ cmd->pwd = g_strdup(pwd);
}
}
return;
}
- if (VIR_STRDUP_QUIET(cmd->inbuf, inbuf) < 0)
- cmd->has_error = ENOMEM;
+ cmd->inbuf = g_strdup(inbuf);
}
if (!ret)
return NULL;
- if (VIR_STRDUP(ret->filename, filename) < 0) {
- VIR_FREE(ret);
- return NULL;
- }
+ ret->filename = g_strdup(filename);
ret->flags = flags;
return ret;
}
VIR_FREE(*value);
- if (VIR_STRDUP(*value, cval->str) < 0)
- return -1;
+ *value = g_strdup(cval->str);
return 1;
}
if (VIR_ALLOC_N(*values, len + 1) < 0)
return -1;
- for (len = 0, eval = cval->list; eval; len++, eval = eval->next) {
- if (VIR_STRDUP((*values)[len], eval->str) < 0) {
- virStringListFree(*values);
- *values = NULL;
- return -1;
- }
- }
+ for (len = 0, eval = cval->list; eval; len++, eval = eval->next)
+ (*values)[len] = g_strdup(eval->str);
break;
case VIR_CONF_STRING:
if (compatString) {
if (VIR_ALLOC_N(*values, cval->str ? 2 : 1) < 0)
return -1;
- if (cval->str &&
- VIR_STRDUP((*values)[0], cval->str) < 0) {
- VIR_FREE(*values);
- return -1;
- }
+ if (cval->str)
+ (*values)[0] = g_strdup(cval->str);
break;
}
G_GNUC_FALLTHROUGH;
return -1;
}
cur->comment = NULL;
- if (VIR_STRDUP(cur->name, setting) < 0) {
- virConfFreeValue(value);
- VIR_FREE(cur);
- return -1;
- }
+ cur->name = g_strdup(setting);
cur->value = value;
if (prev) {
cur->next = prev->next;
}
char *s;
dbus_message_iter_get_basic(iter, &s);
- if (VIR_STRDUP(*x, s) < 0)
- goto cleanup;
+ *x = g_strdup(s);
VIR_DEBUG("Read basic type 'char *' varg 'char **'"
"' val '%s'", *x);
} while (0);
error->level = VIR_ERR_ERROR;
error->code = VIR_ERR_DBUS_SERVICE;
error->domain = VIR_FROM_DBUS;
- if (VIR_STRDUP(error->message, localerror.message) < 0)
- goto cleanup;
- if (VIR_STRDUP(error->str1, localerror.name) < 0)
- goto cleanup;
+ error->message = g_strdup(localerror.message);
+ error->str1 = g_strdup(localerror.name);
ret = 0;
} else {
virReportError(VIR_ERR_DBUS_SERVICE, _("%s: %s"), member,
if (VIR_ALLOC(addnhostsfile->hosts[idx].hostnames) < 0)
goto error;
- if (VIR_STRDUP(addnhostsfile->hosts[idx].ip, ipstr) < 0)
- goto error;
+ addnhostsfile->hosts[idx].ip = g_strdup(ipstr);
addnhostsfile->hosts[idx].nhostnames = 0;
addnhostsfile->nhosts++;
if (VIR_REALLOC_N(addnhostsfile->hosts[idx].hostnames, addnhostsfile->hosts[idx].nhostnames + 1) < 0)
goto error;
- if (VIR_STRDUP(addnhostsfile->hosts[idx].hostnames[addnhostsfile->hosts[idx].nhostnames],
- name) < 0)
- goto error;
+ addnhostsfile->hosts[idx].hostnames[addnhostsfile->hosts[idx].nhostnames] = g_strdup(name);
VIR_FREE(ipstr);
if (VIR_ALLOC(ctx) < 0)
return NULL;
- if (VIR_STRDUP(ctx->config_dir, config_dir) < 0)
- goto error;
+ ctx->config_dir = g_strdup(config_dir);
if (!(ctx->hostsfile = hostsfileNew(network_name, config_dir)))
goto error;
return NULL;
if (!(caps->flags = virBitmapNew(DNSMASQ_CAPS_LAST)))
goto error;
- if (VIR_STRDUP(caps->binaryPath, binaryPath ? binaryPath : DNSMASQ) < 0)
- goto error;
+ caps->binaryPath = g_strdup(binaryPath ? binaryPath : DNSMASQ);
return caps;
error:
to->code = from->code;
to->domain = from->domain;
to->level = from->level;
- if (VIR_STRDUP_QUIET(to->message, from->message) < 0)
- ret = -1;
- if (VIR_STRDUP_QUIET(to->str1, from->str1) < 0)
- ret = -1;
- if (VIR_STRDUP_QUIET(to->str2, from->str2) < 0)
- ret = -1;
- if (VIR_STRDUP_QUIET(to->str3, from->str3) < 0)
- ret = -1;
+ to->message = g_strdup(from->message);
+ to->str1 = g_strdup(from->str1);
+ to->str2 = g_strdup(from->str2);
+ to->str3 = g_strdup(from->str3);
to->int1 = from->int1;
to->int2 = from->int2;
/*
if ((p = strchr(buf, '\n')))
*p = '\0';
- if (VIR_STRDUP(*result, buf) < 0)
- return -1;
+ *result = g_strdup(buf);
return 0;
}
if ((oflags & O_ACCMODE) == O_RDONLY) {
threadData->fdin = fd;
threadData->fdout = pipefds[1];
- if (VIR_STRDUP(threadData->fdinname, path) < 0 ||
- VIR_STRDUP(threadData->fdoutname, "pipe") < 0)
- goto error;
+ threadData->fdinname = g_strdup(path);
+ threadData->fdoutname = g_strdup("pipe");
tmpfd = pipefds[0];
threadData->doRead = true;
} else {
threadData->fdin = pipefds[0];
threadData->fdout = fd;
- if (VIR_STRDUP(threadData->fdinname, "pipe") < 0 ||
- VIR_STRDUP(threadData->fdoutname, path) < 0)
- goto error;
+ threadData->fdinname = g_strdup("pipe");
+ threadData->fdoutname = g_strdup(path);
tmpfd = pipefds[1];
threadData->doRead = false;
}
if (lstat(linkpath, &st) < 0)
return -1;
- if (!S_ISLNK(st.st_mode))
- return VIR_STRDUP_QUIET(*resultpath, linkpath) < 0 ? -1 : 0;
+ if (!S_ISLNK(st.st_mode)) {
+ *resultpath = g_strdup(linkpath);
+ return 0;
+ }
}
*resultpath = virFileCanonicalizePath(linkpath);
origpath = getenv("PATH");
if (!origpath)
origpath = "/bin:/usr/bin";
-
- if (VIR_STRDUP_QUIET(path, origpath) <= 0)
- return NULL;
+ path = g_strdup(origpath);
/* for each path segment, append the file to search for and test for
* it. return it if found.
if (VIR_EXPAND_N(mounts, nmounts, nmounts ? 1 : 2) < 0)
goto cleanup;
- if (VIR_STRDUP(mounts[nmounts - 2], mntent.mnt_dir) < 0)
- goto cleanup;
+ mounts[nmounts - 2] = g_strdup(mntent.mnt_dir);
}
if (mounts)
{
g_autofree char *tmp = NULL;
- if (VIR_STRDUP(tmp, path) < 0) {
- errno = ENOMEM;
- return -1;
- }
+ tmp = g_strdup(path);
return virFileMakePathHelper(tmp, mode);
}
VIR_DEBUG("path=%s", path);
- if (VIR_STRDUP(tmp, path) < 0) {
- errno = ENOMEM;
- return -1;
- }
+ tmp = g_strdup(path);
if ((p = strrchr(tmp, '/')) == NULL) {
errno = EINVAL;
virFileAbsPath(const char *path, char **abspath)
{
if (path[0] == '/') {
- if (VIR_STRDUP(*abspath, path) < 0)
- return -1;
+ *abspath = g_strdup(path);
} else {
g_autofree char *buf = getcwd(NULL, 0);
char *cleanpath;
int idx = 0;
- if (VIR_STRDUP(cleanpath, path) < 0)
- return NULL;
+ cleanpath = g_strdup(path);
/* don't sanitize URIs - rfc3986 states that two slashes may lead to a
* different resource, thus removing them would possibly change the path */
maxMatching = len;
VIR_FREE(mntType);
VIR_FREE(mntDir);
- if (VIR_STRDUP(mntDir, mb.mnt_dir) < 0 ||
- VIR_STRDUP(mntType, mb.mnt_type) < 0)
- goto cleanup;
+ mntDir = g_strdup(mb.mnt_dir);
+ mntType = g_strdup(mb.mnt_type);
}
}
int statfs_ret;
long long f_type = 0;
- if (VIR_STRDUP(dirpath, path) < 0)
- return -1;
+ dirpath = g_strdup(path);
statfs_ret = statfs(dirpath, &sb);
tmp = &fs[nfs - 1];
- if (VIR_STRDUP(tmp->mnt_dir, mb.mnt_dir) < 0)
- goto cleanup;
+ tmp->mnt_dir = g_strdup(mb.mnt_dir);
if (virFileGetHugepageSize(tmp->mnt_dir, &tmp->size) < 0)
goto cleanup;
if (!(cache->table = virHashCreate(10, virObjectFreeHashData)))
goto cleanup;
- if (VIR_STRDUP(cache->dir, dir) < 0)
- goto cleanup;
+ cache->dir = g_strdup(dir);
- if (VIR_STRDUP(cache->suffix, suffix) < 0)
- goto cleanup;
+ cache->suffix = g_strdup(suffix);
cache->handlers = *handlers;
rule->argsLen, 1) < 0) \
goto no_memory; \
\
- if (VIR_STRDUP(rule->args[rule->argsLen++], str) < 0) \
- goto no_memory; \
+ rule->args[rule->argsLen++] = g_strdup(str); \
} while (0)
static virFirewallRulePtr
goto cleanup;
}
- if (VIR_STRDUP(firmware->name, token[0]) < 0 ||
- VIR_STRDUP(firmware->nvram, token[1]) < 0)
- goto cleanup;
+ firmware->name = g_strdup(token[0]);
+ firmware->nvram = g_strdup(token[1]);
ret = 0;
cleanup:
if (VIR_ALLOC(fws[j]) < 0)
goto cleanup;
- if (VIR_STRDUP(fws[j]->name, token[2 * j]) < 0 ||
- VIR_STRDUP(fws[j]->nvram, token[2 * j + 1]) < 0)
- goto cleanup;
+ fws[j]->name = g_strdup(token[2 * j]);
+ fws[j]->nvram = g_strdup(token[2 * j + 1]);
}
}
return NULL;
if (privileged) {
- if (VIR_STRDUP(hostdevMgr->stateDir, HOSTDEV_STATE_DIR) < 0)
- return NULL;
+ hostdevMgr->stateDir = g_strdup(HOSTDEV_STATE_DIR);
if (virFileMakePath(hostdevMgr->stateDir) < 0) {
virReportError(VIR_ERR_OPERATION_FAILED,
cellNum = VIR_NODE_MEMORY_STATS_ALL_CELLS;
if (cellNum == VIR_NODE_MEMORY_STATS_ALL_CELLS) {
- if (VIR_STRDUP(meminfo_path, MEMINFO_PATH) < 0)
- return -1;
+ meminfo_path = g_strdup(MEMINFO_PATH);
} else {
if ((max_node = virNumaGetMaxNode()) < 0)
return -1;
current = next + 1;
}
- if (VIR_STRDUP(iqn, current) < 0)
- goto cleanup;
+ iqn = g_strdup(current);
if (STREQ(iqn, initiatoriqn)) {
*ifacename = g_steal_pointer(&iface);
struct virISCSITargetList *list = data;
g_autofree char *target = NULL;
- if (VIR_STRDUP(target, groups[1]) < 0)
- return -1;
+ target = g_strdup(groups[1]);
if (VIR_APPEND_ELEMENT(list->targets, list->ntargets, target) < 0)
return -1;
return NULL;
val->type = VIR_JSON_TYPE_STRING;
- if (VIR_STRDUP(val->data.string, data) < 0) {
- VIR_FREE(val);
- return NULL;
- }
+ val->data.string = g_strdup(data);
return val;
}
return NULL;
val->type = VIR_JSON_TYPE_NUMBER;
- if (VIR_STRDUP(val->data.number, data) < 0) {
- VIR_FREE(val);
- return NULL;
- }
+ val->data.number = g_strdup(data);
return val;
}
return -1;
}
- if (VIR_STRDUP(pair.key, key) < 0)
- return -1;
+ pair.key = g_strdup(key);
if (prepend) {
ret = VIR_INSERT_ELEMENT(object->data.object.pairs, 0,
return 0;
if (exptime_tmp) {
- if (VIR_STRDUP(exptime, exptime_tmp) < 0)
- return -1;
+ exptime = g_strdup(exptime_tmp);
/* Removed extraneous trailing space in DNSMASQ_LEASE_EXPIRES
* (dnsmasq < 2.52) */
res->fd = -1;
res->flags = flags;
- if (VIR_STRDUP(res->name, resname) < 0)
- goto error;
+ res->name = g_strdup(resname);
if (!(res->path = virLockSpaceGetResourcePath(lockspace, resname)))
goto error;
return NULL;
}
- if (VIR_STRDUP(lockspace->dir, directory) < 0)
- goto error;
+ lockspace->dir = g_strdup(directory);
if (!(lockspace->resources = virHashCreate(VIR_LOCKSPACE_TABLE_SIZE,
virLockSpaceResourceDataFree)))
if (virJSONValueObjectHasKey(object, "directory")) {
const char *dir = virJSONValueObjectGetString(object, "directory");
- if (VIR_STRDUP(lockspace->dir, dir) < 0)
- goto error;
+ lockspace->dir = g_strdup(dir);
}
if (!(resources = virJSONValueObjectGet(object, "resources"))) {
virLockSpaceResourceFree(res);
goto error;
}
- if (VIR_STRDUP(res->name, tmp) < 0) {
- virLockSpaceResourceFree(res);
- goto error;
- }
+ res->name = g_strdup(tmp);
if (!(tmp = virJSONValueObjectGetString(child, "path"))) {
virReportError(VIR_ERR_INTERNAL_ERROR, "%s",
virLockSpaceResourceFree(res);
goto error;
}
- if (VIR_STRDUP(res->path, tmp) < 0) {
- virLockSpaceResourceFree(res);
- goto error;
- }
+ res->path = g_strdup(tmp);
if (virJSONValueObjectGetNumberInt(child, "fd", &res->fd) < 0) {
virReportError(VIR_ERR_INTERNAL_ERROR, "%s",
_("Missing resource fd in JSON document"));
* rather than copying @ident, syslog uses caller's reference instead
*/
VIR_FREE(current_ident);
- if (VIR_STRDUP(current_ident, ident) < 0)
- return NULL;
+ current_ident = g_strdup(ident);
openlog(current_ident, 0, 0);
}
return NULL;
}
- if (VIR_STRDUP(ndup, name) < 0)
- return NULL;
+ ndup = g_strdup(name);
}
if (VIR_ALLOC(ret) < 0) {
* holding the lock so it's safe to call openlog and change the message
* tag
*/
- if (VIR_STRDUP_QUIET(tmp, outputs[id]->name) < 0) {
- virLogUnlock();
- return -1;
- }
+ tmp = g_strdup(outputs[id]->name);
VIR_FREE(current_ident);
current_ident = tmp;
openlog(current_ident, 0, 0);
{
VIR_FREE(dev->used_by_drvname);
VIR_FREE(dev->used_by_domname);
- if (VIR_STRDUP(dev->used_by_drvname, drvname) < 0)
- return -1;
- if (VIR_STRDUP(dev->used_by_domname, domname) < 0)
- return -1;
+ dev->used_by_drvname = g_strdup(drvname);
+ dev->used_by_domname = g_strdup(domname);
return 0;
}
if (VIR_ALLOC(tmp) < 0)
return -1;
- if (VIR_STRDUP(tmp->id, last_component(sysfspath)) < 0)
- return -1;
+ tmp->id = g_strdup(last_component(sysfspath));
/* @name sysfs attribute is optional, so getting ENOENT is fine */
MDEV_GET_SYSFS_ATTR("name", &tmp->name, virFileReadValueString, true);
if (virtPortProfile && virNetlinkEventServiceIsRunning(NETLINK_ROUTE)) {
if (VIR_ALLOC(calld) < 0)
goto error;
- if (VIR_STRDUP(calld->cr_ifname, ifname) < 0)
- goto error;
+ calld->cr_ifname = g_strdup(ifname);
if (VIR_ALLOC(calld->virtPortProfile) < 0)
goto error;
memcpy(calld->virtPortProfile, virtPortProfile, sizeof(*virtPortProfile));
virMacAddrSet(&calld->macaddress, macaddress);
- if (VIR_STRDUP(calld->linkdev, linkdev) < 0)
- goto error;
+ calld->linkdev = g_strdup(linkdev);
memcpy(calld->vmuuid, vmuuid, sizeof(calld->vmuuid));
calld->vmOp = vmOp;
if (virNetDevMacVLanTapSetup(tapfd, tapfdSize, vnet_hdr) < 0)
goto disassociate_exit;
- if (VIR_STRDUP(*ifnameResult, ifnameCreated) < 0)
- goto disassociate_exit;
+ *ifnameResult = g_strdup(ifnameCreated);
} else {
- if (VIR_STRDUP(*ifnameResult, ifnameCreated) < 0)
- goto disassociate_exit;
+ *ifnameResult = g_strdup(ifnameCreated);
}
if (vmOp == VIR_NETDEV_VPORT_PROFILE_OP_CREATE ||
goto cleanup;
}
- if (VIR_STRDUP(*ifname, tmpIfname) < 0)
- goto cleanup;
+ *ifname = g_strdup(tmpIfname);
ret = 1;
cleanup:
return -1;
}
- return VIR_STRDUP(*ifname, ifr.ifr_name) < 0 ? -1 : 0;
+ *ifname = g_strdup(ifr.ifr_name);
+ return 0;
#else
return -1;
#endif
/* In case we are looping more than once, set other
* TAPs to have the same name */
VIR_FREE(*ifname);
- if (VIR_STRDUP(*ifname, ifr.ifr_name) < 0)
- goto cleanup;
+ *ifname = g_strdup(ifr.ifr_name);
}
if ((flags & VIR_NETDEV_TAP_CREATE_PERSIST) &&
goto cleanup;
}
} else {
- if (VIR_STRDUP(physfndev, ifname) < 0) {
- rc = -1;
- goto cleanup;
- }
+ physfndev = g_strdup(ifname);
}
rc = virNetDevGetIndex(physfndev, &ifindex);
_("too many object classes defined"));
goto error;
}
- if (VIR_STRDUP(klass->name, name) < 0)
- goto error;
+ klass->name = g_strdup(name);
klass->objectSize = objectSize;
klass->dispose = dispose;
}
/* path = "/sys/bus/pci/drivers/${drivername}" */
- if (VIR_STRDUP(*name, last_component(*path)) < 0)
- goto cleanup;
+ *name = g_strdup(last_component(*path));
/* name = "${drivername}" */
ret = 0;
*copy = *dev;
copy->path = NULL;
copy->used_by_drvname = copy->used_by_domname = NULL;
- if (VIR_STRDUP(copy->name, dev->name) < 0 ||
- VIR_STRDUP(copy->path, dev->path) < 0 ||
- VIR_STRDUP(copy->used_by_drvname, dev->used_by_drvname) < 0 ||
- VIR_STRDUP(copy->used_by_domname, dev->used_by_domname) < 0) {
- goto error;
- }
+ copy->name = g_strdup(dev->name);
+ copy->path = g_strdup(dev->path);
+ copy->used_by_drvname = g_strdup(dev->used_by_drvname);
+ copy->used_by_domname = g_strdup(dev->used_by_domname);
return copy;
-
- error:
- virPCIDeviceFree(copy);
- return NULL;
}
{
VIR_FREE(dev->used_by_drvname);
VIR_FREE(dev->used_by_domname);
- if (VIR_STRDUP(dev->used_by_drvname, drv_name) < 0)
- return -1;
- if (VIR_STRDUP(dev->used_by_domname, dom_name) < 0)
- return -1;
+ dev->used_by_drvname = g_strdup(drv_name);
+ dev->used_by_domname = g_strdup(dom_name);
return 0;
}
continue;
}
- if (VIR_STRDUP(*netname, entry->d_name) < 0)
- goto cleanup;
+ *netname = g_strdup(entry->d_name);
ret = 0;
break;
range->start = start;
range->end = end;
-
- if (VIR_STRDUP(range->name, name) < 0)
- goto error;
+ range->name = g_strdup(name);
return range;
-
- error:
- virPortAllocatorRangeFree(range);
- return NULL;
}
void
/* If the allocation is empty, then the path will be SYSFS_RESCTRL_PATH */
if (virResctrlAllocIsEmpty(alloc)) {
- if (VIR_STRDUP(alloc->path, SYSFS_RESCTRL_PATH) < 0)
- return -1;
+ alloc->path = g_strdup(SYSFS_RESCTRL_PATH);
return 0;
}
if (!virResctrlAllocIsEmpty(monitor->alloc) &&
STREQ_NULLABLE(monitor->id, monitor->alloc->id)) {
- if (VIR_STRDUP(monitor->path, monitor->alloc->path) < 0)
- return -1;
+ monitor->path = g_strdup(monitor->alloc->path);
return 0;
}
entry->inode = sb.st_ino;
}
- if (VIR_STRDUP(entry->path, path) < 0)
- goto error;
+ entry->path = g_strdup(path);
return entry;
if (VIR_ALLOC(file) < 0)
goto error;
- if (VIR_STRDUP(file->basepath, path) < 0)
- goto error;
+ file->basepath = g_strdup(path);
if (maxbackup > VIR_MAX_MAX_BACKUP) {
virReportError(VIR_ERR_CONFIG_UNSUPPORTED,
for (i = file->maxbackup; i > 0; i--) {
if (i == 1) {
- if (VIR_STRDUP(thispath, file->basepath) < 0)
- goto cleanup;
+ thispath = g_strdup(file->basepath);
} else {
if (virAsprintf(&thispath, "%s.%zu", file->basepath, i - 2) < 0)
goto cleanup;
if (VIR_ALLOC(copy) < 0)
return -1;
- if (VIR_STRDUP(copy->drvname, drvname) < 0 ||
- VIR_STRDUP(copy->domname, domname) < 0)
- return -1;
+ copy->drvname = g_strdup(drvname);
+ copy->domname = g_strdup(domname);
if (VIR_APPEND_ELEMENT(dev->used_by, dev->n_used_by, copy) < 0)
return -1;
{
VIR_FREE(dev->used_by_drvname);
VIR_FREE(dev->used_by_domname);
- if (VIR_STRDUP(dev->used_by_drvname, drvname) < 0)
- return -1;
- if (VIR_STRDUP(dev->used_by_domname, domname) < 0)
- return -1;
+ dev->used_by_drvname = g_strdup(drvname);
+ dev->used_by_domname = g_strdup(domname);
return 0;
}
if (VIR_ALLOC(dev) < 0)
return NULL;
- if (VIR_STRDUP(dev->name, name) < 0) {
- virReportError(VIR_ERR_INTERNAL_ERROR,
- _("dev->name buffer overflow: %s"),
- name);
- return NULL;
- }
+ dev->name = g_strdup(name);
if (virAsprintf(&dev->path, "%s/%s",
SYSFS_VHOST_SCSI_DEVICES, name) < 0)
{
virSecurityLabelDefPtr seclabel = NULL;
- if (VIR_ALLOC(seclabel) < 0 ||
- VIR_STRDUP(seclabel->model, model) < 0) {
+ if (VIR_ALLOC(seclabel) < 0) {
virSecurityLabelDefFree(seclabel);
return NULL;
}
+ seclabel->model = g_strdup(model);
+
seclabel->relabel = true;
return seclabel;
{
virSecurityDeviceLabelDefPtr seclabel = NULL;
- if (VIR_ALLOC(seclabel) < 0 ||
- VIR_STRDUP(seclabel->model, model) < 0) {
+ if (VIR_ALLOC(seclabel) < 0) {
virSecurityDeviceLabelDefFree(seclabel);
seclabel = NULL;
}
+ seclabel->model = g_strdup(model);
+
return seclabel;
}
ret->relabel = src->relabel;
ret->labelskip = src->labelskip;
- if (VIR_STRDUP(ret->model, src->model) < 0 ||
- VIR_STRDUP(ret->label, src->label) < 0)
- goto error;
+ ret->model = g_strdup(src->model);
+ ret->label = g_strdup(src->label);
return ret;
-
- error:
- virSecurityDeviceLabelDefFree(ret);
- return NULL;
}
if (dst->type == VIR_SECRET_LOOKUP_TYPE_UUID) {
memcpy(dst->u.uuid, src->u.uuid, VIR_UUID_BUFLEN);
} else if (dst->type == VIR_SECRET_LOOKUP_TYPE_USAGE) {
- if (VIR_STRDUP(dst->u.usage, src->u.usage) < 0)
- return -1;
+ dst->u.usage = g_strdup(src->u.usage);
}
return 0;
}
separator ? separator : ":") < 0)
return NULL;
} else {
- if (VIR_STRDUP(addrstr, VIR_LOOPBACK_IPV4_ADDR) < 0)
- return NULL;
+ addrstr = g_strdup(VIR_LOOPBACK_IPV4_ADDR);
}
return addrstr;
}
return NULL;
}
} else {
- if (VIR_STRDUP(addrstr, host) < 0)
- return NULL;
+ addrstr = g_strdup(host);
}
return addrstr;
if (VIR_RESIZE_N(tokens, maxtokens, ntokens, 1) < 0)
goto error;
- if (VIR_STRDUP(tokens[ntokens], remainder) < 0)
- goto error;
+ tokens[ntokens] = g_strdup(remainder);
ntokens++;
}
{
size_t i = virStringListLength((const char **) *strings);
- if (VIR_EXPAND_N(*strings, i, 2) < 0 ||
- VIR_STRDUP((*strings)[i - 2], item) < 0)
+ if (VIR_EXPAND_N(*strings, i, 2) < 0)
return -1;
+ (*strings)[i - 2] = g_strdup(item);
+
return 0;
}
if (VIR_ALLOC_N(copy, virStringListLength(src) + 1) < 0)
goto error;
- for (i = 0; src[i]; i++) {
- if (VIR_STRDUP(copy[i], src[i]) < 0)
- goto error;
- }
+ for (i = 0; src[i]; i++)
+ copy[i] = g_strdup(src[i]);
*dst = copy;
return 0;
cur, eol - cur) < 0)
goto error;
- if (VIR_STRDUP(processor->processor_type, processor_type) < 0)
- goto error;
+ processor->processor_type = g_strdup(processor_type);
base = cur;
}
if (VIR_EXPAND_N(ret->processor, ret->nprocessor, 1) < 0)
goto error;
processor = &ret->processor[ret->nprocessor - 1];
- if (VIR_STRDUP(processor->processor_manufacturer, manufacturer) < 0)
- goto error;
+ processor->processor_manufacturer = g_strdup(manufacturer);
if (!virSysinfoParseS390Delimited(procline, "version",
&processor->processor_version,
'=', ',') ||
if (!(slicename = virSystemdMakeSliceName(partition)))
goto cleanup;
} else {
- if (VIR_STRDUP(slicename, "") < 0)
- goto cleanup;
+ slicename = g_strdup("");
}
/*
}
break;
case VIR_TYPED_PARAM_STRING:
- if (VIR_STRDUP(param->value.s, val) < 0)
- return -1;
+ param->value.s = g_strdup(val);
break;
default:
virReportError(VIR_ERR_INTERNAL_ERROR,
goto error;
*maxparams = max;
- if (VIR_STRDUP(str, value) < 0)
- goto error;
+ str = g_strdup(value);
if (virTypedParameterAssign(*params + n, name,
VIR_TYPED_PARAM_STRING, str) < 0) {
break;
case VIR_TYPED_PARAM_STRING:
if (copystr) {
- if (VIR_STRDUP(param->value.s, va_arg(ap, char *)) < 0)
- return -1;
+ param->value.s = g_strdup(va_arg(ap, char *));
} else {
param->value.s = va_arg(ap, char *);
}
param = *params + n - 1;
}
- if (VIR_STRDUP(str, value) < 0)
- goto error;
+ str = g_strdup(value);
if (virTypedParameterAssign(param, name,
VIR_TYPED_PARAM_STRING, str) < 0) {
ignore_value(virStrcpyStatic((*dst)[i].field, src[i].field));
(*dst)[i].type = src[i].type;
if (src[i].type == VIR_TYPED_PARAM_STRING) {
- if (VIR_STRDUP((*dst)[i].value.s, src[i].value.s) < 0) {
- virTypedParamsFree(*dst, i - 1);
- *dst = NULL;
- return -1;
- }
+ (*dst)[i].value.s = g_strdup(src[i].value.s);
} else {
(*dst)[i].value = src[i].value;
}
remote_param->value.remote_typed_param_value.b;
break;
case VIR_TYPED_PARAM_STRING:
- if (VIR_STRDUP(param->value.s,
- remote_param->value.remote_typed_param_value.s) < 0)
- goto cleanup;
+ param->value.s = g_strdup(remote_param->value.remote_typed_param_value.s);
break;
default:
virReportError(VIR_ERR_RPC, _("unknown parameter type: %d"),
/* This will be either freed by virNetServerDispatchCall or call(),
* depending on the calling side, i.e. server or client */
- if (VIR_STRDUP(val->field, param->field) < 0)
- goto cleanup;
+ val->field = g_strdup(param->field);
val->value.type = param->type;
switch (param->type) {
case VIR_TYPED_PARAM_INT:
val->value.remote_typed_param_value.b = param->value.b;
break;
case VIR_TYPED_PARAM_STRING:
- if (VIR_STRDUP(val->value.remote_typed_param_value.s, param->value.s) < 0)
- goto cleanup;
+ val->value.remote_typed_param_value.s = g_strdup(param->value.s);
break;
default:
virReportError(VIR_ERR_RPC, _("unknown parameter type: %d"),
char *pname = NULL;
char *pvalue = NULL;
- if (VIR_STRDUP(pname, name) < 0 || VIR_STRDUP(pvalue, value) < 0)
- goto error;
+ pname = g_strdup(name);
+ pvalue = g_strdup(value);
if (VIR_RESIZE_N(uri->params, uri->paramsAlloc, uri->paramsCount, 1) < 0)
goto error;
if (VIR_ALLOC(ret) < 0)
goto error;
- if (VIR_STRDUP(ret->scheme, xmluri->scheme) < 0)
- goto error;
- if (VIR_STRDUP(ret->server, xmluri->server) < 0)
- goto error;
+ ret->scheme = g_strdup(xmluri->scheme);
+ ret->server = g_strdup(xmluri->server);
/* xmluri->port value is not defined if server was
* not given. Modern versions libxml2 fill port
* differently to old versions in this case, so
ret->port = 0;
else
ret->port = xmluri->port;
- if (VIR_STRDUP(ret->path, xmluri->path) < 0)
- goto error;
- if (VIR_STRDUP(ret->query, xmluri->query_raw) < 0)
- goto error;
- if (VIR_STRDUP(ret->fragment, xmluri->fragment) < 0)
- goto error;
- if (VIR_STRDUP(ret->user, xmluri->user) < 0)
- goto error;
+ ret->path = g_strdup(xmluri->path);
+ ret->query = g_strdup(xmluri->query_raw);
+ ret->fragment = g_strdup(xmluri->fragment);
+ ret->user = g_strdup(xmluri->user);
/* Strip square bracket from an IPv6 address.
* The function modifies the string in-place. Even after such
{
VIR_FREE(dev->used_by_drvname);
VIR_FREE(dev->used_by_domname);
- if (VIR_STRDUP(dev->used_by_drvname, drv_name) < 0)
- return -1;
- if (VIR_STRDUP(dev->used_by_domname, dom_name) < 0)
- return -1;
+ dev->used_by_drvname = g_strdup(drv_name);
+ dev->used_by_domname = g_strdup(dom_name);
return 0;
}
goto cleanup;
}
- if (name && VIR_STRDUP(*name, pw->pw_name) < 0)
- goto cleanup;
+ if (name)
+ *name = g_strdup(pw->pw_name);
if (group)
*group = pw->pw_gid;
- if (dir && VIR_STRDUP(*dir, pw->pw_dir) < 0)
- goto cleanup;
- if (shell && VIR_STRDUP(*shell, pw->pw_shell) < 0)
- goto cleanup;
+ if (dir)
+ *dir = g_strdup(pw->pw_dir);
+ if (shell)
+ *shell = g_strdup(pw->pw_shell);
ret = 0;
cleanup:
*path = NULL;
if (SHGetSpecialFolderLocation(NULL, csidl, &pidl) == S_OK) {
- if (SHGetPathFromIDList(pidl, buf) && VIR_STRDUP(*path, buf) < 0)
- ret = -1;
+ if (SHGetPathFromIDList(pidl, buf))
+ *path = g_strdup(buf);
CoTaskMemFree(pidl);
}
return ret;
strcpy(windowsdir, "C:\\");
}
- return VIR_STRDUP(*path, windowsdir) < 0 ? -1 : 0;
+ *path = g_strdup(windowsdir);
+ return 0;
}
/* USERPROFILE is probably the closest equivalent to $HOME? */
dir = getenv("USERPROFILE");
- if (VIR_STRDUP(ret, dir) < 0)
- return NULL;
+ ret = g_strdup(dir);
if (!ret &&
virGetWin32SpecialFolder(CSIDL_PROFILE, &ret) < 0)
char *owner = NULL;
char *group = NULL;
- if (VIR_STRDUP(tmp_label, label) < 0)
- goto cleanup;
+ tmp_label = g_strdup(label);
/* Split label */
sep = strchr(tmp_label, ':');
if (VIR_ALLOC(validator) < 0)
return NULL;
- if (VIR_STRDUP(validator->schemafile, schemafile) < 0)
- goto error;
+ validator->schemafile = g_strdup(schemafile);
if (!(validator->rngParser =
xmlRelaxNGNewParserCtxt(validator->schemafile))) {