about summary refs log tree commit diff
path: root/src/libnm-core-impl/nm-setting-vlan.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/libnm-core-impl/nm-setting-vlan.c')
-rw-r--r--src/libnm-core-impl/nm-setting-vlan.c78
1 files changed, 36 insertions, 42 deletions
diff --git a/src/libnm-core-impl/nm-setting-vlan.c b/src/libnm-core-impl/nm-setting-vlan.c
index 1124953e..5f50acdd 100644
--- a/src/libnm-core-impl/nm-setting-vlan.c
+++ b/src/libnm-core-impl/nm-setting-vlan.c
@@ -36,7 +36,7 @@ NM_GOBJECT_PROPERTIES_DEFINE(NMSettingVlan,
 typedef struct {
     GSList *ingress_priority_map;
     GSList *egress_priority_map;
-    char *  parent;
+    char   *parent;
     guint32 id;
     guint32 flags;
 } NMSettingVlanPrivate;
@@ -77,6 +77,7 @@ const char *
 nm_setting_vlan_get_parent(NMSettingVlan *setting)
 {
     g_return_val_if_fail(NM_IS_SETTING_VLAN(setting), NULL);
+
     return NM_SETTING_VLAN_GET_PRIVATE(setting)->parent;
 }
 
@@ -197,7 +198,7 @@ set_map(NMSettingVlan *self, NMVlanPriorityMap map, GSList *list)
 static gboolean
 check_replace_duplicate_priority(GSList *list, guint32 from, guint32 to)
 {
-    GSList *          iter;
+    GSList           *iter;
     NMVlanQosMapping *p;
 
     for (iter = list; iter; iter = g_slist_next(iter)) {
@@ -226,7 +227,7 @@ check_replace_duplicate_priority(GSList *list, guint32 from, guint32 to)
 gboolean
 nm_setting_vlan_add_priority_str(NMSettingVlan *setting, NMVlanPriorityMap map, const char *str)
 {
-    GSList *          list = NULL;
+    GSList           *list = NULL;
     NMVlanQosMapping *item = NULL;
 
     g_return_val_if_fail(NM_IS_SETTING_VLAN(setting), FALSE);
@@ -287,14 +288,14 @@ nm_setting_vlan_get_num_priorities(NMSettingVlan *setting, NMVlanPriorityMap map
  * Returns: returns %TRUE if @idx is in range. Otherwise, %FALSE.
  **/
 gboolean
-nm_setting_vlan_get_priority(NMSettingVlan *   setting,
+nm_setting_vlan_get_priority(NMSettingVlan    *setting,
                              NMVlanPriorityMap map,
                              guint32           idx,
-                             guint32 *         out_from,
-                             guint32 *         out_to)
+                             guint32          *out_from,
+                             guint32          *out_to)
 {
     NMVlanQosMapping *item;
-    GSList *          list;
+    GSList           *list;
 
     g_return_val_if_fail(NM_IS_SETTING_VLAN(setting), FALSE);
     g_return_val_if_fail(NM_IN_SET(map, NM_VLAN_INGRESS_MAP, NM_VLAN_EGRESS_MAP), FALSE);
@@ -334,12 +335,12 @@ nm_setting_vlan_get_priority(NMSettingVlan *   setting,
  * Returns: %TRUE.
  */
 gboolean
-nm_setting_vlan_add_priority(NMSettingVlan *   setting,
+nm_setting_vlan_add_priority(NMSettingVlan    *setting,
                              NMVlanPriorityMap map,
                              guint32           from,
                              guint32           to)
 {
-    GSList *          list = NULL;
+    GSList           *list = NULL;
     NMVlanQosMapping *item;
 
     g_return_val_if_fail(NM_IS_SETTING_VLAN(setting), FALSE);
@@ -363,13 +364,13 @@ nm_setting_vlan_add_priority(NMSettingVlan *   setting,
 }
 
 gboolean
-_nm_setting_vlan_set_priorities(NMSettingVlan *         setting,
+_nm_setting_vlan_set_priorities(NMSettingVlan          *setting,
                                 NMVlanPriorityMap       map,
                                 const NMVlanQosMapping *qos_map,
                                 guint                   n_qos_map)
 {
     gboolean has_changes = FALSE;
-    GSList * map_prev, *map_new;
+    GSList  *map_prev, *map_new;
     guint    i;
     gint64   from_last;
 
@@ -398,7 +399,7 @@ _nm_setting_vlan_set_priorities(NMSettingVlan *         setting,
     from_last = G_MAXINT64;
     for (i = n_qos_map; i > 0;) {
         const NMVlanQosMapping *m = &qos_map[--i];
-        NMVlanQosMapping *      item;
+        NMVlanQosMapping       *item;
 
         /* We require the array to be presorted. */
         if (m->from >= from_last)
@@ -418,12 +419,12 @@ _nm_setting_vlan_set_priorities(NMSettingVlan *         setting,
 }
 
 void
-_nm_setting_vlan_get_priorities(NMSettingVlan *    setting,
+_nm_setting_vlan_get_priorities(NMSettingVlan     *setting,
                                 NMVlanPriorityMap  map,
                                 NMVlanQosMapping **out_qos_map,
-                                guint *            out_n_qos_map)
+                                guint             *out_n_qos_map)
 {
-    GSList *          list;
+    GSList           *list;
     NMVlanQosMapping *qos_map = NULL;
     guint             n_qos_map, i;
 
@@ -470,13 +471,13 @@ nm_setting_vlan_remove_priority(NMSettingVlan *setting, NMVlanPriorityMap map, g
 }
 
 static gboolean
-priority_map_remove_by_value(NMSettingVlan *   setting,
+priority_map_remove_by_value(NMSettingVlan    *setting,
                              NMVlanPriorityMap map,
                              guint32           from,
                              guint32           to,
                              gboolean          wildcard_to)
 {
-    GSList *          list = NULL, *iter = NULL;
+    GSList           *list = NULL, *iter = NULL;
     NMVlanQosMapping *item;
 
     nm_assert(NM_IS_SETTING_VLAN(setting));
@@ -512,7 +513,7 @@ priority_map_remove_by_value(NMSettingVlan *   setting,
  * Returns: %TRUE if the priority mapping was found and removed; %FALSE if it was not.
  */
 gboolean
-nm_setting_vlan_remove_priority_by_value(NMSettingVlan *   setting,
+nm_setting_vlan_remove_priority_by_value(NMSettingVlan    *setting,
                                          NMVlanPriorityMap map,
                                          guint32           from,
                                          guint32           to)
@@ -536,9 +537,9 @@ nm_setting_vlan_remove_priority_by_value(NMSettingVlan *   setting,
  * Returns: %TRUE if the priority mapping was found and removed; %FALSE if it was not.
  */
 gboolean
-nm_setting_vlan_remove_priority_str_by_value(NMSettingVlan *   setting,
+nm_setting_vlan_remove_priority_str_by_value(NMSettingVlan    *setting,
                                              NMVlanPriorityMap map,
-                                             const char *      str)
+                                             const char       *str)
 {
     gboolean is_wildcard_to;
     guint32  from, to;
@@ -578,8 +579,8 @@ static int
 verify(NMSetting *setting, NMConnection *connection, GError **error)
 {
     NMSettingVlanPrivate *priv = NM_SETTING_VLAN_GET_PRIVATE(setting);
-    NMSettingConnection * s_con;
-    NMSettingWired *      s_wired;
+    NMSettingConnection  *s_con;
+    NMSettingWired       *s_wired;
 
     if (connection) {
         s_con   = nm_connection_get_setting_connection(connection);
@@ -712,7 +713,7 @@ priority_strv_to_maplist(NMVlanPriorityMap map, char **strv)
 static char **
 priority_maplist_to_strv(GSList *list)
 {
-    GSList *   iter;
+    GSList    *iter;
     GPtrArray *strv;
 
     strv = g_ptr_array_new();
@@ -732,13 +733,10 @@ priority_maplist_to_strv(GSList *list)
 static void
 get_property(GObject *object, guint prop_id, GValue *value, GParamSpec *pspec)
 {
-    NMSettingVlan *       setting = NM_SETTING_VLAN(object);
+    NMSettingVlan        *setting = NM_SETTING_VLAN(object);
     NMSettingVlanPrivate *priv    = NM_SETTING_VLAN_GET_PRIVATE(setting);
 
     switch (prop_id) {
-    case PROP_PARENT:
-        g_value_set_string(value, priv->parent);
-        break;
     case PROP_FLAGS:
         g_value_set_flags(value, priv->flags);
         break;
@@ -757,14 +755,10 @@ get_property(GObject *object, guint prop_id, GValue *value, GParamSpec *pspec)
 static void
 set_property(GObject *object, guint prop_id, const GValue *value, GParamSpec *pspec)
 {
-    NMSettingVlan *       setting = NM_SETTING_VLAN(object);
+    NMSettingVlan        *setting = NM_SETTING_VLAN(object);
     NMSettingVlanPrivate *priv    = NM_SETTING_VLAN_GET_PRIVATE(setting);
 
     switch (prop_id) {
-    case PROP_PARENT:
-        g_free(priv->parent);
-        priv->parent = g_value_dup_string(value);
-        break;
     case PROP_FLAGS:
         priv->flags = g_value_get_flags(value);
         break;
@@ -810,10 +804,9 @@ nm_setting_vlan_new(void)
 static void
 finalize(GObject *object)
 {
-    NMSettingVlan *       setting = NM_SETTING_VLAN(object);
+    NMSettingVlan        *setting = NM_SETTING_VLAN(object);
     NMSettingVlanPrivate *priv    = NM_SETTING_VLAN_GET_PRIVATE(setting);
 
-    g_free(priv->parent);
     g_slist_free_full(priv->ingress_priority_map, g_free);
     g_slist_free_full(priv->egress_priority_map, g_free);
 
@@ -823,9 +816,9 @@ finalize(GObject *object)
 static void
 nm_setting_vlan_class_init(NMSettingVlanClass *klass)
 {
-    GObjectClass *  object_class        = G_OBJECT_CLASS(klass);
+    GObjectClass   *object_class        = G_OBJECT_CLASS(klass);
     NMSettingClass *setting_class       = NM_SETTING_CLASS(klass);
-    GArray *        properties_override = _nm_sett_info_property_override_create_array();
+    GArray         *properties_override = _nm_sett_info_property_override_create_array();
 
     g_type_class_add_private(klass, sizeof(NMSettingVlanPrivate));
 
@@ -849,12 +842,13 @@ nm_setting_vlan_class_init(NMSettingVlanClass *klass)
      * description: Parent interface of the VLAN.
      * ---end---
      */
-    obj_properties[PROP_PARENT] = g_param_spec_string(
-        NM_SETTING_VLAN_PARENT,
-        "",
-        "",
-        NULL,
-        G_PARAM_READWRITE | NM_SETTING_PARAM_INFERRABLE | G_PARAM_STATIC_STRINGS);
+    _nm_setting_property_define_direct_string(properties_override,
+                                              obj_properties,
+                                              NM_SETTING_VLAN_PARENT,
+                                              PROP_PARENT,
+                                              NM_SETTING_PARAM_INFERRABLE,
+                                              NMSettingVlanPrivate,
+                                              parent);
 
     /**
      * NMSettingVlan:id: