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>
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;
}
}
- 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;
}
void virNetDevBandwidthFree(virNetDevBandwidthPtr def);
+G_DEFINE_AUTOPTR_CLEANUP_FUNC(virNetDevBandwidth, virNetDevBandwidthFree);
+
int virNetDevBandwidthSet(const char *ifname,
const virNetDevBandwidth *bandwidth,
bool hierarchical_class,