platform: avoid duplicated code in _nmp_object_stackinit_from_type()

This commit is contained in:
Thomas Haller 2022-03-29 17:18:44 +02:00
parent 31299473cd
commit 3bd5d2bca9
No known key found for this signature in database
GPG key ID: 29C2366E4DFC5728

View file

@ -799,7 +799,7 @@ nmp_object_new_link(int ifindex)
/*****************************************************************************/
static void
static NMPObject *
_nmp_object_stackinit_from_class(NMPObject *obj, const NMPClass *klass)
{
nm_assert(obj);
@ -812,25 +812,13 @@ _nmp_object_stackinit_from_class(NMPObject *obj, const NMPClass *klass)
._ref_count = NM_OBJ_REF_COUNT_STACKINIT,
},
};
return obj;
}
static NMPObject *
_nmp_object_stackinit_from_type(NMPObject *obj, NMPObjectType obj_type)
{
const NMPClass *klass;
nm_assert(obj);
klass = nmp_class_from_type(obj_type);
nm_assert(klass);
*obj = (NMPObject){
.parent =
{
.klass = (const NMDedupMultiObjClass *) klass,
._ref_count = NM_OBJ_REF_COUNT_STACKINIT,
},
};
return obj;
return _nmp_object_stackinit_from_class(obj, nmp_class_from_type(obj_type));
}
const NMPObject *