mirror of
https://gitlab.com/libvirt/libvirt.git
synced 2025-03-20 06:50:22 +03:00
networkcommon_conf: Use g_autofree where possible
Signed-off-by: Kristina Hanicova <khanicov@redhat.com> Reviewed-by: Laine Stump <laine@redhat.com>
This commit is contained in:
parent
5ac6ab2fde
commit
8c23da73b6
@ -228,9 +228,10 @@ virNetDevIPRouteParseXML(const char *errorDetail,
|
||||
|
||||
virNetDevIPRoutePtr def = NULL;
|
||||
VIR_XPATH_NODE_AUTORESTORE(ctxt)
|
||||
char *family = NULL;
|
||||
char *address = NULL, *netmask = NULL;
|
||||
char *gateway = NULL;
|
||||
g_autofree char *family = NULL;
|
||||
g_autofree char *address = NULL;
|
||||
g_autofree char *netmask = NULL;
|
||||
g_autofree char *gateway = NULL;
|
||||
unsigned long prefix = 0, metric = 0;
|
||||
int prefixRc, metricRc;
|
||||
bool hasPrefix = false;
|
||||
@ -276,10 +277,6 @@ virNetDevIPRouteParseXML(const char *errorDetail,
|
||||
hasMetric);
|
||||
|
||||
cleanup:
|
||||
VIR_FREE(family);
|
||||
VIR_FREE(address);
|
||||
VIR_FREE(netmask);
|
||||
VIR_FREE(gateway);
|
||||
return def;
|
||||
}
|
||||
|
||||
@ -287,31 +284,30 @@ int
|
||||
virNetDevIPRouteFormat(virBufferPtr buf,
|
||||
const virNetDevIPRoute *def)
|
||||
{
|
||||
char *addr = NULL;
|
||||
g_autofree char *address = NULL;
|
||||
g_autofree char *netmask = NULL;
|
||||
g_autofree char *gateway = NULL;
|
||||
|
||||
virBufferAddLit(buf, "<route");
|
||||
|
||||
if (def->family)
|
||||
virBufferAsprintf(buf, " family='%s'", def->family);
|
||||
|
||||
if (!(addr = virSocketAddrFormat(&def->address)))
|
||||
if (!(address = virSocketAddrFormat(&def->address)))
|
||||
return -1;
|
||||
virBufferAsprintf(buf, " address='%s'", addr);
|
||||
VIR_FREE(addr);
|
||||
virBufferAsprintf(buf, " address='%s'", address);
|
||||
|
||||
if (VIR_SOCKET_ADDR_VALID(&def->netmask)) {
|
||||
if (!(addr = virSocketAddrFormat(&def->netmask)))
|
||||
if (!(netmask = virSocketAddrFormat(&def->netmask)))
|
||||
return -1;
|
||||
virBufferAsprintf(buf, " netmask='%s'", addr);
|
||||
VIR_FREE(addr);
|
||||
virBufferAsprintf(buf, " netmask='%s'", netmask);
|
||||
}
|
||||
if (def->has_prefix)
|
||||
virBufferAsprintf(buf, " prefix='%u'", def->prefix);
|
||||
|
||||
if (!(addr = virSocketAddrFormat(&def->gateway)))
|
||||
if (!(gateway = virSocketAddrFormat(&def->gateway)))
|
||||
return -1;
|
||||
virBufferAsprintf(buf, " gateway='%s'", addr);
|
||||
VIR_FREE(addr);
|
||||
virBufferAsprintf(buf, " gateway='%s'", gateway);
|
||||
|
||||
if (def->has_metric && def->metric > 0)
|
||||
virBufferAsprintf(buf, " metric='%u'", def->metric);
|
||||
|
Loading…
x
Reference in New Issue
Block a user