libnm: merge branch 'th/libnm-strv-props'

https://gitlab.freedesktop.org/NetworkManager/NetworkManager/-/merge_requests/1775
This commit is contained in:
Thomas Haller 2023-11-08 09:39:35 +01:00
commit 6c5c5a73bd
No known key found for this signature in database
GPG key ID: 29C2366E4DFC5728
11 changed files with 205 additions and 184 deletions

View file

@ -3197,7 +3197,7 @@ nm_setting_802_1x_class_init(NMSetting8021xClass *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_sized(55);
object_class->get_property = get_property;
object_class->set_property = set_property;
@ -3223,11 +3223,11 @@ nm_setting_802_1x_class_init(NMSetting8021xClass *klass)
* example: IEEE_8021X_EAP_METHODS=PEAP
* ---end---
*/
obj_properties[PROP_EAP] = g_param_spec_boxed(NM_SETTING_802_1X_EAP,
"",
"",
G_TYPE_STRV,
G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS);
_nm_setting_property_define_gprop_strv_oldstyle(properties_override,
obj_properties,
NM_SETTING_802_1X_EAP,
PROP_EAP,
NM_SETTING_PARAM_NONE);
/**
* NMSetting8021x:identity:
@ -3422,12 +3422,11 @@ nm_setting_802_1x_class_init(NMSetting8021xClass *klass)
* example: IEEE_8021X_ALTSUBJECT_MATCHES="s1.domain.cc"
* ---end---
*/
obj_properties[PROP_ALTSUBJECT_MATCHES] =
g_param_spec_boxed(NM_SETTING_802_1X_ALTSUBJECT_MATCHES,
"",
"",
G_TYPE_STRV,
G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS);
_nm_setting_property_define_gprop_strv_oldstyle(properties_override,
obj_properties,
NM_SETTING_802_1X_ALTSUBJECT_MATCHES,
PROP_ALTSUBJECT_MATCHES,
NM_SETTING_PARAM_NONE);
/**
* NMSetting8021x:domain-suffix-match:
@ -3835,12 +3834,11 @@ nm_setting_802_1x_class_init(NMSetting8021xClass *klass)
* variable: IEEE_8021X_PHASE2_ALTSUBJECT_MATCHES(+)
* ---end---
*/
obj_properties[PROP_PHASE2_ALTSUBJECT_MATCHES] =
g_param_spec_boxed(NM_SETTING_802_1X_PHASE2_ALTSUBJECT_MATCHES,
"",
"",
G_TYPE_STRV,
G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS);
_nm_setting_property_define_gprop_strv_oldstyle(properties_override,
obj_properties,
NM_SETTING_802_1X_PHASE2_ALTSUBJECT_MATCHES,
PROP_PHASE2_ALTSUBJECT_MATCHES,
NM_SETTING_PARAM_NONE);
/**
* NMSetting8021x:phase2-domain-suffix-match:

View file

@ -1416,7 +1416,7 @@ nm_setting_bridge_class_init(NMSettingBridgeClass *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_sized(35);
object_class->get_property = get_property;
object_class->set_property = set_property;

View file

@ -1796,7 +1796,6 @@ finalize(GObject *object)
NMSettingConnectionPrivate *priv = NM_SETTING_CONNECTION_GET_PRIVATE(object);
nm_clear_pointer(&priv->permissions, g_array_unref);
nm_clear_pointer(&priv->secondaries.arr, g_array_unref);
G_OBJECT_CLASS(nm_setting_connection_parent_class)->finalize(object);
}
@ -1806,7 +1805,7 @@ nm_setting_connection_class_init(NMSettingConnectionClass *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_sized(35);
object_class->get_property = get_property;
object_class->set_property = set_property;
@ -2034,12 +2033,11 @@ nm_setting_connection_class_init(NMSettingConnectionClass *klass)
* example: USERS="joe bob"
* ---end---
*/
obj_properties[PROP_PERMISSIONS] =
g_param_spec_boxed(NM_SETTING_CONNECTION_PERMISSIONS,
"",
"",
G_TYPE_STRV,
G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS);
_nm_setting_property_define_gprop_strv_oldstyle(properties_override,
obj_properties,
NM_SETTING_CONNECTION_PERMISSIONS,
PROP_PERMISSIONS,
NM_SETTING_PARAM_NONE);
/**
* NMSettingConnection:autoconnect:

View file

@ -5963,7 +5963,7 @@ dns_data_from_dbus(_NM_SETT_INFO_PROP_FROM_DBUS_FCN_ARGS _nm_nil)
GArray *
_nm_sett_info_property_override_create_array_ip_config(int addr_family)
{
GArray *properties_override = _nm_sett_info_property_override_create_array();
GArray *properties_override = _nm_sett_info_property_override_create_array_sized(45);
nm_assert_addr_family(addr_family);
@ -6130,6 +6130,18 @@ _nm_sett_info_property_override_create_array_ip_config(int addr_family)
.direct_offset =
NM_STRUCT_OFFSET_ENSURE_TYPE(int, NMSettingIPConfigPrivate, replace_local_rule));
_nm_properties_override_gobj(properties_override,
obj_properties[PROP_DNS_SEARCH],
&nm_sett_info_propert_type_gprop_strv_oldstyle);
_nm_properties_override_gobj(properties_override,
obj_properties[PROP_DNS_OPTIONS],
&nm_sett_info_propert_type_gprop_strv_oldstyle);
_nm_properties_override_gobj(properties_override,
obj_properties[PROP_DHCP_REJECT_SERVERS],
&nm_sett_info_propert_type_gprop_strv_oldstyle);
return properties_override;
}

View file

@ -718,19 +718,6 @@ verify(NMSetting *setting, NMConnection *connection, GError **error)
return TRUE;
}
static void
finalize(GObject *object)
{
NMSettingMatch *self = NM_SETTING_MATCH(object);
nm_clear_pointer(&self->interface_name.arr, g_array_unref);
nm_clear_pointer(&self->kernel_command_line.arr, g_array_unref);
nm_clear_pointer(&self->driver.arr, g_array_unref);
nm_clear_pointer(&self->path.arr, g_array_unref);
G_OBJECT_CLASS(nm_setting_match_parent_class)->finalize(object);
}
static void
nm_setting_match_class_init(NMSettingMatchClass *klass)
{
@ -740,7 +727,6 @@ nm_setting_match_class_init(NMSettingMatchClass *klass)
object_class->get_property = _nm_setting_property_get_property_direct;
object_class->set_property = _nm_setting_property_set_property_direct;
object_class->finalize = finalize;
setting_class->verify = verify;

View file

@ -331,6 +331,7 @@ extern const NMSettInfoPropertType nm_sett_info_propert_type_setting_name;
extern const NMSettInfoPropertType nm_sett_info_propert_type_deprecated_interface_name;
extern const NMSettInfoPropertType nm_sett_info_propert_type_deprecated_ignore_i;
extern const NMSettInfoPropertType nm_sett_info_propert_type_deprecated_ignore_u;
extern const NMSettInfoPropertType nm_sett_info_propert_type_gprop_strv_oldstyle;
extern const NMSettInfoPropertType nm_sett_info_propert_type_direct_boolean;
extern const NMSettInfoPropertType nm_sett_info_propert_type_direct_int32;
@ -419,11 +420,7 @@ const NMSettInfoProperty *
_nm_sett_info_property_lookup_by_param_spec(const NMSettInfoSetting *sett_info,
const GParamSpec *param_spec);
static inline GArray *
_nm_sett_info_property_override_create_array_sized(guint reserved_size)
{
return g_array_sized_new(FALSE, FALSE, sizeof(NMSettInfoProperty), reserved_size);
}
GArray *_nm_sett_info_property_override_create_array_sized(guint reserved_size);
static inline GArray *
_nm_sett_info_property_override_create_array(void)
@ -486,15 +483,23 @@ _nm_properties_override(GArray *properties_override, const NMSettInfoProperty *p
g_array_append_vals(properties_override, prop_info, 1);
}
#define _nm_properties_override_gobj(properties_override, \
p_param_spec, \
p_property_type, \
... /* extra NMSettInfoProperty fields */) \
_nm_properties_override((properties_override), \
NM_SETT_INFO_PROPERTY(.name = NULL, \
.param_spec = (p_param_spec), \
.property_type = (p_property_type), \
__VA_ARGS__))
#define _nm_properties_override_gobj(properties_override, \
p_param_spec, \
p_property_type, \
... /* extra NMSettInfoProperty fields */) \
G_STMT_START \
{ \
GParamSpec *const _p_param_spec_2 = (p_param_spec); \
\
nm_assert(_p_param_spec_2); \
\
_nm_properties_override((properties_override), \
NM_SETT_INFO_PROPERTY(.name = _p_param_spec_2->name, \
.param_spec = _p_param_spec_2, \
.property_type = (p_property_type), \
__VA_ARGS__)); \
} \
G_STMT_END
#define _nm_properties_override_dbus(properties_override, \
p_name, \
@ -1035,6 +1040,38 @@ _nm_properties_override(GArray *properties_override, const NMSettInfoProperty *p
} \
G_STMT_END
/* This should not be used for new strv properties. Use _nm_setting_property_define_direct_strv().
*
* FIXME: existing properties should migrate to _nm_setting_property_define_direct_strv(). */
#define _nm_setting_property_define_gprop_strv_oldstyle(properties_override, \
obj_properties, \
prop_name, \
prop_id, \
param_flags) \
G_STMT_START \
{ \
GParamSpec *_param_spec; \
\
G_STATIC_ASSERT(!NM_FLAGS_ANY((param_flags), \
~(NM_SETTING_PARAM_SECRET | NM_SETTING_PARAM_FUZZY_IGNORE \
| NM_SETTING_PARAM_INFERRABLE \
| NM_SETTING_PARAM_REAPPLY_IMMEDIATELY))); \
\
_param_spec = \
g_param_spec_boxed("" prop_name "", \
"", \
"", \
G_TYPE_STRV, \
G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS | (param_flags)); \
\
(obj_properties)[(prop_id)] = _param_spec; \
\
_nm_properties_override_gobj((properties_override), \
_param_spec, \
&nm_sett_info_propert_type_gprop_strv_oldstyle); \
} \
G_STMT_END
/*****************************************************************************/
gboolean _nm_setting_use_legacy_property(NMSetting *setting,

View file

@ -979,12 +979,11 @@ nm_setting_vlan_class_init(NMSettingVlanClass *klass)
* example: VLAN_INGRESS_PRIORITY_MAP=4:2,3:5
* ---end---
*/
obj_properties[PROP_INGRESS_PRIORITY_MAP] = g_param_spec_boxed(
NM_SETTING_VLAN_INGRESS_PRIORITY_MAP,
"",
"",
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_VLAN_INGRESS_PRIORITY_MAP,
PROP_INGRESS_PRIORITY_MAP,
NM_SETTING_PARAM_INFERRABLE);
/**
* NMSettingVlan:egress-priority-map:
@ -1000,12 +999,11 @@ nm_setting_vlan_class_init(NMSettingVlanClass *klass)
* example: VLAN_EGRESS_PRIORITY_MAP=5:4,4:1,3:7
* ---end---
*/
obj_properties[PROP_EGRESS_PRIORITY_MAP] = g_param_spec_boxed(
NM_SETTING_VLAN_EGRESS_PRIORITY_MAP,
"",
"",
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_VLAN_EGRESS_PRIORITY_MAP,
PROP_EGRESS_PRIORITY_MAP,
NM_SETTING_PARAM_INFERRABLE);
/* ---ifcfg-rh---
* property: interface-name

View file

@ -1483,12 +1483,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:
@ -1531,12 +1530,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:

View file

@ -1383,7 +1383,7 @@ nm_setting_wireless_security_class_init(NMSettingWirelessSecurityClass *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_sized(25);
object_class->get_property = get_property;
object_class->set_property = set_property;
@ -1490,11 +1490,11 @@ nm_setting_wireless_security_class_init(NMSettingWirelessSecurityClass *klass)
* description: Allowed WPA protocols, WPA and WPA2 (RSN).
* ---end---
*/
obj_properties[PROP_PROTO] = g_param_spec_boxed(NM_SETTING_WIRELESS_SECURITY_PROTO,
"",
"",
G_TYPE_STRV,
G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS);
_nm_setting_property_define_gprop_strv_oldstyle(properties_override,
obj_properties,
NM_SETTING_WIRELESS_SECURITY_PROTO,
PROP_PROTO,
NM_SETTING_PARAM_NONE);
/**
* NMSettingWirelessSecurity:pairwise:
@ -1512,11 +1512,11 @@ nm_setting_wireless_security_class_init(NMSettingWirelessSecurityClass *klass)
* separated list.
* ---end---
*/
obj_properties[PROP_PAIRWISE] = g_param_spec_boxed(NM_SETTING_WIRELESS_SECURITY_PAIRWISE,
"",
"",
G_TYPE_STRV,
G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS);
_nm_setting_property_define_gprop_strv_oldstyle(properties_override,
obj_properties,
NM_SETTING_WIRELESS_SECURITY_PAIRWISE,
PROP_PAIRWISE,
NM_SETTING_PARAM_NONE);
/**
* NMSettingWirelessSecurity:group:
@ -1534,11 +1534,11 @@ nm_setting_wireless_security_class_init(NMSettingWirelessSecurityClass *klass)
* separated list.
* ---end---
*/
obj_properties[PROP_GROUP] = g_param_spec_boxed(NM_SETTING_WIRELESS_SECURITY_GROUP,
"",
"",
G_TYPE_STRV,
G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS);
_nm_setting_property_define_gprop_strv_oldstyle(properties_override,
obj_properties,
NM_SETTING_WIRELESS_SECURITY_GROUP,
PROP_GROUP,
NM_SETTING_PARAM_NONE);
/**
* NMSettingWirelessSecurity:pmf:

View file

@ -1312,7 +1312,7 @@ nm_setting_wireless_class_init(NMSettingWirelessClass *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_sized(25);
object_class->set_property = set_property;
object_class->get_property = get_property;
@ -1680,12 +1680,11 @@ nm_setting_wireless_class_init(NMSettingWirelessClass *klass)
* is listed.
* ---end---
*/
obj_properties[PROP_MAC_ADDRESS_BLACKLIST] = g_param_spec_boxed(
NM_SETTING_WIRELESS_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_WIRELESS_MAC_ADDRESS_BLACKLIST,
PROP_MAC_ADDRESS_BLACKLIST,
NM_SETTING_PARAM_FUZZY_IGNORE);
/**
* NMSettingWireless:seen-bssids:

View file

@ -183,9 +183,8 @@ _nm_properties_override_assert(const NMSettInfoProperty *prop_info)
{
#if NM_MORE_ASSERTS
nm_assert(prop_info);
nm_assert((!!prop_info->name) != (!!prop_info->param_spec));
nm_assert(!prop_info->param_spec || !prop_info->name
|| nm_streq0(prop_info->name, prop_info->param_spec->name));
nm_assert(prop_info->name);
nm_assert(!prop_info->param_spec || prop_info->name == prop_info->param_spec->name);
if (prop_info->property_type) {
const NMSettInfoPropertType *property_type = prop_info->property_type;
@ -208,6 +207,34 @@ _nm_properties_override_assert(const NMSettInfoProperty *prop_info)
return TRUE;
}
GArray *
_nm_sett_info_property_override_create_array_sized(guint reserved_size)
{
GArray *properties_override;
GParamSpec *param_spec;
/* pre-allocate a relatively large buffer to avoid frequent re-allocations.
* Note that the buffer is only short-lived and will be destroyed by
* _nm_setting_class_commit(). */
properties_override =
g_array_sized_new(FALSE, FALSE, sizeof(NMSettInfoProperty), reserved_size);
/* The "name" property is special because it's defined in the
* parent class NMSetting. We add the property info right here.
*/
param_spec = obj_properties[PROP_NAME];
nm_assert(param_spec);
nm_assert(nm_streq0(param_spec->name, NM_SETTING_NAME));
nm_assert(param_spec
== g_object_class_find_property(g_type_class_peek(NM_TYPE_SETTING), NM_SETTING_NAME));
nm_assert(!NM_FLAGS_HAS(param_spec->flags, G_PARAM_WRITABLE));
_nm_properties_override_gobj(properties_override,
param_spec,
&nm_sett_info_propert_type_setting_name);
return properties_override;
}
static NMSettInfoSetting _sett_info_settings[_NM_META_SETTING_TYPE_NUM];
const NMSettInfoSetting *
@ -223,10 +250,8 @@ _property_infos_sort_cmp_setting_connection(gconstpointer p_a,
{
const NMSettInfoProperty *a = *((const NMSettInfoProperty *const *) p_a);
const NMSettInfoProperty *b = *((const NMSettInfoProperty *const *) p_b);
int c_name;
c_name = strcmp(a->name, b->name);
nm_assert(c_name != 0);
nm_assert(a->name && b->name && !nm_streq(a->name, b->name));
#define CMP_AND_RETURN(n_a, n_b, name) \
G_STMT_START \
@ -239,15 +264,14 @@ _property_infos_sort_cmp_setting_connection(gconstpointer p_a,
G_STMT_END
/* for [connection], report first id, uuid, type in that order. */
if (c_name != 0) {
CMP_AND_RETURN(a->name, b->name, NM_SETTING_CONNECTION_ID);
CMP_AND_RETURN(a->name, b->name, NM_SETTING_CONNECTION_UUID);
CMP_AND_RETURN(a->name, b->name, NM_SETTING_CONNECTION_TYPE);
}
CMP_AND_RETURN(a->name, b->name, NM_SETTING_CONNECTION_ID);
CMP_AND_RETURN(a->name, b->name, NM_SETTING_CONNECTION_UUID);
CMP_AND_RETURN(a->name, b->name, NM_SETTING_CONNECTION_TYPE);
#undef CMP_AND_RETURN
return c_name;
NM_CMP_FIELD_STR(a, b, name);
return nm_assert_unreachable_val(0);
}
static const NMSettInfoProperty *const *
@ -305,9 +329,11 @@ _nm_setting_class_commit(NMSettingClass *setting_class,
GArray *properties_override,
gint16 private_offset)
{
NMSettInfoSetting *sett_info;
gs_free GParamSpec **property_specs = NULL;
guint n_property_specs;
NMSettInfoSetting *sett_info;
#if NM_MORE_ASSERTS > 10
gs_free GParamSpec **property_specs = NULL;
guint n_property_specs;
#endif
NMSettInfoPropertLookupByParamSpec *lookup_by_iter;
guint override_len;
guint i;
@ -324,35 +350,26 @@ _nm_setting_class_commit(NMSettingClass *setting_class,
nm_assert(!sett_info->property_infos_len);
nm_assert(!sett_info->property_infos);
if (!properties_override)
properties_override = _nm_sett_info_property_override_create_array_sized(1);
override_len = properties_override->len;
nm_assert(override_len > 0);
#if NM_MORE_ASSERTS > 10
property_specs =
g_object_class_list_properties(G_OBJECT_CLASS(setting_class), &n_property_specs);
if (!properties_override) {
override_len = 0;
properties_override = _nm_sett_info_property_override_create_array_sized(n_property_specs);
} else {
override_len = properties_override->len;
for (i = 0; i < override_len; i++) {
NMSettInfoProperty *p = &nm_g_array_index(properties_override, NMSettInfoProperty, i);
nm_assert((!!p->name) != (!!p->param_spec));
if (!p->name) {
nm_assert(p->param_spec);
p->name = p->param_spec->name;
} else
nm_assert(!p->param_spec);
}
}
#if NM_MORE_ASSERTS > 10
/* assert that properties_override is constructed consistently. */
for (i = 0; i < override_len; i++) {
const NMSettInfoProperty *p = &nm_g_array_index(properties_override, NMSettInfoProperty, i);
gboolean found = FALSE;
guint k;
nm_assert(p->name);
nm_assert(!p->param_spec || p->name == p->param_spec->name);
nm_assert(!_nm_sett_info_property_find_in_array(
nm_g_array_first_p(properties_override, NMSettInfoProperty),
i,
@ -366,62 +383,31 @@ _nm_setting_class_commit(NMSettingClass *setting_class,
}
nm_assert(found == (p->param_spec != NULL));
}
#endif
for (i = 0; i < n_property_specs; i++) {
const char *name = property_specs[i]->name;
NMSettInfoProperty *p;
const GParamSpec *param_spec = property_specs[i];
const char *name = param_spec->name;
const NMSettInfoProperty *p;
if (_nm_sett_info_property_find_in_array(
nm_g_array_first_p(properties_override, NMSettInfoProperty),
override_len,
name))
continue;
p = nm_g_array_append_new(properties_override, NMSettInfoProperty);
memset(p, 0, sizeof(*p));
p->name = name;
p->param_spec = property_specs[i];
p = _nm_sett_info_property_find_in_array(
nm_g_array_first_p(properties_override, NMSettInfoProperty),
override_len,
name);
nm_assert(p);
nm_assert(p->param_spec);
nm_assert(p->param_spec == param_spec);
}
for (i = 0; i < properties_override->len; i++) {
NMSettInfoProperty *p = &nm_g_array_index(properties_override, NMSettInfoProperty, i);
GType vtype;
if (p->property_type)
goto has_property_type;
nm_assert(p->param_spec);
vtype = p->param_spec->value_type;
if (vtype == G_TYPE_STRING) {
/* The "name" property is a bit special because it's defined in the
* parent class NMSetting. We set the property_type here, because
* it's more convenient (albeit a bit ugly).
*
* FIXME: let _nm_sett_info_property_override_create_array() always add
* the handling of the name property.*/
nm_assert(nm_streq(p->name, NM_SETTING_NAME));
nm_assert(!NM_FLAGS_HAS(p->param_spec->flags, G_PARAM_WRITABLE));
p->property_type = &nm_sett_info_propert_type_setting_name;
goto has_property_type;
}
if (vtype == G_TYPE_STRV)
p->property_type = NM_SETT_INFO_PROPERT_TYPE_GPROP(
G_VARIANT_TYPE_STRING_ARRAY,
.compare_fcn = _nm_setting_property_compare_fcn_default,
.from_dbus_fcn = _nm_setting_property_from_dbus_fcn_gprop,
.from_dbus_is_full = TRUE);
else
nm_assert_not_reached();
has_property_type:
nm_assert(p->property_type);
nm_assert(p->property_type->dbus_type);
nm_assert(g_variant_type_string_is_valid((const char *) p->property_type->dbus_type));
nm_assert(p->name);
nm_assert(!p->param_spec || nm_streq0(p->name, p->param_spec->name));
}
#endif
G_STATIC_ASSERT_EXPR(G_STRUCT_OFFSET(NMSettInfoProperty, name) == 0);
g_array_sort(properties_override, nm_strcmp_p);
@ -838,7 +824,7 @@ _nm_setting_property_get_property_direct(GObject *object,
goto out_fail;
}
return;
nm_assert_not_reached();
out_fail:
G_OBJECT_WARN_INVALID_PROPERTY_ID(object, prop_id, pspec);
@ -985,7 +971,7 @@ _nm_setting_property_set_property_direct(GObject *object,
goto out_fail;
}
return;
nm_assert_not_reached();
out_notify:
/* If explicit-notify would be set, we would need to emit g_object_notify_by_pspec().
@ -3606,6 +3592,15 @@ const NMSettInfoPropertType nm_sett_info_propert_type_deprecated_ignore_u =
/* No functions set. This property type is to silently ignore the value on D-Bus. */
.compare_fcn = _nm_setting_property_compare_fcn_ignore);
/* This should not be used for new strv properties. Use nm_sett_info_propert_type_direct_strv.
*
* FIXME: existing properties should migrate to nm_sett_info_propert_type_direct_strv. */
const NMSettInfoPropertType nm_sett_info_propert_type_gprop_strv_oldstyle =
NM_SETT_INFO_PROPERT_TYPE_GPROP_INIT(G_VARIANT_TYPE_STRING_ARRAY,
.compare_fcn = _nm_setting_property_compare_fcn_default,
.from_dbus_fcn = _nm_setting_property_from_dbus_fcn_gprop,
.from_dbus_is_full = TRUE);
const NMSettInfoPropertType nm_sett_info_propert_type_direct_boolean =
NM_SETT_INFO_PROPERT_TYPE_DBUS_INIT(G_VARIANT_TYPE_BOOLEAN,
.direct_type = NM_VALUE_TYPE_BOOL,