[PATCH 1/7] virSecretDefParseUsage: Use g_autofree for type_str

Peter Krempa pkrempa at redhat.com
Wed Jan 6 16:57:55 UTC 2021


Signed-off-by: Peter Krempa <pkrempa at redhat.com>
---
 src/conf/secret_conf.c | 4 +---
 1 file changed, 1 insertion(+), 3 deletions(-)

diff --git a/src/conf/secret_conf.c b/src/conf/secret_conf.c
index 273987bdb4..9cacc43e28 100644
--- a/src/conf/secret_conf.c
+++ b/src/conf/secret_conf.c
@@ -52,7 +52,7 @@ static int
 virSecretDefParseUsage(xmlXPathContextPtr ctxt,
                        virSecretDefPtr def)
 {
-    char *type_str;
+    g_autofree char *type_str = NULL;
     int type;

     type_str = virXPathString("string(./usage/@type)", ctxt);
@@ -65,10 +65,8 @@ virSecretDefParseUsage(xmlXPathContextPtr ctxt,
     if (type < 0) {
         virReportError(VIR_ERR_CONFIG_UNSUPPORTED,
                        _("unknown secret usage type %s"), type_str);
-        VIR_FREE(type_str);
         return -1;
     }
-    VIR_FREE(type_str);
     def->usage_type = type;
     switch (def->usage_type) {
     case VIR_SECRET_USAGE_TYPE_NONE:
-- 
2.29.2




More information about the libvir-list mailing list