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:
parent
b10402ece1
commit
fa3d8a609a
@ -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);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -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;
|
||||
|
@ -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;
|
||||
}
|
||||
|
@ -67,7 +67,7 @@ VIR_LOG_INIT("esx.esx_vi_types");
|
||||
\
|
||||
_body \
|
||||
\
|
||||
VIR_FREE(*ptrptr); \
|
||||
g_clear_pointer(ptrptr, g_free); \
|
||||
}
|
||||
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user