summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorKristina Hanicova <khanicov@redhat.com>2021-03-03 11:48:17 +0100
committerJán Tomko <jtomko@redhat.com>2021-03-04 17:30:04 +0100
commitbcb63a3bdcc7b22376ce60b7833958cf6cddf702 (patch)
tree7bbf4e648946fd8a759522b5148d4669dbc943d1
parenta40448c42f18337453cc235f2102ce94a1cb6aea (diff)
downloadlibvirt-bcb63a3bdcc7b22376ce60b7833958cf6cddf702.tar.gz
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>
-rw-r--r--src/conf/netdev_bandwidth_conf.c8
-rw-r--r--src/util/virnetdevbandwidth.h2
2 files changed, 5 insertions, 5 deletions
diff --git a/src/conf/netdev_bandwidth_conf.c b/src/conf/netdev_bandwidth_conf.c
index 53cb6978bc..81590efe6d 100644
--- a/src/conf/netdev_bandwidth_conf.c
+++ b/src/conf/netdev_bandwidth_conf.c
@@ -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;
}
diff --git a/src/util/virnetdevbandwidth.h b/src/util/virnetdevbandwidth.h
index 871d0c962c..fff83222a9 100644
--- a/src/util/virnetdevbandwidth.h
+++ b/src/util/virnetdevbandwidth.h
@@ -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,