summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorThomas Haller <thaller@redhat.com>2019-12-20 14:46:58 +0100
committerThomas Haller <thaller@redhat.com>2019-12-20 14:46:58 +0100
commitd65aabd5180b9d668610a9deb230d1baecb71a52 (patch)
treeb773d2088b7fdcbcec67562ec59ada6f3788f8f2
parentc4a728217d3794627268303475531df5be35a27b (diff)
downloadNetworkManager-d65aabd5180b9d668610a9deb230d1baecb71a52.tar.gz
libnm: use designated initalizers for NMSriovVF and VFVlan
-rw-r--r--libnm-core/nm-setting-sriov.c28
1 files changed, 16 insertions, 12 deletions
diff --git a/libnm-core/nm-setting-sriov.c b/libnm-core/nm-setting-sriov.c
index 8c0db37cc9..9ef68cce61 100644
--- a/libnm-core/nm-setting-sriov.c
+++ b/libnm-core/nm-setting-sriov.c
@@ -99,13 +99,15 @@ nm_sriov_vf_new (guint index)
{
NMSriovVF *vf;
- vf = g_slice_new0 (NMSriovVF);
- vf->refcount = 1;
- vf->index = index;
- vf->attributes = g_hash_table_new_full (nm_str_hash,
- g_str_equal,
- g_free,
- (GDestroyNotify) g_variant_unref);
+ vf = g_slice_new (NMSriovVF);
+ *vf = (NMSriovVF) {
+ .refcount = 1,
+ .index = index,
+ .attributes = g_hash_table_new_full (nm_str_hash,
+ g_str_equal,
+ g_free,
+ (GDestroyNotify) g_variant_unref),
+ };
return vf;
}
@@ -147,7 +149,7 @@ nm_sriov_vf_unref (NMSriovVF *vf)
if (vf->vlans)
g_hash_table_unref (vf->vlans);
g_free (vf->vlan_ids);
- g_slice_free (NMSriovVF, vf);
+ nm_g_slice_free (vf);
}
}
@@ -221,10 +223,12 @@ vf_add_vlan (NMSriovVF *vf,
{
VFVlan *vlan;
- vlan = g_slice_new0 (VFVlan);
- vlan->id = vlan_id;
- vlan->qos = qos;
- vlan->protocol = protocol;
+ vlan = g_slice_new (VFVlan);
+ *vlan = (VFVlan) {
+ .id = vlan_id,
+ .qos = qos,
+ .protocol = protocol,
+ };
if (!vf->vlans)
vf->vlans = _vf_vlan_create_hash ();