bhyve: remove unneeded labels

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@gmail.com>
Reviewed-by: Erik Skultety <eskultet@redhat.com>
This commit is contained in:
Daniel Henrique Barboza 2020-01-06 18:57:25 -03:00 committed by Erik Skultety
parent 8e1804f9f6
commit fbf3f3d86a
2 changed files with 23 additions and 37 deletions

View File

@ -97,7 +97,7 @@ bhyveAssignDevicePCISlots(virDomainDefPtr def,
if (virDomainPCIAddressReserveAddr(addrs, &lpc_addr, if (virDomainPCIAddressReserveAddr(addrs, &lpc_addr,
VIR_PCI_CONNECT_TYPE_PCI_DEVICE, 0) < 0) { VIR_PCI_CONNECT_TYPE_PCI_DEVICE, 0) < 0) {
goto error; return -1;
} }
for (i = 0; i < def->ncontrollers; i++) { for (i = 0; i < def->ncontrollers; i++) {
@ -113,7 +113,7 @@ bhyveAssignDevicePCISlots(virDomainDefPtr def,
&def->controllers[i]->info, &def->controllers[i]->info,
VIR_PCI_CONNECT_TYPE_PCI_DEVICE, VIR_PCI_CONNECT_TYPE_PCI_DEVICE,
-1) < 0) -1) < 0)
goto error; return -1;
} }
} }
@ -124,7 +124,7 @@ bhyveAssignDevicePCISlots(virDomainDefPtr def,
&def->nets[i]->info, &def->nets[i]->info,
VIR_PCI_CONNECT_TYPE_PCI_DEVICE, VIR_PCI_CONNECT_TYPE_PCI_DEVICE,
-1) < 0) -1) < 0)
goto error; return -1;
} }
for (i = 0; i < def->ndisks; i++) { for (i = 0; i < def->ndisks; i++) {
@ -140,7 +140,7 @@ bhyveAssignDevicePCISlots(virDomainDefPtr def,
if (virDomainPCIAddressReserveNextAddr(addrs, &def->disks[i]->info, if (virDomainPCIAddressReserveNextAddr(addrs, &def->disks[i]->info,
VIR_PCI_CONNECT_TYPE_PCI_DEVICE, VIR_PCI_CONNECT_TYPE_PCI_DEVICE,
-1) < 0) -1) < 0)
goto error; return -1;
} }
for (i = 0; i < def->nvideos; i++) { for (i = 0; i < def->nvideos; i++) {
@ -150,14 +150,11 @@ bhyveAssignDevicePCISlots(virDomainDefPtr def,
&def->videos[i]->info, &def->videos[i]->info,
VIR_PCI_CONNECT_TYPE_PCI_DEVICE, VIR_PCI_CONNECT_TYPE_PCI_DEVICE,
-1) < 0) -1) < 0)
goto error; return -1;
} }
return 0; return 0;
error:
return -1;
} }
int bhyveDomainAssignPCIAddresses(virDomainDefPtr def, int bhyveDomainAssignPCIAddresses(virDomainDefPtr def,

View File

@ -374,7 +374,7 @@ bhyveParsePCISlot(const char *slotdef,
val = g_strdup(curr); val = g_strdup(curr);
if (virStrToLong_ui(val, NULL, 10, &values[i]) < 0) if (virStrToLong_ui(val, NULL, 10, &values[i]) < 0)
goto error; return -1;
VIR_FREE(val); VIR_FREE(val);
@ -404,8 +404,6 @@ bhyveParsePCISlot(const char *slotdef,
} }
return 0; return 0;
error:
return -1;
} }
static int static int
@ -426,7 +424,7 @@ bhyveParsePCIDisk(virDomainDefPtr def,
virDomainDiskDefPtr disk = NULL; virDomainDiskDefPtr disk = NULL;
if (!(disk = virDomainDiskDefNew(NULL))) if (!(disk = virDomainDiskDefNew(NULL)))
goto cleanup; return 0;
disk->bus = bus; disk->bus = bus;
disk->device = device; disk->device = device;
@ -471,7 +469,6 @@ bhyveParsePCIDisk(virDomainDefPtr def,
if (VIR_APPEND_ELEMENT(def->disks, def->ndisks, disk) < 0) if (VIR_APPEND_ELEMENT(def->disks, def->ndisks, disk) < 0)
goto error; goto error;
cleanup:
return 0; return 0;
error: error:
@ -664,17 +661,17 @@ bhyveParseBhyveCommandLine(virDomainDefPtr def,
if (virStrToLong_i(arg, NULL, 10, &vcpus) < 0) { if (virStrToLong_i(arg, NULL, 10, &vcpus) < 0) {
virReportError(VIR_ERR_OPERATION_FAILED, "%s", virReportError(VIR_ERR_OPERATION_FAILED, "%s",
_("Failed to parse number of vCPUs")); _("Failed to parse number of vCPUs"));
goto error; return -1;
} }
if (virDomainDefSetVcpusMax(def, vcpus, xmlopt) < 0) if (virDomainDefSetVcpusMax(def, vcpus, xmlopt) < 0)
goto error; return -1;
if (virDomainDefSetVcpus(def, vcpus) < 0) if (virDomainDefSetVcpus(def, vcpus) < 0)
goto error; return -1;
break; break;
case 'l': case 'l':
CONSUME_ARG(arg); CONSUME_ARG(arg);
if (bhyveParseBhyveLPCArg(def, caps, arg)) if (bhyveParseBhyveLPCArg(def, caps, arg))
goto error; return -1;
break; break;
case 's': case 's':
CONSUME_ARG(arg); CONSUME_ARG(arg);
@ -684,19 +681,19 @@ bhyveParseBhyveCommandLine(virDomainDefPtr def,
&nahcidisks, &nahcidisks,
&nvirtiodisks, &nvirtiodisks,
arg)) arg))
goto error; return -1;
break; break;
case 'm': case 'm':
CONSUME_ARG(arg); CONSUME_ARG(arg);
if (bhyveParseMemsize(arg, &memory)) { if (bhyveParseMemsize(arg, &memory)) {
virReportError(VIR_ERR_OPERATION_FAILED, "%s", virReportError(VIR_ERR_OPERATION_FAILED, "%s",
_("Failed to parse memory")); _("Failed to parse memory"));
goto error; return -1;
} }
if (def->mem.cur_balloon != 0 && def->mem.cur_balloon != memory) { if (def->mem.cur_balloon != 0 && def->mem.cur_balloon != memory) {
virReportError(VIR_ERR_OPERATION_FAILED, "%s", virReportError(VIR_ERR_OPERATION_FAILED, "%s",
_("Failed to parse memory: size mismatch")); _("Failed to parse memory: size mismatch"));
goto error; return -1;
} }
def->mem.cur_balloon = memory; def->mem.cur_balloon = memory;
virDomainDefSetMemoryTotal(def, memory); virDomainDefSetMemoryTotal(def, memory);
@ -714,7 +711,7 @@ bhyveParseBhyveCommandLine(virDomainDefPtr def,
if (virUUIDParse(arg, def->uuid) < 0) { if (virUUIDParse(arg, def->uuid) < 0) {
virReportError(VIR_ERR_INTERNAL_ERROR, virReportError(VIR_ERR_INTERNAL_ERROR,
_("Cannot parse UUID '%s'"), arg); _("Cannot parse UUID '%s'"), arg);
goto error; return -1;
} }
break; break;
case 'S': case 'S':
@ -729,7 +726,7 @@ bhyveParseBhyveCommandLine(virDomainDefPtr def,
if (argc != opti) { if (argc != opti) {
virReportError(VIR_ERR_OPERATION_FAILED, "%s", virReportError(VIR_ERR_OPERATION_FAILED, "%s",
_("Failed to parse arguments for bhyve command")); _("Failed to parse arguments for bhyve command"));
goto error; return -1;
} }
if (def->name == NULL) { if (def->name == NULL) {
@ -739,13 +736,10 @@ bhyveParseBhyveCommandLine(virDomainDefPtr def,
* error here */ * error here */
virReportError(VIR_ERR_OPERATION_FAILED, "%s", virReportError(VIR_ERR_OPERATION_FAILED, "%s",
_("Failed to parse arguments: VM name mismatch")); _("Failed to parse arguments: VM name mismatch"));
goto error; return -1;
} }
return 0; return 0;
error:
return -1;
} }
/* /*
@ -761,7 +755,6 @@ bhyveParseBhyveLoadCommandLine(virDomainDefPtr def,
unsigned arguments = 0; unsigned arguments = 0;
size_t memory = 0; size_t memory = 0;
size_t i = 0; size_t i = 0;
int ret = -1;
size_t opti; size_t opti;
const char *arg; const char *arg;
@ -789,12 +782,12 @@ bhyveParseBhyveLoadCommandLine(virDomainDefPtr def,
if (bhyveParseMemsize(arg, &memory)) { if (bhyveParseMemsize(arg, &memory)) {
virReportError(VIR_ERR_OPERATION_FAILED, "%s", virReportError(VIR_ERR_OPERATION_FAILED, "%s",
_("Failed to parse memory")); _("Failed to parse memory"));
goto error; return -1;
} }
if (def->mem.cur_balloon != 0 && def->mem.cur_balloon != memory) { if (def->mem.cur_balloon != 0 && def->mem.cur_balloon != memory) {
virReportError(VIR_ERR_OPERATION_FAILED, "%s", virReportError(VIR_ERR_OPERATION_FAILED, "%s",
_("Failed to parse memory: size mismatch")); _("Failed to parse memory: size mismatch"));
goto error; return -1;
} }
def->mem.cur_balloon = memory; def->mem.cur_balloon = memory;
virDomainDefSetMemoryTotal(def, memory); virDomainDefSetMemoryTotal(def, memory);
@ -807,7 +800,7 @@ bhyveParseBhyveLoadCommandLine(virDomainDefPtr def,
if (argc != opti) { if (argc != opti) {
virReportError(VIR_ERR_OPERATION_FAILED, "%s", virReportError(VIR_ERR_OPERATION_FAILED, "%s",
_("Failed to parse arguments for bhyve command")); _("Failed to parse arguments for bhyve command"));
goto error; return -1;
} }
if (arguments != 3) { if (arguments != 3) {
@ -824,12 +817,10 @@ bhyveParseBhyveLoadCommandLine(virDomainDefPtr def,
* error here */ * error here */
virReportError(VIR_ERR_OPERATION_FAILED, "%s", virReportError(VIR_ERR_OPERATION_FAILED, "%s",
_("Failed to parse arguments: VM name mismatch")); _("Failed to parse arguments: VM name mismatch"));
goto error; return -1;
} }
ret = 0; return 0;
error:
return ret;
} }
static int static int
@ -838,14 +829,12 @@ bhyveParseCustomLoaderCommandLine(virDomainDefPtr def,
char **argv) char **argv)
{ {
if (!argv) if (!argv)
goto error; return -1;
def->os.bootloader = g_strdup(argv[0]); def->os.bootloader = g_strdup(argv[0]);
def->os.bootloaderArgs = virStringListJoin((const char**) &argv[1], " "); def->os.bootloaderArgs = virStringListJoin((const char**) &argv[1], " ");
return 0; return 0;
error:
return -1;
} }
virDomainDefPtr virDomainDefPtr