[libvirt] [PATCH v4 2/4] qemu_process.c: use g_autoptr()

Cole Robinson crobinso at redhat.com
Fri Dec 20 18:47:17 UTC 2019


On 12/19/19 4:09 PM, Daniel Henrique Barboza wrote:
> Change all feasible pointers to use g_autoptr().
> 
> Signed-off-by: Daniel Henrique Barboza <danielhb413 at gmail.com>
> ---
>  src/qemu/qemu_process.c | 113 +++++++++++++---------------------------
>  1 file changed, 37 insertions(+), 76 deletions(-)


> @@ -6718,7 +6684,7 @@ qemuProcessLaunch(virConnectPtr conn,
>      qemuDomainObjPrivatePtr priv = vm->privateData;
>      virCommandPtr cmd = NULL;
>      struct qemuProcessHookData hookData;
> -    virQEMUDriverConfigPtr cfg;
> +    g_autoptr(virQEMUDriverConfig) cfg = NULL;
>      size_t nnicindexes = 0;
>      g_autofree int *nicindexes = NULL;
>      size_t i;
> @@ -7026,7 +6992,6 @@ qemuProcessLaunch(virConnectPtr conn,
>      qemuDomainSecretDestroy(vm);
>      virCommandFree(cmd);

virCommand supports autoptr too

>      virObjectUnref(logCtxt);

Could add a prep patch in qemu_domain.h with:

G_DEFINE_AUTOPTR_CLEANUP_FUNC(qemuDomainLogContext, virObjectUnref);

Then use it here too

- Cole




More information about the libvir-list mailing list