diff options
| author | Michael Biebl <biebl@debian.org> | 2024-01-25 09:46:18 +0100 |
|---|---|---|
| committer | Michael Biebl <biebl@debian.org> | 2024-01-25 09:46:18 +0100 |
| commit | 70e18d99b8e3e77bb37e218d7ac582130156f8ef (patch) | |
| tree | d40c587e6d3f0e094ff558e415f1bb9803643214 /src/libnm-core-impl/nm-setting-wired.c | |
| parent | d4d8b2b91f7ba000d97a8b2aab48c85000c11314 (diff) | |
New upstream version 1.45.90 upstream/1.45.90
Diffstat (limited to 'src/libnm-core-impl/nm-setting-wired.c')
| -rw-r--r-- | src/libnm-core-impl/nm-setting-wired.c | 60 |
1 files changed, 33 insertions, 27 deletions
diff --git a/src/libnm-core-impl/nm-setting-wired.c b/src/libnm-core-impl/nm-setting-wired.c index 1ee16df5..e09fd70d 100644 --- a/src/libnm-core-impl/nm-setting-wired.c +++ b/src/libnm-core-impl/nm-setting-wired.c @@ -75,20 +75,18 @@ typedef struct { * Wired Ethernet Settings */ struct _NMSettingWired { - NMSetting parent; - /* In the past, this struct was public API. Preserve ABI! */ + NMSetting parent; + NMSettingWiredPrivate _priv; }; struct _NMSettingWiredClass { NMSettingClass parent; - /* In the past, this struct was public API. Preserve ABI! */ - gpointer padding[4]; }; G_DEFINE_TYPE(NMSettingWired, nm_setting_wired, NM_TYPE_SETTING) #define NM_SETTING_WIRED_GET_PRIVATE(o) \ - (G_TYPE_INSTANCE_GET_PRIVATE((o), NM_TYPE_SETTING_WIRED, NMSettingWiredPrivate)) + _NM_GET_PRIVATE(o, NMSettingWired, NM_IS_SETTING_WIRED, NMSetting) /*****************************************************************************/ @@ -314,6 +312,8 @@ nm_setting_wired_get_num_mac_blacklist_items(NMSettingWired *setting) * @setting: the #NMSettingWired * @idx: the zero-based index of the MAC address entry * + * Since 1.46, access at index "len" is allowed and returns NULL. + * * Returns: the blacklisted MAC address string (hex-digits-and-colons notation) * at index @idx **/ @@ -325,7 +325,12 @@ nm_setting_wired_get_mac_blacklist_item(NMSettingWired *setting, guint32 idx) g_return_val_if_fail(NM_IS_SETTING_WIRED(setting), NULL); priv = NM_SETTING_WIRED_GET_PRIVATE(setting); - g_return_val_if_fail(idx <= priv->mac_address_blacklist->len, NULL); + + if (idx == priv->mac_address_blacklist->len) { + return NULL; + } + + g_return_val_if_fail(idx < priv->mac_address_blacklist->len, NULL); return nm_g_array_index(priv->mac_address_blacklist, const char *, idx); } @@ -886,7 +891,7 @@ verify(NMSetting *setting, NMConnection *connection, GError **error) } } - if (priv->cloned_mac_address && !NM_CLONED_MAC_IS_SPECIAL(priv->cloned_mac_address) + if (priv->cloned_mac_address && !NM_CLONED_MAC_IS_SPECIAL(priv->cloned_mac_address, FALSE) && !nm_utils_hwaddr_valid(priv->cloned_mac_address, ETH_ALEN)) { g_set_error(error, NM_CONNECTION_ERROR, @@ -1172,8 +1177,6 @@ nm_setting_wired_class_init(NMSettingWiredClass *klass) NMSettingClass *setting_class = NM_SETTING_CLASS(klass); GArray *properties_override = _nm_sett_info_property_override_create_array(); - g_type_class_add_private(klass, sizeof(NMSettingWiredPrivate)); - object_class->get_property = get_property; object_class->set_property = set_property; object_class->finalize = finalize; @@ -1200,7 +1203,8 @@ nm_setting_wired_class_init(NMSettingWiredClass *klass) PROP_PORT, NM_SETTING_PARAM_NONE, NMSettingWiredPrivate, - port); + port, + .direct_string_allow_empty = TRUE); /** * NMSettingWired:speed: @@ -1266,7 +1270,8 @@ nm_setting_wired_class_init(NMSettingWiredClass *klass) PROP_DUPLEX, NM_SETTING_PARAM_NONE, NMSettingWiredPrivate, - duplex); + duplex, + .direct_string_allow_empty = TRUE); /** * NMSettingWired:auto-negotiate: @@ -1455,7 +1460,8 @@ nm_setting_wired_class_init(NMSettingWiredClass *klass) PROP_GENERATE_MAC_ADDRESS_MASK, NM_SETTING_PARAM_FUZZY_IGNORE, NMSettingWiredPrivate, - generate_mac_address_mask); + generate_mac_address_mask, + .direct_string_allow_empty = TRUE); /** * NMSettingWired:mac-address-blacklist: @@ -1480,12 +1486,11 @@ nm_setting_wired_class_init(NMSettingWiredClass *klass) * example: HWADDR_BLACKLIST="00:22:68:11:69:08 00:11:22:11:44:55" * ---end--- */ - obj_properties[PROP_MAC_ADDRESS_BLACKLIST] = g_param_spec_boxed( - NM_SETTING_WIRED_MAC_ADDRESS_BLACKLIST, - "", - "", - G_TYPE_STRV, - G_PARAM_READWRITE | NM_SETTING_PARAM_FUZZY_IGNORE | G_PARAM_STATIC_STRINGS); + _nm_setting_property_define_gprop_strv_oldstyle(properties_override, + obj_properties, + NM_SETTING_WIRED_MAC_ADDRESS_BLACKLIST, + PROP_MAC_ADDRESS_BLACKLIST, + NM_SETTING_PARAM_FUZZY_IGNORE); /** * NMSettingWired:mtu: @@ -1528,12 +1533,11 @@ nm_setting_wired_class_init(NMSettingWiredClass *klass) * example: SUBCHANNELS=0.0.b00a,0.0.b00b,0.0.b00c * ---end--- */ - obj_properties[PROP_S390_SUBCHANNELS] = g_param_spec_boxed( - NM_SETTING_WIRED_S390_SUBCHANNELS, - "", - "", - G_TYPE_STRV, - G_PARAM_READWRITE | NM_SETTING_PARAM_INFERRABLE | G_PARAM_STATIC_STRINGS); + _nm_setting_property_define_gprop_strv_oldstyle(properties_override, + obj_properties, + NM_SETTING_WIRED_S390_SUBCHANNELS, + PROP_S390_SUBCHANNELS, + NM_SETTING_PARAM_INFERRABLE); /** * NMSettingWired:s390-nettype: @@ -1555,7 +1559,8 @@ nm_setting_wired_class_init(NMSettingWiredClass *klass) PROP_S390_NETTYPE, NM_SETTING_PARAM_INFERRABLE, NMSettingWiredPrivate, - s390_nettype); + s390_nettype, + .direct_string_allow_empty = TRUE); /** * NMSettingWired:s390-options: (type GHashTable(utf8,utf8)) @@ -1643,7 +1648,8 @@ nm_setting_wired_class_init(NMSettingWiredClass *klass) PROP_WAKE_ON_LAN_PASSWORD, NM_SETTING_PARAM_NONE, NMSettingWiredPrivate, - wol_password); + wol_password, + .direct_string_allow_empty = TRUE); /** * NMSettingWired:accept-all-mac-addresses: @@ -1675,5 +1681,5 @@ nm_setting_wired_class_init(NMSettingWiredClass *klass) NM_META_SETTING_TYPE_WIRED, NULL, properties_override, - NM_SETT_INFO_PRIVATE_OFFSET_FROM_CLASS); + G_STRUCT_OFFSET(NMSettingWired, _priv)); } |