]> git.ipfire.org Git - thirdparty/libvirt.git/commitdiff
virt-aa-helper: Decrease scope of @mem_path in get_files()
authorMichal Privoznik <mprivozn@redhat.com>
Wed, 11 Jun 2025 11:52:46 +0000 (13:52 +0200)
committerMichal Privoznik <mprivozn@redhat.com>
Wed, 2 Jul 2025 11:54:23 +0000 (13:54 +0200)
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 <mprivozn@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
src/security/virt-aa-helper.c

index 2fac65f108496a638a006950b56e3b82bd3cd64f..64cada3b3b9a49db0f38acd6534f1ebcfa42e401 100644 (file)
@@ -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;
 }