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@xxxxxxxxxx> --- src/esx/esx_network_driver.c | 2 +- src/esx/esx_util.c | 8 ++++---- src/esx/esx_vi.c | 4 ++-- src/esx/esx_vi_types.c | 2 +- 4 files changed, 8 insertions(+), 8 deletions(-) diff --git a/src/esx/esx_network_driver.c b/src/esx/esx_network_driver.c index b489f4de8a..4d0fba8c9f 100644 --- a/src/esx/esx_network_driver.c +++ b/src/esx/esx_network_driver.c @@ -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); } } diff --git a/src/esx/esx_util.c b/src/esx/esx_util.c index ef070a4f04..24e1c73ec4 100644 --- a/src/esx/esx_util.c +++ b/src/esx/esx_util.c @@ -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; diff --git a/src/esx/esx_vi.c b/src/esx/esx_vi.c index db5035c035..e1c1a15ab6 100644 --- a/src/esx/esx_vi.c +++ b/src/esx/esx_vi.c @@ -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; } diff --git a/src/esx/esx_vi_types.c b/src/esx/esx_vi_types.c index 4dc7c30680..59735194ae 100644 --- a/src/esx/esx_vi_types.c +++ b/src/esx/esx_vi_types.c @@ -67,7 +67,7 @@ VIR_LOG_INIT("esx.esx_vi_types"); \ _body \ \ - VIR_FREE(*ptrptr); \ + g_clear_pointer(ptrptr, g_free); \ } -- 2.29.2