1
0
mirror of https://gitlab.com/libvirt/libvirt.git synced 2025-03-07 17:28:15 +00:00

esx: replace some VIR_FREE with g_clear_pointer(x, g_free)

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>
This commit is contained in:
Laine Stump 2021-02-12 16:39:38 -05:00
parent b10402ece1
commit fa3d8a609a
4 changed files with 8 additions and 8 deletions

View File

@ -914,7 +914,7 @@ esxConnectListAllNetworks(virConnectPtr conn,
if (nets && *nets) { if (nets && *nets) {
for (i = 0; i < count; ++i) for (i = 0; i < count; ++i)
g_free((*nets)[i]); g_free((*nets)[i]);
VIR_FREE(*nets); g_clear_pointer(nets, g_free);
} }
} }

View File

@ -95,7 +95,7 @@ esxUtil_ParseUri(esxUtil_ParsedUri **parsedUri, virURIPtr uri)
/* Expected format: [<type>://]<hostname>[:<port>] */ /* Expected format: [<type>://]<hostname>[:<port>] */
(*parsedUri)->proxy = true; (*parsedUri)->proxy = true;
(*parsedUri)->proxy_type = CURLPROXY_HTTP; (*parsedUri)->proxy_type = CURLPROXY_HTTP;
VIR_FREE((*parsedUri)->proxy_hostname); g_clear_pointer(&(*parsedUri)->proxy_hostname, g_free);
(*parsedUri)->proxy_port = 1080; (*parsedUri)->proxy_port = 1080;
if ((tmp = STRSKIP(queryParam->value, "http://"))) { if ((tmp = STRSKIP(queryParam->value, "http://"))) {
@ -261,13 +261,13 @@ esxUtil_ParseDatastorePath(const char *datastorePath, char **datastoreName,
cleanup: cleanup:
if (result < 0) { if (result < 0) {
if (datastoreName) if (datastoreName)
VIR_FREE(*datastoreName); g_clear_pointer(datastoreName, g_free);
if (directoryName) if (directoryName)
VIR_FREE(*directoryName); g_clear_pointer(directoryName, g_free);
if (directoryAndFileName) if (directoryAndFileName)
VIR_FREE(*directoryAndFileName); g_clear_pointer(directoryAndFileName, g_free);
} }
return result; return result;

View File

@ -73,7 +73,7 @@ VIR_LOG_INIT("esx.esx_vi");
\ \
_body \ _body \
\ \
VIR_FREE(*ptrptr); \ g_clear_pointer(ptrptr, g_free); \
} }
@ -2516,7 +2516,7 @@ esxVI_GetVirtualMachineIdentity(esxVI_ObjectContent *virtualMachine,
failure: failure:
if (name) if (name)
VIR_FREE(*name); g_clear_pointer(name, g_free);
return -1; return -1;
} }

View File

@ -67,7 +67,7 @@ VIR_LOG_INIT("esx.esx_vi_types");
\ \
_body \ _body \
\ \
VIR_FREE(*ptrptr); \ g_clear_pointer(ptrptr, g_free); \
} }