Signed-off-by: Ján Tomko <jtomko(a)redhat.com>
---
src/ch/ch_monitor.c | 15 +++++----------
1 file changed, 5 insertions(+), 10 deletions(-)
diff --git a/src/ch/ch_monitor.c b/src/ch/ch_monitor.c
index 3504c21f9d..804704e66d 100644
--- a/src/ch/ch_monitor.c
+++ b/src/ch/ch_monitor.c
@@ -445,9 +445,8 @@ chMonitorCreateSocket(const char *socket_path)
virCHMonitor *
virCHMonitorNew(virDomainObj *vm, const char *socketdir)
{
- virCHMonitor *ret = NULL;
virCHMonitor *mon = NULL;
- virCommand *cmd = NULL;
+ g_autoptr(virCommand) cmd = NULL;
int socket_fd = 0;
if (virCHMonitorInitialize() < 0)
@@ -468,7 +467,7 @@ virCHMonitorNew(virDomainObj *vm, const char *socketdir)
virReportSystemError(errno,
_("Cannot create socket directory '%s'"),
socketdir);
- goto cleanup;
+ return NULL;
}
cmd = virCommandNew(vm->def->emulator);
@@ -478,7 +477,7 @@ virCHMonitorNew(virDomainObj *vm, const char *socketdir)
virReportSystemError(errno,
_("Cannot create socket '%s'"),
mon->socketpath);
- goto cleanup;
+ return NULL;
}
virCommandAddArg(cmd, "--api-socket");
@@ -487,7 +486,7 @@ virCHMonitorNew(virDomainObj *vm, const char *socketdir)
/* launch Cloud-Hypervisor socket */
if (virCommandRunAsync(cmd, &mon->pid) < 0)
- goto cleanup;
+ return NULL;
/* get a curl handle */
mon->handle = curl_easy_init();
@@ -496,11 +495,7 @@ virCHMonitorNew(virDomainObj *vm, const char *socketdir)
virObjectRef(mon);
mon->vm = virObjectRef(vm);
- ret = mon;
-
- cleanup:
- virCommandFree(cmd);
- return ret;
+ return mon;
}
static void virCHMonitorDispose(void *opaque)
--
2.31.1