]> git.ipfire.org Git - thirdparty/libvirt.git/commitdiff
virSecretDefParseUsage: Use g_autofree for type_str
authorPeter Krempa <pkrempa@redhat.com>
Wed, 6 Jan 2021 14:51:26 +0000 (15:51 +0100)
committerPeter Krempa <pkrempa@redhat.com>
Fri, 8 Jan 2021 08:18:21 +0000 (09:18 +0100)
Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
src/conf/secret_conf.c

index 273987bdb4857ab6b98f0bd93b31da5790ea03f5..9cacc43e28f1ecd55c57ec9c751058864750bde4 100644 (file)
@@ -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: