device: also use NM_DEVICE_CLASS_DECLARE_TYPES() for types without link-types

NMDeviceOvsPort and NMDeviceOvsInterface don't have an underlying link-type from platform.
Still use NM_DEVICE_CLASS_DECLARE_TYPES() macro, for consistancy reasons.

This requires to extend NM_DEVICE_CLASS_DECLARE_TYPES() macro, to support
a variadic argument list with zero link-types.
This commit is contained in:
Thomas Haller 2018-07-10 08:38:59 +02:00
parent 87a60c4596
commit c9883b85a2
3 changed files with 13 additions and 5 deletions

View file

@ -133,10 +133,16 @@ void nm_device_commit_mtu (NMDevice *self);
#define NM_DEVICE_CLASS_DECLARE_TYPES(klass, conn_type, ...) \
G_STMT_START { \
NM_DEVICE_CLASS (klass)->connection_type_supported = conn_type; \
{ \
static const NMLinkType link_types[] = { __VA_ARGS__, NM_LINK_TYPE_NONE }; \
if (NM_NARG (__VA_ARGS__) > 0) { \
static const struct { \
const NMLinkType types[NM_NARG (__VA_ARGS__)]; \
const NMLinkType sentinel; \
} _link_types = { \
.types = { __VA_ARGS__ }, \
.sentinel = NM_LINK_TYPE_NONE, \
}; \
\
NM_DEVICE_CLASS (klass)->link_types = link_types; \
NM_DEVICE_CLASS (klass)->link_types = _link_types.types; \
} \
} G_STMT_END

View file

@ -150,9 +150,10 @@ nm_device_ovs_bridge_class_init (NMDeviceOvsBridgeClass *klass)
NMDBusObjectClass *dbus_object_class = NM_DBUS_OBJECT_CLASS (klass);
NMDeviceClass *device_class = NM_DEVICE_CLASS (klass);
NM_DEVICE_CLASS_DECLARE_TYPES (klass, NM_SETTING_OVS_BRIDGE_SETTING_NAME);
dbus_object_class->interface_infos = NM_DBUS_INTERFACE_INFOS (&interface_info_device_ovs_bridge);
device_class->connection_type_supported = NM_SETTING_OVS_BRIDGE_SETTING_NAME;
device_class->is_master = TRUE;
device_class->get_type_description = get_type_description;
device_class->create_and_realize = create_and_realize;

View file

@ -196,9 +196,10 @@ nm_device_ovs_port_class_init (NMDeviceOvsPortClass *klass)
NMDBusObjectClass *dbus_object_class = NM_DBUS_OBJECT_CLASS (klass);
NMDeviceClass *device_class = NM_DEVICE_CLASS (klass);
NM_DEVICE_CLASS_DECLARE_TYPES (klass, NM_SETTING_OVS_PORT_SETTING_NAME);
dbus_object_class->interface_infos = NM_DBUS_INTERFACE_INFOS (&interface_info_device_ovs_port);
device_class->connection_type_supported = NM_SETTING_OVS_PORT_SETTING_NAME;
device_class->is_master = TRUE;
device_class->get_type_description = get_type_description;
device_class->create_and_realize = create_and_realize;