diff options
author | Thomas Haller <thaller@redhat.com> | 2017-09-12 16:22:29 +0200 |
---|---|---|
committer | Thomas Haller <thaller@redhat.com> | 2017-09-12 16:34:17 +0200 |
commit | a8d2a4ebaf7e91a91fa046ff7927d45eca9c9801 (patch) | |
tree | 7175ef3ad5181d34773cfe06311b115cfeedb5c7 | |
parent | 4c8673d978fa6c2d84f547afaa935a98b0b0c09a (diff) | |
download | NetworkManager-a8d2a4ebaf7e91a91fa046ff7927d45eca9c9801.tar.gz |
cli: implement dcb priority as plain int property
There are basically three options:
1) use a separate _get_fcn_gobject_dcb_priority() getter and
implement them as a new type _pt_gobject_dcb_priority.
2a) implement them as _pt_gobject_int and set nicks as value_infos,
repeating the nicks 3 times.
2b) like 2a, but use a macro to define how the DCB priority shall
behave at one place.
I think 1) is ugly. In the previous form, it also does not support
setting the property to "unset". We should implement properties as
types, and modify their behavior (by setting value_infos), instead
of implementing multiple, different types.
I slightly prefer 2b) over 2a) because it defines the behavior once,
but it's a bit harder to follow.
-rw-r--r-- | clients/common/nm-meta-setting-desc.c | 36 |
1 files changed, 14 insertions, 22 deletions
diff --git a/clients/common/nm-meta-setting-desc.c b/clients/common/nm-meta-setting-desc.c index a3e59be309..3535ac98c4 100644 --- a/clients/common/nm-meta-setting-desc.c +++ b/clients/common/nm-meta-setting-desc.c @@ -648,20 +648,6 @@ _get_fcn_gobject_int (ARGS_GET_FCN) } static gconstpointer -_get_fcn_gobject_dcb_priority (ARGS_GET_FCN) -{ - static const NMMetaUtilsIntValueInfo value_infos[] = { - { - .value = -1, - .nick = "unset", - }, - { 0 }, - }; - - return _get_fcn_gobject_int_impl (property_info, setting, get_type, value_infos, out_to_free); -} - -static gconstpointer _get_fcn_gobject_mtu (ARGS_GET_FCN) { guint32 mtu; @@ -4408,11 +4394,6 @@ static const NMMetaPropertyType _pt_gobject_mtu = { .set_fcn = _set_fcn_gobject_mtu, }; -static const NMMetaPropertyType _pt_gobject_dcb_priority = { - .get_fcn = _get_fcn_gobject_dcb_priority, - .set_fcn = _set_fcn_gobject_int, -}; - static const NMMetaPropertyType _pt_gobject_mac = { .get_fcn = _get_fcn_gobject, .set_fcn = _set_fcn_gobject_mac, @@ -4479,6 +4460,17 @@ static const NMMetaPropertyType _pt_gobject_devices = { "{ \"device\": \"team0\", \"runner\": {\"name\": \"roundrobin\"}, \"ports\": {\"eth1\": {}, \"eth2\": {}} }\n" \ " set team.config /etc/my-team.conf\n") +#define DEFINE_DCB_PROPRITY_PROPERTY_TYPE \ + .property_type = &_pt_gobject_int, \ + .property_typ_data = DEFINE_PROPERTY_TYP_DATA_SUBTYPE (gobject_int, \ + .value_infos = INT_VALUE_INFOS ( \ + { \ + .value = -1, \ + .nick = "unset", \ + } \ + ), \ + ), + #define _CURRENT_NM_META_SETTING_TYPE NM_META_SETTING_TYPE_802_1X static const NMMetaPropertyInfo *const property_infos_802_1X[] = { PROPERTY_INFO_WITH_DESC (NM_SETTING_802_1X_EAP, @@ -5104,7 +5096,7 @@ static const NMMetaPropertyInfo *const property_infos_DCB[] = { ), ), PROPERTY_INFO_WITH_DESC (NM_SETTING_DCB_APP_FCOE_PRIORITY, - .property_type = &_pt_gobject_dcb_priority, + DEFINE_DCB_PROPRITY_PROPERTY_TYPE ), PROPERTY_INFO_WITH_DESC (NM_SETTING_DCB_APP_FCOE_MODE, .property_type = &_pt_gobject_string, @@ -5120,7 +5112,7 @@ static const NMMetaPropertyInfo *const property_infos_DCB[] = { ), ), PROPERTY_INFO_WITH_DESC (NM_SETTING_DCB_APP_ISCSI_PRIORITY, - .property_type = &_pt_gobject_dcb_priority, + DEFINE_DCB_PROPRITY_PROPERTY_TYPE ), PROPERTY_INFO_WITH_DESC (NM_SETTING_DCB_APP_FIP_FLAGS, .property_type = DEFINE_PROPERTY_TYPE ( @@ -5129,7 +5121,7 @@ static const NMMetaPropertyInfo *const property_infos_DCB[] = { ), ), PROPERTY_INFO_WITH_DESC (NM_SETTING_DCB_APP_FIP_PRIORITY, - .property_type = &_pt_gobject_dcb_priority, + DEFINE_DCB_PROPRITY_PROPERTY_TYPE ), PROPERTY_INFO_WITH_DESC (NM_SETTING_DCB_PRIORITY_FLOW_CONTROL_FLAGS, .property_type = DEFINE_PROPERTY_TYPE ( |