Rework to remove unnecessary label and goto.
Signed-off-by: Tim Wiederhake <twiederh(a)redhat.com>
---
tests/domaincapstest.c | 18 +++++-------------
1 file changed, 5 insertions(+), 13 deletions(-)
diff --git a/tests/domaincapstest.c b/tests/domaincapstest.c
index 9ea5bed5c2..4a46acb9ad 100644
--- a/tests/domaincapstest.c
+++ b/tests/domaincapstest.c
@@ -135,25 +135,17 @@ fillQemuCaps(virDomainCaps *domCaps,
static int
fillXenCaps(virDomainCaps *domCaps)
{
- virFirmware **firmwares;
- int ret = -1;
-
- firmwares = g_new0(virFirmware *, 2);
-
- firmwares[0] = g_new0(virFirmware, 1);
- firmwares[1] = g_new0(virFirmware, 1);
+ g_autoptr(virFirmware) fw_hvmloader = g_new0(virFirmware, 1);
+ g_autoptr(virFirmware) fw_ovmf = g_new0(virFirmware, 1);
+ virFirmware *firmwares[] = { fw_hvmloader, fw_ovmf };
firmwares[0]->name = g_strdup("/usr/lib/xen/boot/hvmloader");
firmwares[1]->name = g_strdup("/usr/lib/xen/boot/ovmf.bin");
if (libxlMakeDomainCapabilities(domCaps, firmwares, 2) < 0)
- goto cleanup;
-
- ret = 0;
+ return -1;
- cleanup:
- virFirmwareFreeList(firmwares, 2);
- return ret;
+ return 0;
}
#endif /* WITH_LIBXL */
--
2.31.1