]> git.ipfire.org Git - thirdparty/libvirt.git/commitdiff
esx: replace some VIR_FREE with g_clear_pointer(x, g_free)
authorLaine Stump <laine@redhat.com>
Fri, 12 Feb 2021 21:39:38 +0000 (16:39 -0500)
committerLaine Stump <laine@redhat.com>
Tue, 16 Feb 2021 18:50:05 +0000 (13:50 -0500)
These are all cases when 1) the pointer is passed by reference from
the caller (ie.e. **) and expects it to be NULL on return if there is
an error, or 2) the variable holding the pointer is being checked or
re-used in the same function, but not right away.

Signed-off-by: Laine Stump <laine@redhat.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
src/esx/esx_network_driver.c
src/esx/esx_util.c
src/esx/esx_vi.c
src/esx/esx_vi_types.c

index b489f4de8a97a6bd628f4dcfd79c6fde40743d4f..4d0fba8c9f553770d47079e0cfdb54b3bd525f1a 100644 (file)
@@ -914,7 +914,7 @@ esxConnectListAllNetworks(virConnectPtr conn,
         if (nets && *nets) {
             for (i = 0; i < count; ++i)
                 g_free((*nets)[i]);
-            VIR_FREE(*nets);
+            g_clear_pointer(nets, g_free);
         }
     }
 
index ef070a4f0457295bf069dea5710e73359bb41953..24e1c73ec411535004c3432ea45c067384481363 100644 (file)
@@ -95,7 +95,7 @@ esxUtil_ParseUri(esxUtil_ParsedUri **parsedUri, virURIPtr uri)
             /* Expected format: [<type>://]<hostname>[:<port>] */
             (*parsedUri)->proxy = true;
             (*parsedUri)->proxy_type = CURLPROXY_HTTP;
-            VIR_FREE((*parsedUri)->proxy_hostname);
+            g_clear_pointer(&(*parsedUri)->proxy_hostname, g_free);
             (*parsedUri)->proxy_port = 1080;
 
             if ((tmp = STRSKIP(queryParam->value, "http://"))) {
@@ -261,13 +261,13 @@ esxUtil_ParseDatastorePath(const char *datastorePath, char **datastoreName,
  cleanup:
     if (result < 0) {
         if (datastoreName)
-            VIR_FREE(*datastoreName);
+            g_clear_pointer(datastoreName, g_free);
 
         if (directoryName)
-            VIR_FREE(*directoryName);
+            g_clear_pointer(directoryName, g_free);
 
         if (directoryAndFileName)
-            VIR_FREE(*directoryAndFileName);
+            g_clear_pointer(directoryAndFileName, g_free);
     }
 
     return result;
index db5035c035d6f6cc606ab878b1c73dedc3624dc9..e1c1a15ab66cdc07a3c09ba4545bb767a8ca5562 100644 (file)
@@ -73,7 +73,7 @@ VIR_LOG_INIT("esx.esx_vi");
  \
         _body \
  \
-        VIR_FREE(*ptrptr); \
+        g_clear_pointer(ptrptr, g_free); \
     }
 
 
@@ -2516,7 +2516,7 @@ esxVI_GetVirtualMachineIdentity(esxVI_ObjectContent *virtualMachine,
 
  failure:
     if (name)
-        VIR_FREE(*name);
+        g_clear_pointer(name, g_free);
 
     return -1;
 }
index 4dc7c30680ffc68f9a8fc2bb386ec7d117160dc4..59735194ae3a0d101ac5351824dcdc9df493f865 100644 (file)
@@ -67,7 +67,7 @@ VIR_LOG_INIT("esx.esx_vi_types");
  \
         _body \
  \
-        VIR_FREE(*ptrptr); \
+        g_clear_pointer(ptrptr, g_free); \
     }