[PATCH 03/33] virDomainDefSetMetadata: Avoid temporary variable for string copy

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

 



Since error checking was removed when switching to g_strdup, it doesn't
make much sense to have 'tmp' around.

Signed-off-by: Peter Krempa <pkrempa@xxxxxxxxxx>
---
 src/conf/domain_conf.c | 15 ++++++---------
 1 file changed, 6 insertions(+), 9 deletions(-)

diff --git a/src/conf/domain_conf.c b/src/conf/domain_conf.c
index b731744f04..6f4487fcfc 100644
--- a/src/conf/domain_conf.c
+++ b/src/conf/domain_conf.c
@@ -30426,7 +30426,6 @@ virDomainDefSetMetadata(virDomainDefPtr def,
     xmlDocPtr doc = NULL;
     xmlNodePtr old;
     xmlNodePtr new = NULL;
-    char *tmp = NULL;
     int ret = -1;

     if (type >= VIR_DOMAIN_METADATA_LAST) {
@@ -30437,19 +30436,17 @@ virDomainDefSetMetadata(virDomainDefPtr def,

     switch ((virDomainMetadataType) type) {
     case VIR_DOMAIN_METADATA_DESCRIPTION:
-        if (STRNEQ_NULLABLE(metadata, ""))
-            tmp = g_strdup(metadata);
+        g_clear_pointer(&def->description, g_free);

-        VIR_FREE(def->description);
-        def->description = tmp;
+        if (STRNEQ_NULLABLE(metadata, ""))
+            def->description = g_strdup(metadata);
         break;

     case VIR_DOMAIN_METADATA_TITLE:
-        if (STRNEQ_NULLABLE(metadata, ""))
-            tmp = g_strdup(metadata);
+        g_clear_pointer(&def->title, g_free);

-        VIR_FREE(def->title);
-        def->title = tmp;
+        if (STRNEQ_NULLABLE(metadata, ""))
+            def->title = g_strdup(metadata);
         break;

     case VIR_DOMAIN_METADATA_ELEMENT:
-- 
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