virConnectOpenInternal: Switch to automatic memory cleanup

Use automatic cleanup for 'ret' and 'uristr'.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
This commit is contained in:
Peter Krempa 2022-09-08 16:36:28 +02:00
parent 48e1b49353
commit 000bb404e5

View File

@ -882,9 +882,9 @@ virConnectOpenInternal(const char *name,
{ {
size_t i; size_t i;
int res; int res;
virConnectPtr ret; g_autoptr(virConnect) ret = NULL;
g_autoptr(virConf) conf = NULL; g_autoptr(virConf) conf = NULL;
char *uristr = NULL; g_autofree char *uristr = NULL;
bool embed = false; bool embed = false;
ret = virGetConnect(); ret = virGetConnect();
@ -1151,14 +1151,9 @@ virConnectOpenInternal(const char *name,
goto failed; goto failed;
} }
VIR_FREE(uristr); return g_steal_pointer(&ret);
return ret;
failed: failed:
VIR_FREE(uristr);
virObjectUnref(ret);
return NULL; return NULL;
} }