1
0
mirror of https://gitlab.com/libvirt/libvirt.git synced 2025-03-20 06:50:22 +03:00

netdev_bandwidth_conf: Refractor virNetDevBandwidthParse()

Refractoring includes:
* removal of VIR_FREE
* inversion of the condition

Signed-off-by: Kristina Hanicova <khanicov@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
Signed-off-by: Ján Tomko <jtomko@redhat.com>
This commit is contained in:
Kristina Hanicova 2021-03-03 11:48:17 +01:00 committed by Ján Tomko
parent a40448c42f
commit bcb63a3bdc
2 changed files with 5 additions and 5 deletions

View File

@ -111,7 +111,7 @@ virNetDevBandwidthParse(virNetDevBandwidthPtr *bandwidth,
bool allowFloor)
{
int ret = -1;
virNetDevBandwidthPtr def = NULL;
g_autoptr(virNetDevBandwidth) def = NULL;
xmlNodePtr cur;
xmlNodePtr in = NULL, out = NULL;
g_autofree char *class_id_prop = NULL;
@ -197,14 +197,12 @@ virNetDevBandwidthParse(virNetDevBandwidthPtr *bandwidth,
}
}
if (!def->in && !def->out)
VIR_FREE(def);
if (def->in || def->out)
*bandwidth = g_steal_pointer(&def);
*bandwidth = g_steal_pointer(&def);
ret = 0;
cleanup:
virNetDevBandwidthFree(def);
return ret;
}

View File

@ -38,6 +38,8 @@ struct _virNetDevBandwidth {
void virNetDevBandwidthFree(virNetDevBandwidthPtr def);
G_DEFINE_AUTOPTR_CLEANUP_FUNC(virNetDevBandwidth, virNetDevBandwidthFree);
int virNetDevBandwidthSet(const char *ifname,
const virNetDevBandwidth *bandwidth,
bool hierarchical_class,