[PATCH 3/7] qemuBlockNodeNameGetBackingChain: Shuffle around variable initialization

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Allocate the hash tables first so tat the 'data' struct can be directly
initialized removing the need for a memset and two additional
assignments.

Signed-off-by: Peter Krempa <pkrempa@xxxxxxxxxx>
---
 src/qemu/qemu_block.c | 8 ++------
 1 file changed, 2 insertions(+), 6 deletions(-)

diff --git a/src/qemu/qemu_block.c b/src/qemu/qemu_block.c
index 8150241015..1bcf7fa4f1 100644
--- a/src/qemu/qemu_block.c
+++ b/src/qemu/qemu_block.c
@@ -230,20 +230,16 @@ GHashTable *
 qemuBlockNodeNameGetBackingChain(virJSONValue *namednodes,
                                  virJSONValue *blockstats)
 {
-    struct qemuBlockNodeNameGetBackingChainData data;
     g_autoptr(GHashTable) namednodestable = virHashNew(virJSONValueHashFree);
     g_autoptr(GHashTable) disks = virHashNew(qemuBlockNodeNameBackingChainDataHashEntryFree);
-
-    memset(&data, 0, sizeof(data));
+    struct qemuBlockNodeNameGetBackingChainData data = { .nodenamestable = namednodestable,
+                                                         .disks = disks };

     if (virJSONValueArrayForeachSteal(namednodes,
                                       qemuBlockNamedNodesArrayToHash,
                                       namednodestable) < 0)
         return NULL;

-    data.nodenamestable = namednodestable;
-    data.disks = disks;
-
     if (virJSONValueArrayForeachSteal(blockstats,
                                       qemuBlockNodeNameGetBackingChainDisk,
                                       &data) < 0)
-- 
2.31.1




[Index of Archives]     [Virt Tools]     [Libvirt Users]     [Lib OS Info]     [Fedora Users]     [Fedora Desktop]     [Fedora SELinux]     [Big List of Linux Books]     [Yosemite News]     [KDE Users]     [Fedora Tools]

  Powered by Linux