From: Michal Privoznik Date: Wed, 11 Jun 2025 11:52:46 +0000 (+0200) Subject: virt-aa-helper: Decrease scope of @mem_path in get_files() X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=2f7e11aaa38d850dd1934d9b0492e35af4047ed7;p=thirdparty%2Flibvirt.git virt-aa-helper: Decrease scope of @mem_path in get_files() The @mem_path variable inside of get_files() is used only within a single block. Move its declaration inside it. And also utilize automatic memory freeing. Signed-off-by: Michal Privoznik Reviewed-by: Ján Tomko --- diff --git a/src/security/virt-aa-helper.c b/src/security/virt-aa-helper.c index 2fac65f108..64cada3b3b 100644 --- a/src/security/virt-aa-helper.c +++ b/src/security/virt-aa-helper.c @@ -866,7 +866,6 @@ get_files(vahControl * ctl) int rc = -1; size_t i; char *uuid; - char *mem_path = NULL; char uuidstr[VIR_UUID_STRING_BUFLEN]; bool needsVfio = false, needsvhost = false, needsgl = false; @@ -1210,6 +1209,8 @@ get_files(vahControl * ctl) "rw") != 0) goto cleanup; } else { + g_autofree char *mem_path = NULL; + switch (shmem->model) { case VIR_DOMAIN_SHMEM_MODEL_IVSHMEM_PLAIN: /* until exposed, recreate qemuBuildShmemBackendMemProps */ @@ -1361,7 +1362,6 @@ get_files(vahControl * ctl) ctl->files = virBufferContentAndReset(&buf); cleanup: - VIR_FREE(mem_path); VIR_FREE(uuid); return rc; }