openvz_driver: use g_autofree instead of VIR_FREE()

Signed-off-by: Karim Taha <kariem.taha2.7@gmail.com>
Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
This commit is contained in:
Karim Taha 2024-03-17 17:19:20 +02:00 committed by Michal Privoznik
parent c9de7a1c3b
commit 771bfe0c0d

View File

@ -615,7 +615,7 @@ openvzGenerateVethName(int veid, char *dev_name_ve)
static char * static char *
openvzGenerateContainerVethName(int veid) openvzGenerateContainerVethName(int veid)
{ {
char *temp = NULL; g_autofree char *temp = NULL;
char *name = NULL; char *name = NULL;
/* try to get line "^NETIF=..." from config */ /* try to get line "^NETIF=..." from config */
@ -638,8 +638,6 @@ openvzGenerateContainerVethName(int veid)
name = g_strdup_printf("eth%d", max + 1); name = g_strdup_printf("eth%d", max + 1);
} }
VIR_FREE(temp);
return name; return name;
} }
@ -750,7 +748,6 @@ openvzDomainSetNetworkConfig(virConnectPtr conn,
{ {
size_t i; size_t i;
g_auto(virBuffer) buf = VIR_BUFFER_INITIALIZER; g_auto(virBuffer) buf = VIR_BUFFER_INITIALIZER;
char *param;
int first = 1; int first = 1;
struct openvz_driver *driver = conn->privateData; struct openvz_driver *driver = conn->privateData;
@ -771,15 +768,15 @@ openvzDomainSetNetworkConfig(virConnectPtr conn,
} }
if (driver->version < VZCTL_BRIDGE_MIN_VERSION && def->nnets) { if (driver->version < VZCTL_BRIDGE_MIN_VERSION && def->nnets) {
g_autofree char *param = NULL;
param = virBufferContentAndReset(&buf); param = virBufferContentAndReset(&buf);
if (param) { if (param) {
if (openvzWriteVPSConfigParam(strtoI(def->name), "NETIF", param) < 0) { if (openvzWriteVPSConfigParam(strtoI(def->name), "NETIF", param) < 0) {
VIR_FREE(param);
virReportError(VIR_ERR_INTERNAL_ERROR, "%s", virReportError(VIR_ERR_INTERNAL_ERROR, "%s",
_("cannot replace NETIF config")); _("cannot replace NETIF config"));
return -1; return -1;
} }
VIR_FREE(param);
} }
} }
@ -1075,7 +1072,7 @@ openvzDomainGetAutostart(virDomainPtr dom, int *autostart)
{ {
struct openvz_driver *driver = dom->conn->privateData; struct openvz_driver *driver = dom->conn->privateData;
virDomainObj *vm; virDomainObj *vm;
char *value = NULL; g_autofree char *value = NULL;
int ret = -1; int ret = -1;
if (!(vm = openvzDomObjFromDomain(driver, dom->uuid))) if (!(vm = openvzDomObjFromDomain(driver, dom->uuid)))
@ -1093,8 +1090,6 @@ openvzDomainGetAutostart(virDomainPtr dom, int *autostart)
ret = 0; ret = 0;
cleanup: cleanup:
VIR_FREE(value);
virDomainObjEndAPI(&vm); virDomainObjEndAPI(&vm);
return ret; return ret;
} }
@ -1405,7 +1400,7 @@ static int openvzConnectListDefinedDomains(virConnectPtr conn G_GNUC_UNUSED,
static int openvzGetProcessInfo(unsigned long long *cpuTime, int vpsid) static int openvzGetProcessInfo(unsigned long long *cpuTime, int vpsid)
{ {
FILE *fp; FILE *fp;
char *line = NULL; g_autofree char *line = NULL;
size_t line_size = 0; size_t line_size = 0;
unsigned long long usertime, systime, nicetime; unsigned long long usertime, systime, nicetime;
int readvps = vpsid + 1; /* ensure readvps is initially different */ int readvps = vpsid + 1; /* ensure readvps is initially different */
@ -1442,7 +1437,6 @@ Version: 2.2
} }
} }
VIR_FREE(line);
VIR_FORCE_FCLOSE(fp); VIR_FORCE_FCLOSE(fp);
if (err) if (err)
return -1; return -1;