[PATCH 18/25] virMACMapHashDumper: Refactor array addition

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

 



Use automatic memory freeing and don't check return value of
virJSONValueNewString as it can't fail.

Signed-off-by: Peter Krempa <pkrempa@xxxxxxxxxx>
---
 src/util/virmacmap.c | 8 +++-----
 1 file changed, 3 insertions(+), 5 deletions(-)

diff --git a/src/util/virmacmap.c b/src/util/virmacmap.c
index 521ab89b5b..12df325933 100644
--- a/src/util/virmacmap.c
+++ b/src/util/virmacmap.c
@@ -214,13 +214,11 @@ virMACMapHashDumper(void *payload,
     GSList *next;

     for (next = macs; next; next = next->next) {
-        virJSONValuePtr m = virJSONValueNewString((const char *) next->data);
+        g_autoptr(virJSONValue) m = virJSONValueNewString((const char *) next->data);

-        if (!m ||
-            virJSONValueArrayAppend(arr, m) < 0) {
-            virJSONValueFree(m);
+        if (virJSONValueArrayAppend(arr, m) < 0)
             return -1;
-        }
+        m = NULL;
     }

     if (virJSONValueObjectAppendString(obj, "domain", name) < 0 ||
-- 
2.29.2




[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