mirror of
https://gitlab.com/libvirt/libvirt.git
synced 2024-12-23 06:05:27 +00:00
Use g_autoptr instead of virNetDevIPRouteFree if possible
In files: src/conf/domain_conf: in virDomainNetIPInfoParseXML(), src/lxc/lxc_native: in lxcAddNetworkRouteDefinition(), src/vz/vz_sdk: in prlsdkGetRoutes(), src/conf/networkcommon_conf: in virNetDevIPRouteCreate() Signed-off-by: Kristina Hanicova <khanicov@redhat.com> Reviewed-by: Laine Stump <laine@redhat.com>
This commit is contained in:
parent
8c23da73b6
commit
5fa51adcf2
@ -7481,7 +7481,7 @@ virDomainNetIPInfoParseXML(const char *source,
|
|||||||
xmlXPathContextPtr ctxt,
|
xmlXPathContextPtr ctxt,
|
||||||
virNetDevIPInfoPtr def)
|
virNetDevIPInfoPtr def)
|
||||||
{
|
{
|
||||||
virNetDevIPRoutePtr route = NULL;
|
g_autoptr(virNetDevIPRoute) route = NULL;
|
||||||
int nnodes;
|
int nnodes;
|
||||||
int ret = -1;
|
int ret = -1;
|
||||||
size_t i;
|
size_t i;
|
||||||
@ -7511,7 +7511,6 @@ virDomainNetIPInfoParseXML(const char *source,
|
|||||||
cleanup:
|
cleanup:
|
||||||
if (ret < 0)
|
if (ret < 0)
|
||||||
virNetDevIPInfoClear(def);
|
virNetDevIPInfoClear(def);
|
||||||
virNetDevIPRouteFree(route);
|
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -41,7 +41,7 @@ virNetDevIPRouteCreate(const char *errorDetail,
|
|||||||
unsigned int metric,
|
unsigned int metric,
|
||||||
bool hasMetric)
|
bool hasMetric)
|
||||||
{
|
{
|
||||||
virNetDevIPRoutePtr def = NULL;
|
g_autoptr(virNetDevIPRoute) def = NULL;
|
||||||
virSocketAddr testAddr;
|
virSocketAddr testAddr;
|
||||||
|
|
||||||
def = g_new0(virNetDevIPRoute, 1);
|
def = g_new0(virNetDevIPRoute, 1);
|
||||||
@ -209,10 +209,9 @@ virNetDevIPRouteCreate(const char *errorDetail,
|
|||||||
goto error;
|
goto error;
|
||||||
}
|
}
|
||||||
|
|
||||||
return def;
|
return g_steal_pointer(&def);
|
||||||
|
|
||||||
error:
|
error:
|
||||||
virNetDevIPRouteFree(def);
|
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -441,7 +441,7 @@ lxcAddNetworkRouteDefinition(const char *address,
|
|||||||
virNetDevIPRoutePtr **routes,
|
virNetDevIPRoutePtr **routes,
|
||||||
size_t *nroutes)
|
size_t *nroutes)
|
||||||
{
|
{
|
||||||
virNetDevIPRoutePtr route = NULL;
|
g_autoptr(virNetDevIPRoute) route = NULL;
|
||||||
g_autofree char *familyStr = NULL;
|
g_autofree char *familyStr = NULL;
|
||||||
g_autofree char *zero = NULL;
|
g_autofree char *zero = NULL;
|
||||||
|
|
||||||
@ -460,7 +460,6 @@ lxcAddNetworkRouteDefinition(const char *address,
|
|||||||
return 0;
|
return 0;
|
||||||
|
|
||||||
error:
|
error:
|
||||||
virNetDevIPRouteFree(route);
|
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -974,7 +974,7 @@ prlsdkGetRoutes(PRL_HANDLE sdknet, virDomainNetDefPtr net)
|
|||||||
int ret = -1;
|
int ret = -1;
|
||||||
char *gw = NULL;
|
char *gw = NULL;
|
||||||
char *gw6 = NULL;
|
char *gw6 = NULL;
|
||||||
virNetDevIPRoutePtr route = NULL;
|
g_autoptr(virNetDevIPRoute) route = NULL;
|
||||||
|
|
||||||
if (!(gw = prlsdkGetStringParamVar(PrlVmDevNet_GetDefaultGateway, sdknet)))
|
if (!(gw = prlsdkGetStringParamVar(PrlVmDevNet_GetDefaultGateway, sdknet)))
|
||||||
goto cleanup;
|
goto cleanup;
|
||||||
@ -1006,7 +1006,6 @@ prlsdkGetRoutes(PRL_HANDLE sdknet, virDomainNetDefPtr net)
|
|||||||
ret = 0;
|
ret = 0;
|
||||||
|
|
||||||
cleanup:
|
cleanup:
|
||||||
virNetDevIPRouteFree(route);
|
|
||||||
VIR_FREE(gw);
|
VIR_FREE(gw);
|
||||||
VIR_FREE(gw6);
|
VIR_FREE(gw6);
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user