Replace all occurrences of
if (VIR_STRDUP(a, b) < 0)
/* effectively dead code */
with:
a = g_strdup(b);
Signed-off-by: Ján Tomko <jtomko(a)redhat.com>
---
src/bhyve/bhyve_command.c | 15 +++++---------
src/bhyve/bhyve_conf.c | 3 +--
src/bhyve/bhyve_driver.c | 3 +--
src/bhyve/bhyve_parse_command.c | 35 +++++++++------------------------
4 files changed, 16 insertions(+), 40 deletions(-)
diff --git a/src/bhyve/bhyve_command.c b/src/bhyve/bhyve_command.c
index 912cf99683..8ea76cee2e 100644
--- a/src/bhyve/bhyve_command.c
+++ b/src/bhyve/bhyve_command.c
@@ -58,12 +58,10 @@ bhyveBuildNetArgStr(virConnectPtr conn,
virDomainNetType actualType = virDomainNetGetActualType(net);
if (net->model == VIR_DOMAIN_NET_MODEL_VIRTIO) {
- if (VIR_STRDUP(nic_model, "virtio-net") < 0)
- return -1;
+ nic_model = g_strdup("virtio-net");
} else if (net->model == VIR_DOMAIN_NET_MODEL_E1000) {
if ((bhyveDriverGetCaps(conn) & BHYVE_CAP_NET_E1000) != 0) {
- if (VIR_STRDUP(nic_model, "e1000") < 0)
- return -1;
+ nic_model = g_strdup("e1000");
} else {
virReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s",
_("NIC model 'e1000' is not supported "
@@ -77,8 +75,7 @@ bhyveBuildNetArgStr(virConnectPtr conn,
}
if (actualType == VIR_DOMAIN_NET_TYPE_BRIDGE) {
- if (VIR_STRDUP(brname, virDomainNetGetActualBridgeName(net)) < 0)
- goto cleanup;
+ brname = g_strdup(virDomainNetGetActualBridgeName(net));
} else {
virReportError(VIR_ERR_CONFIG_UNSUPPORTED,
_("Network type %d is not supported"),
@@ -90,8 +87,7 @@ bhyveBuildNetArgStr(virConnectPtr conn,
STRPREFIX(net->ifname, VIR_NET_GENERATED_TAP_PREFIX) ||
strchr(net->ifname, '%')) {
VIR_FREE(net->ifname);
- if (VIR_STRDUP(net->ifname, VIR_NET_GENERATED_TAP_PREFIX "%d") <
0)
- goto cleanup;
+ net->ifname = g_strdup(VIR_NET_GENERATED_TAP_PREFIX "%d");
}
if (!dryRun) {
@@ -117,8 +113,7 @@ bhyveBuildNetArgStr(virConnectPtr conn,
if (virNetDevSetOnline(net->ifname, true) != 0)
goto cleanup;
} else {
- if (VIR_STRDUP(realifname, "tap0") < 0)
- goto cleanup;
+ realifname = g_strdup("tap0");
}
diff --git a/src/bhyve/bhyve_conf.c b/src/bhyve/bhyve_conf.c
index 617b25eb8f..ab5d7f467b 100644
--- a/src/bhyve/bhyve_conf.c
+++ b/src/bhyve/bhyve_conf.c
@@ -56,8 +56,7 @@ virBhyveDriverConfigNew(void)
if (!(cfg = virObjectNew(virBhyveDriverConfigClass)))
return NULL;
- if (VIR_STRDUP(cfg->firmwareDir, DATADIR "/uefi-firmware") < 0)
- goto error;
+ cfg->firmwareDir = g_strdup(DATADIR "/uefi-firmware");
return cfg;
diff --git a/src/bhyve/bhyve_driver.c b/src/bhyve/bhyve_driver.c
index db3d71f2b2..e3d984f69a 100644
--- a/src/bhyve/bhyve_driver.c
+++ b/src/bhyve/bhyve_driver.c
@@ -470,8 +470,7 @@ bhyveDomainGetOSType(virDomainPtr dom)
if (virDomainGetOSTypeEnsureACL(dom->conn, vm->def) < 0)
goto cleanup;
- if (VIR_STRDUP(ret, virDomainOSTypeToString(vm->def->os.type)) < 0)
- goto cleanup;
+ ret = g_strdup(virDomainOSTypeToString(vm->def->os.type));
cleanup:
virDomainObjEndAPI(&vm);
diff --git a/src/bhyve/bhyve_parse_command.c b/src/bhyve/bhyve_parse_command.c
index 7c72651b00..fa3b881f21 100644
--- a/src/bhyve/bhyve_parse_command.c
+++ b/src/bhyve/bhyve_parse_command.c
@@ -299,16 +299,8 @@ bhyveParseBhyveLPCArg(virDomainDefPtr def,
goto error;
}
- if (VIR_STRDUP(chr->source->data.nmdm.master, param) < 0) {
- virDomainChrDefFree(chr);
- goto error;
- }
-
- if (VIR_STRDUP(chr->source->data.nmdm.slave,
chr->source->data.file.path)
- < 0) {
- virDomainChrDefFree(chr);
- goto error;
- }
+ chr->source->data.nmdm.master = g_strdup(param);
+ chr->source->data.nmdm.slave =
g_strdup(chr->source->data.file.path);
/* If the last character of the master is 'A', the slave will be
'B'
* and vice versa */
@@ -456,13 +448,11 @@ bhyveParsePCIDisk(virDomainDefPtr def,
if (bus == VIR_DOMAIN_DISK_BUS_VIRTIO) {
idx = *nvirtiodisk;
*nvirtiodisk += 1;
- if (VIR_STRDUP(disk->dst, "vda") < 0)
- goto error;
+ disk->dst = g_strdup("vda");
} else if (bus == VIR_DOMAIN_DISK_BUS_SATA) {
idx = *nahcidisk;
*nahcidisk += 1;
- if (VIR_STRDUP(disk->dst, "sda") < 0)
- goto error;
+ disk->dst = g_strdup("sda");
}
if (idx > 'z' - 'a') {
@@ -507,8 +497,7 @@ bhyveParsePCINet(virDomainDefPtr def,
* guess the actual bridge name from the command line,
* try to come up with some reasonable defaults */
net->type = VIR_DOMAIN_NET_TYPE_BRIDGE;
- if (VIR_STRDUP(net->data.bridge.brname, "virbr0") < 0)
- goto error;
+ net->data.bridge.brname = g_strdup("virbr0");
net->model = model;
net->info.type = VIR_DOMAIN_DEVICE_ADDRESS_TYPE_PCI;
@@ -738,8 +727,7 @@ bhyveParseBhyveCommandLine(virDomainDefPtr def,
}
if (def->name == NULL) {
- if (VIR_STRDUP(def->name, argv[argc]) < 0)
- goto error;
+ def->name = g_strdup(argv[argc]);
} else if (STRNEQ(def->name, argv[argc])) {
/* the vm name of the loader and the bhyverun command differ, throw an
* error here */
@@ -819,15 +807,12 @@ bhyveParseBhyveLoadCommandLine(virDomainDefPtr def,
if (arguments != 3) {
/* Set os.bootloader since virDomainDefFormatInternal will only format
* the bootloader arguments if os->bootloader is set. */
- if (VIR_STRDUP(def->os.bootloader, argv[0]) < 0)
- goto error;
-
+ def->os.bootloader = g_strdup(argv[0]);
def->os.bootloaderArgs = virStringListJoin((const char**) &argv[1], "
");
}
if (def->name == NULL) {
- if (VIR_STRDUP(def->name, argv[argc]) < 0)
- goto error;
+ def->name = g_strdup(argv[argc]);
} else if (STRNEQ(def->name, argv[argc])) {
/* the vm name of the loader and the bhyverun command differ, throw an
* error here */
@@ -849,9 +834,7 @@ bhyveParseCustomLoaderCommandLine(virDomainDefPtr def,
if (!argv)
goto error;
- if (VIR_STRDUP(def->os.bootloader, argv[0]) < 0)
- goto error;
-
+ def->os.bootloader = g_strdup(argv[0]);
def->os.bootloaderArgs = virStringListJoin((const char**) &argv[1], "
");
return 0;
--
2.21.0