libnm: use designated initalizers for NMSriovVF and VFVlan

(cherry picked from commit d65aabd518)
This commit is contained in:
Thomas Haller 2019-12-20 14:46:58 +01:00
parent 49376697c6
commit cb49f35bd1

View file

@ -99,13 +99,15 @@ nm_sriov_vf_new (guint index)
{ {
NMSriovVF *vf; NMSriovVF *vf;
vf = g_slice_new0 (NMSriovVF); vf = g_slice_new (NMSriovVF);
vf->refcount = 1; *vf = (NMSriovVF) {
vf->index = index; .refcount = 1,
vf->attributes = g_hash_table_new_full (nm_str_hash, .index = index,
g_str_equal, .attributes = g_hash_table_new_full (nm_str_hash,
g_free, g_str_equal,
(GDestroyNotify) g_variant_unref); g_free,
(GDestroyNotify) g_variant_unref),
};
return vf; return vf;
} }
@ -147,7 +149,7 @@ nm_sriov_vf_unref (NMSriovVF *vf)
if (vf->vlans) if (vf->vlans)
g_hash_table_unref (vf->vlans); g_hash_table_unref (vf->vlans);
g_free (vf->vlan_ids); 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; VFVlan *vlan;
vlan = g_slice_new0 (VFVlan); vlan = g_slice_new (VFVlan);
vlan->id = vlan_id; *vlan = (VFVlan) {
vlan->qos = qos; .id = vlan_id,
vlan->protocol = protocol; .qos = qos,
.protocol = protocol,
};
if (!vf->vlans) if (!vf->vlans)
vf->vlans = _vf_vlan_create_hash (); vf->vlans = _vf_vlan_create_hash ();