From: Ján Tomko Date: Fri, 10 Dec 2021 17:29:18 +0000 (+0100) Subject: bhyve: use g_auto in virBhyveProcessStartImpl X-Git-Tag: v8.0.0-rc1~238 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=d604666d7784baeee021be93d394fdfdb25eee8b;p=thirdparty%2Flibvirt.git bhyve: use g_auto in virBhyveProcessStartImpl Use g_auto and VIR_AUTOCLOSE where possible. Signed-off-by: Ján Tomko Reviewed-by: Michal Privoznik --- diff --git a/src/bhyve/bhyve_process.c b/src/bhyve/bhyve_process.c index 8de5fe4838..ead6b0e522 100644 --- a/src/bhyve/bhyve_process.c +++ b/src/bhyve/bhyve_process.c @@ -116,12 +116,12 @@ virBhyveProcessStartImpl(struct _bhyveConn *driver, virDomainObj *vm, virDomainRunningReason reason) { - char *devmap_file = NULL; - char *devicemap = NULL; - char *logfile = NULL; - int logfd = -1; - virCommand *cmd = NULL; - virCommand *load_cmd = NULL; + g_autofree char *devmap_file = NULL; + g_autofree char *devicemap = NULL; + g_autofree char *logfile = NULL; + VIR_AUTOCLOSE logfd = -1; + g_autoptr(virCommand) cmd = NULL; + g_autoptr(virCommand) load_cmd = NULL; bhyveDomainObjPrivate *priv = vm->privateData; int ret = -1, rc; @@ -227,28 +227,21 @@ virBhyveProcessStartImpl(struct _bhyveConn *driver, if (rc < 0 && errno != ENOENT) virReportSystemError(errno, _("cannot unlink file '%s'"), devmap_file); - VIR_FREE(devicemap); } - VIR_FREE(devmap_file); if (ret < 0) { int exitstatus; /* Needed to avoid logging non-zero status */ - virCommand *destroy_cmd; + g_autoptr(virCommand) destroy_cmd = NULL; if ((destroy_cmd = virBhyveProcessBuildDestroyCmd(driver, vm->def)) != NULL) { virCommandSetOutputFD(load_cmd, &logfd); virCommandSetErrorFD(load_cmd, &logfd); ignore_value(virCommandRun(destroy_cmd, &exitstatus)); - virCommandFree(destroy_cmd); } bhyveNetCleanup(vm); } - virCommandFree(load_cmd); - virCommandFree(cmd); - VIR_FREE(logfile); - VIR_FORCE_CLOSE(logfd); return ret; }