Re: [libvirt PATCH 3/9] ch: use g_auto in virCHMonitorBuildMemoryJson

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

 



On 9/22/21 4:55 PM, Ján Tomko wrote:
Signed-off-by: Ján Tomko <jtomko@xxxxxxxxxx>
---
  src/ch/ch_monitor.c | 10 +++-------
  1 file changed, 3 insertions(+), 7 deletions(-)

diff --git a/src/ch/ch_monitor.c b/src/ch/ch_monitor.c
index d241d30b10..9c562fdd0f 100644
--- a/src/ch/ch_monitor.c
+++ b/src/ch/ch_monitor.c
@@ -149,22 +149,18 @@ virCHMonitorBuildKernelRelatedJson(virJSONValue *content, virDomainDef *vmdef)
  static int
  virCHMonitorBuildMemoryJson(virJSONValue *content, virDomainDef *vmdef)
  {
-    virJSONValue *memory;
+    g_autoptr(virJSONValue) memory = NULL;
      unsigned long long total_memory = virDomainDefGetMemoryInitial(vmdef) * 1024;
if (total_memory != 0) {
          memory = virJSONValueNewObject();

You could have moved this initialization into the definition line for memory to eliminate one more line (that is your goal, right? :-)

          if (virJSONValueObjectAppendNumberUlong(memory, "size", total_memory) < 0)
-            goto cleanup;
+            return -1;
          if (virJSONValueObjectAppend(content, "memory", &memory) < 0)
-            goto cleanup;
+            return -1;
      }
return 0;
-
- cleanup:
-    virJSONValueFree(memory);
-    return -1;
  }
static int





[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