switch (def->type) {
case VIR_DOMAIN_TPM_TYPE_PASSTHROUGH:
path = virXPathString("string(./backend/device/@path)", ctxt);
- if (!path && VIR_STRDUP(path, VIR_DOMAIN_TPM_DEFAULT_DEVICE) < 0)
- goto error;
+ if (!path)
+ path = g_strdup(VIR_DOMAIN_TPM_DEFAULT_DEVICE);
def->data.passthrough.source.data.file.path = g_steal_pointer(&path);
def->data.passthrough.source.type = VIR_DOMAIN_CHR_TYPE_DEV;
break;
if ((n = virXPathNodeSet("./target/features/*", ctxt, &nodes)) < 0)
return NULL;
- if (!def->target.compat && VIR_STRDUP(def->target.compat, "1.1") < 0)
- return NULL;
+ if (!def->target.compat)
+ def->target.compat = g_strdup("1.1");
if (!(def->target.features = virBitmapNew(VIR_STORAGE_FILE_FEATURE_LAST)))
return NULL;
if (VIR_STRDUP((*parsedUri)->path, uri->path) < 0)
goto cleanup;
- if (!(*parsedUri)->transport &&
- VIR_STRDUP((*parsedUri)->transport, "https") < 0)
- goto cleanup;
+ if (!(*parsedUri)->transport)
+ (*parsedUri)->transport = g_strdup("https");
result = 0;
(*anyType)->value =
(char *)xmlNodeListGetString(node->doc, node->children, 1);
- if (!(*anyType)->value && VIR_STRDUP((*anyType)->value, "") < 0)
- goto failure;
+ if (!(*anyType)->value)
+ (*anyType)->value = g_strdup("");
#define _DESERIALIZE_NUMBER(_type, _xsdType, _name, _min, _max) \
do { \
}
}
- if (!(*parsedUri)->transport &&
- VIR_STRDUP((*parsedUri)->transport, "https") < 0)
- goto cleanup;
+ if (!(*parsedUri)->transport)
+ (*parsedUri)->transport = g_strdup("https");
result = 0;
} while (def->parent == NULL && parent_device != NULL);
- if (!def->parent && VIR_STRDUP(def->parent, "computer") < 0)
- goto cleanup;
+ if (!def->parent)
+ def->parent = g_strdup("computer");
ret = 0;
if (virXPathBoolean("boolean(./package)", ctxt) > 0) {
qemuCaps->package = virXPathString("string(./package)", ctxt);
- if (!qemuCaps->package &&
- VIR_STRDUP(qemuCaps->package, "") < 0)
- goto cleanup;
+ if (!qemuCaps->package)
+ qemuCaps->package = g_strdup("");
}
if (virXPathBoolean("boolean(./kernelVersion)", ctxt) > 0) {
mount_options = qemuSecurityGetMountOptions(mgr, vm->def);
- if (!mount_options &&
- VIR_STRDUP(mount_options, "") < 0)
- goto cleanup;
+ if (!mount_options)
+ mount_options = g_strdup("");
/*
* tmpfs is limited to 64kb, since we only have device nodes in there
}
/* ifname: check if it's set in newdev. If not, retain the autogenerated one */
- if (!newdev->ifname && VIR_STRDUP(newdev->ifname, olddev->ifname) < 0)
- goto cleanup;
+ if (!newdev->ifname)
+ newdev->ifname = g_strdup(olddev->ifname);
if (STRNEQ_NULLABLE(olddev->ifname, newdev->ifname)) {
virReportError(VIR_ERR_OPERATION_UNSUPPORTED, "%s",
_("cannot modify network device tap name"));
goto cleanup;
}
/* grab alias from olddev if not set in newdev */
- if (!newdev->info.alias &&
- VIR_STRDUP(newdev->info.alias, olddev->info.alias) < 0)
- goto cleanup;
+ if (!newdev->info.alias)
+ newdev->info.alias = g_strdup(olddev->info.alias);
/* device alias is checked already in virDomainDefCompatibleDevice */
goto cleanup;
}
- if (!newdev->info.romfile &&
- VIR_STRDUP(newdev->info.romfile, olddev->info.romfile) < 0)
- goto cleanup;
+ if (!newdev->info.romfile)
+ newdev->info.romfile = g_strdup(olddev->info.romfile);
if (STRNEQ_NULLABLE(olddev->info.romfile, newdev->info.romfile)) {
virReportError(VIR_ERR_OPERATION_UNSUPPORTED, "%s",
_("cannot modify network rom file"));
break;
case REMOTE_DRIVER_TRANSPORT_SSH:
- if (!command && VIR_STRDUP(command, "ssh") < 0)
- goto failed;
+ if (!command)
+ command = g_strdup("ssh");
if (!(priv->client = virNetClientNewSSH(priv->hostname,
port,
if (VIR_STRDUP(secdef->imagelabel, profile_name) < 0)
goto err;
- if (!secdef->model && VIR_STRDUP(secdef->model, SECURITY_APPARMOR_NAME) < 0)
- goto err;
+ if (!secdef->model)
+ secdef->model = g_strdup(SECURITY_APPARMOR_NAME);
/* Now that we have a label, load the profile into the kernel. */
if (load_profile(mgr, secdef->label, def, NULL, false) < 0) {
if (!seclabel->imagelabel)
goto cleanup;
- if (!seclabel->model &&
- VIR_STRDUP(seclabel->model, SECURITY_SELINUX_NAME) < 0)
- goto cleanup;
+ if (!seclabel->model)
+ seclabel->model = g_strdup(SECURITY_SELINUX_NAME);
rc = 0;
return NULL;
}
- if (!opts && VIR_STRDUP(opts, "") < 0)
- return NULL;
+ if (!opts)
+ opts = g_strdup("");
VIR_DEBUG("imageLabel=%s opts=%s",
secdef ? secdef->imagelabel : "(null)", opts);
vol->target.backingStore->type = VIR_STORAGE_TYPE_BLOCK;
}
- if (!vol->key && VIR_STRDUP(vol->key, groups[2]) < 0)
- goto cleanup;
+ if (!vol->key)
+ vol->key = g_strdup(groups[2]);
if (virStorageBackendUpdateVolInfo(vol, false,
VIR_STORAGE_VOL_OPEN_DEFAULT, 0) < 0)
goto cleanup;
}
- if (!volume->key && VIR_STRDUP(volume->key, tokens[0]) < 0)
- goto cleanup;
+ if (!volume->key)
+ volume->key = g_strdup(tokens[0]);
if (volume->target.path == NULL) {
if (virAsprintf(&volume->target.path, "%s/%s",
return -1;
}
- if (!volDef->key && VIR_STRDUP(volDef->key, volDef->target.path) < 0)
- return -1;
+ if (!volDef->key)
+ volDef->key = g_strdup(volDef->target.path);
if (virStoragePoolObjAddVol(obj, volDef) < 0)
return -1;
* comparison.
*/
ignore_value(virFileResolveLink(p1, &res1));
- if (!res1 && VIR_STRDUP(res1, p1) < 0)
- return -1;
+ if (!res1)
+ res1 = g_strdup(p1);
ignore_value(virFileResolveLink(p2, &res2));
- if (!res2 && VIR_STRDUP(res2, p2) < 0)
- return -1;
+ if (!res2)
+ res2 = g_strdup(p2);
return STREQ_NULLABLE(res1, res2);
}
/* This is an ipv6 lease */
if ((server_duid_tmp
= virJSONValueObjectGetString(lease_tmp, "server-duid"))) {
- if (!*server_duid && VIR_STRDUP(*server_duid, server_duid_tmp) < 0) {
- /* Control reaches here when the 'action' is not for an
- * ipv6 lease or, for some weird reason the env var
- * DNSMASQ_SERVER_DUID wasn't set*/
- return -1;
- }
+ if (!*server_duid)
+ *server_duid = g_strdup(server_duid_tmp);
} else {
/* Inject server-duid into those ipv6 leases which
* didn't have it previously, for example, those
* needed because some NIC drivers (e.g. i40e)
* implement phys_port_id for PFs, but not for VFs
*/
- if (!firstEntryName &&
- VIR_STRDUP(firstEntryName, entry->d_name) < 0) {
- goto cleanup;
- }
+ if (!firstEntryName)
+ firstEntryName = g_strdup(entry->d_name);
continue;
}
param->value.s = va_arg(ap, char *);
}
- if (!param->value.s && VIR_STRDUP(param->value.s, "") < 0)
- return -1;
+ if (!param->value.s)
+ param->value.s = g_strdup("");
break;
default:
virReportError(VIR_ERR_INTERNAL_ERROR,
true) < 0)
goto cleanup;
- if (!networkName && VIR_STRDUP(networkName, "") < 0)
- goto cleanup;
+ if (!networkName)
+ networkName = g_strdup("");
}
/* vmx:vnet -> def:data.ifname */
goto cleanup;
}
- if (!domCaps->machine &&
- VIR_STRDUP(domCaps->machine,
- virQEMUCapsGetPreferredMachine(qemuCaps)) < 0)
- goto cleanup;
+ if (!domCaps->machine)
+ domCaps->machine = g_strdup(virQEMUCapsGetPreferredMachine(qemuCaps));
if (virQEMUCapsFillDomainCaps(caps, domCaps, qemuCaps,
false,