Labels that are simply a jump to a 'return' call are
unneeded and can be replaced by the return value instead.
Signed-off-by: Daniel Henrique Barboza <danielhb413(a)gmail.com>
---
src/bhyve/bhyve_device.c | 13 ++++-----
src/bhyve/bhyve_parse_command.c | 47 +++++++++++++--------------------
2 files changed, 23 insertions(+), 37 deletions(-)
diff --git a/src/bhyve/bhyve_device.c b/src/bhyve/bhyve_device.c
index ddbe20d31d..13261e9935 100644
--- a/src/bhyve/bhyve_device.c
+++ b/src/bhyve/bhyve_device.c
@@ -97,7 +97,7 @@ bhyveAssignDevicePCISlots(virDomainDefPtr def,
if (virDomainPCIAddressReserveAddr(addrs, &lpc_addr,
VIR_PCI_CONNECT_TYPE_PCI_DEVICE, 0) < 0) {
- goto error;
+ return -1;
}
for (i = 0; i < def->ncontrollers; i++) {
@@ -113,7 +113,7 @@ bhyveAssignDevicePCISlots(virDomainDefPtr def,
&def->controllers[i]->info,
VIR_PCI_CONNECT_TYPE_PCI_DEVICE,
-1) < 0)
- goto error;
+ return -1;
}
}
@@ -124,7 +124,7 @@ bhyveAssignDevicePCISlots(virDomainDefPtr def,
&def->nets[i]->info,
VIR_PCI_CONNECT_TYPE_PCI_DEVICE,
-1) < 0)
- goto error;
+ return -1;
}
for (i = 0; i < def->ndisks; i++) {
@@ -140,7 +140,7 @@ bhyveAssignDevicePCISlots(virDomainDefPtr def,
if (virDomainPCIAddressReserveNextAddr(addrs, &def->disks[i]->info,
VIR_PCI_CONNECT_TYPE_PCI_DEVICE,
-1) < 0)
- goto error;
+ return -1;
}
for (i = 0; i < def->nvideos; i++) {
@@ -150,14 +150,11 @@ bhyveAssignDevicePCISlots(virDomainDefPtr def,
&def->videos[i]->info,
VIR_PCI_CONNECT_TYPE_PCI_DEVICE,
-1) < 0)
- goto error;
+ return -1;
}
return 0;
-
- error:
- return -1;
}
int bhyveDomainAssignPCIAddresses(virDomainDefPtr def,
diff --git a/src/bhyve/bhyve_parse_command.c b/src/bhyve/bhyve_parse_command.c
index e74c4c2d0c..f7cedf5c65 100644
--- a/src/bhyve/bhyve_parse_command.c
+++ b/src/bhyve/bhyve_parse_command.c
@@ -374,7 +374,7 @@ bhyveParsePCISlot(const char *slotdef,
val = g_strdup(curr);
if (virStrToLong_ui(val, NULL, 10, &values[i]) < 0)
- goto error;
+ return -1;
VIR_FREE(val);
@@ -404,8 +404,6 @@ bhyveParsePCISlot(const char *slotdef,
}
return 0;
- error:
- return -1;
}
static int
@@ -426,7 +424,7 @@ bhyveParsePCIDisk(virDomainDefPtr def,
virDomainDiskDefPtr disk = NULL;
if (!(disk = virDomainDiskDefNew(NULL)))
- goto cleanup;
+ return 0;
disk->bus = bus;
disk->device = device;
@@ -471,7 +469,6 @@ bhyveParsePCIDisk(virDomainDefPtr def,
if (VIR_APPEND_ELEMENT(def->disks, def->ndisks, disk) < 0)
goto error;
- cleanup:
return 0;
error:
@@ -664,17 +661,17 @@ bhyveParseBhyveCommandLine(virDomainDefPtr def,
if (virStrToLong_i(arg, NULL, 10, &vcpus) < 0) {
virReportError(VIR_ERR_OPERATION_FAILED, "%s",
_("Failed to parse number of vCPUs"));
- goto error;
+ return -1;
}
if (virDomainDefSetVcpusMax(def, vcpus, xmlopt) < 0)
- goto error;
+ return -1;
if (virDomainDefSetVcpus(def, vcpus) < 0)
- goto error;
+ return -1;
break;
case 'l':
CONSUME_ARG(arg);
if (bhyveParseBhyveLPCArg(def, caps, arg))
- goto error;
+ return -1;
break;
case 's':
CONSUME_ARG(arg);
@@ -684,19 +681,19 @@ bhyveParseBhyveCommandLine(virDomainDefPtr def,
&nahcidisks,
&nvirtiodisks,
arg))
- goto error;
+ return -1;
break;
case 'm':
CONSUME_ARG(arg);
if (bhyveParseMemsize(arg, &memory)) {
virReportError(VIR_ERR_OPERATION_FAILED, "%s",
_("Failed to parse memory"));
- goto error;
+ return -1;
}
if (def->mem.cur_balloon != 0 && def->mem.cur_balloon !=
memory) {
virReportError(VIR_ERR_OPERATION_FAILED, "%s",
_("Failed to parse memory: size mismatch"));
- goto error;
+ return -1;
}
def->mem.cur_balloon = memory;
virDomainDefSetMemoryTotal(def, memory);
@@ -714,7 +711,7 @@ bhyveParseBhyveCommandLine(virDomainDefPtr def,
if (virUUIDParse(arg, def->uuid) < 0) {
virReportError(VIR_ERR_INTERNAL_ERROR,
_("Cannot parse UUID '%s'"), arg);
- goto error;
+ return -1;
}
break;
case 'S':
@@ -729,7 +726,7 @@ bhyveParseBhyveCommandLine(virDomainDefPtr def,
if (argc != opti) {
virReportError(VIR_ERR_OPERATION_FAILED, "%s",
_("Failed to parse arguments for bhyve command"));
- goto error;
+ return -1;
}
if (def->name == NULL) {
@@ -739,13 +736,10 @@ bhyveParseBhyveCommandLine(virDomainDefPtr def,
* error here */
virReportError(VIR_ERR_OPERATION_FAILED, "%s",
_("Failed to parse arguments: VM name mismatch"));
- goto error;
+ return -1;
}
return 0;
-
- error:
- return -1;
}
/*
@@ -761,7 +755,6 @@ bhyveParseBhyveLoadCommandLine(virDomainDefPtr def,
unsigned arguments = 0;
size_t memory = 0;
size_t i = 0;
- int ret = -1;
size_t opti;
const char *arg;
@@ -789,12 +782,12 @@ bhyveParseBhyveLoadCommandLine(virDomainDefPtr def,
if (bhyveParseMemsize(arg, &memory)) {
virReportError(VIR_ERR_OPERATION_FAILED, "%s",
_("Failed to parse memory"));
- goto error;
+ return -1;
}
if (def->mem.cur_balloon != 0 && def->mem.cur_balloon !=
memory) {
virReportError(VIR_ERR_OPERATION_FAILED, "%s",
_("Failed to parse memory: size mismatch"));
- goto error;
+ return -1;
}
def->mem.cur_balloon = memory;
virDomainDefSetMemoryTotal(def, memory);
@@ -807,7 +800,7 @@ bhyveParseBhyveLoadCommandLine(virDomainDefPtr def,
if (argc != opti) {
virReportError(VIR_ERR_OPERATION_FAILED, "%s",
_("Failed to parse arguments for bhyve command"));
- goto error;
+ return -1;
}
if (arguments != 3) {
@@ -824,12 +817,10 @@ bhyveParseBhyveLoadCommandLine(virDomainDefPtr def,
* error here */
virReportError(VIR_ERR_OPERATION_FAILED, "%s",
_("Failed to parse arguments: VM name mismatch"));
- goto error;
+ return -1;
}
- ret = 0;
- error:
- return ret;
+ return 0;
}
static int
@@ -838,14 +829,12 @@ bhyveParseCustomLoaderCommandLine(virDomainDefPtr def,
char **argv)
{
if (!argv)
- goto error;
+ return -1;
def->os.bootloader = g_strdup(argv[0]);
def->os.bootloaderArgs = virStringListJoin((const char**) &argv[1], "
");
return 0;
- error:
- return -1;
}
virDomainDefPtr
--
2.24.1