]> git.ipfire.org Git - thirdparty/libvirt.git/commitdiff
virNetDevVPortProfileParse: Use g_autofree
authorMichal Privoznik <mprivozn@redhat.com>
Thu, 4 Nov 2021 12:38:02 +0000 (13:38 +0100)
committerMichal Privoznik <mprivozn@redhat.com>
Fri, 12 Nov 2021 16:16:44 +0000 (17:16 +0100)
Explicit calls to VIR_FREE() can be dropped then.

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
Reviewed-by: Kristína Hanicová <khanicov@redhat.com>
src/conf/netdev_vport_profile_conf.c

index d98ce098dfa26d8bb524deb1c0053b95cfdf9e47..dfffc4dd7027143bc4bfc7ee0094d8e6200bd8a1 100644 (file)
 virNetDevVPortProfile *
 virNetDevVPortProfileParse(xmlNodePtr node, unsigned int flags)
 {
-    char *virtPortType;
-    char *virtPortManagerID = NULL;
-    char *virtPortTypeID = NULL;
-    char *virtPortTypeIDVersion = NULL;
-    char *virtPortInstanceID = NULL;
-    char *virtPortProfileID = NULL;
-    char *virtPortInterfaceID = NULL;
-    virNetDevVPortProfile *virtPort = NULL;
+    g_autofree char *virtPortType = NULL;
+    g_autofree char *virtPortManagerID = NULL;
+    g_autofree char *virtPortTypeID = NULL;
+    g_autofree char *virtPortTypeIDVersion = NULL;
+    g_autofree char *virtPortInstanceID = NULL;
+    g_autofree char *virtPortProfileID = NULL;
+    g_autofree char *virtPortInterfaceID = NULL;
+    g_autofree virNetDevVPortProfile *virtPort = NULL;
     xmlNodePtr cur = node->children;
 
     virtPort = g_new0(virNetDevVPortProfile, 1);
@@ -178,20 +178,10 @@ virNetDevVPortProfileParse(xmlNodePtr node, unsigned int flags)
     if (virNetDevVPortProfileCheckNoExtras(virtPort) < 0)
         goto error;
 
- cleanup:
-    VIR_FREE(virtPortManagerID);
-    VIR_FREE(virtPortTypeID);
-    VIR_FREE(virtPortTypeIDVersion);
-    VIR_FREE(virtPortInstanceID);
-    VIR_FREE(virtPortProfileID);
-    VIR_FREE(virtPortType);
-    VIR_FREE(virtPortInterfaceID);
-
-    return virtPort;
+    return g_steal_pointer(&virtPort);
 
  error:
-    VIR_FREE(virtPort);
-    goto cleanup;
+    return NULL;
 }