summary refs log tree commit diff
path: root/src/libnm-core-impl/nm-setting-wired.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/libnm-core-impl/nm-setting-wired.c')
-rw-r--r--src/libnm-core-impl/nm-setting-wired.c60
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));
 }