libnm: move NMSettInfoProperty.to_dbus_including_default flag

The "to_dbus_data" existed for namespacing the properties inside it.
However, such a struct adds overhead due to the alignment that it
enforces. We can share the memory needed for the bitfield by having
them beside each other.
This commit is contained in:
Thomas Haller 2021-06-29 22:11:08 +02:00
parent 9a05db61d6
commit 36f552c5ca
No known key found for this signature in database
GPG key ID: 29C2366E4DFC5728
4 changed files with 11 additions and 13 deletions

View file

@ -1383,7 +1383,7 @@ nm_setting_wired_class_init(NMSettingWiredClass *klass)
NM_SETTING_PARAM_NONE,
NMSettingWiredPrivate,
auto_negotiate,
.to_dbus_data.including_default = TRUE);
.to_dbus_including_default = TRUE);
/**
* NMSettingWired:mac-address:

View file

@ -886,7 +886,7 @@ _nm_setting_property_to_dbus_fcn_direct(const NMSettInfoSetting *
gboolean val;
val = *((bool *) _nm_setting_get_private(setting, sett_info, property_info->direct_offset));
if (!property_info->to_dbus_data.including_default
if (!property_info->to_dbus_including_default
&& val == NM_G_PARAM_SPEC_GET_DEFAULT_BOOLEAN(property_info->param_spec))
return NULL;
return g_variant_ref(nm_g_variant_singleton_b(val));
@ -897,7 +897,7 @@ _nm_setting_property_to_dbus_fcn_direct(const NMSettInfoSetting *
val = *(
(guint32 *) _nm_setting_get_private(setting, sett_info, property_info->direct_offset));
if (!property_info->to_dbus_data.including_default
if (!property_info->to_dbus_including_default
&& val == NM_G_PARAM_SPEC_GET_DEFAULT_UINT(property_info->param_spec))
return NULL;
return g_variant_new_uint32(val);
@ -912,7 +912,7 @@ _nm_setting_property_to_dbus_fcn_direct(const NMSettInfoSetting *
* Setting "including_default" for a string makes no sense because a
* GVariant of type "s" cannot express NULL. */
nm_assert(!NM_G_PARAM_SPEC_GET_DEFAULT_STRING(property_info->param_spec));
nm_assert(!property_info->to_dbus_data.including_default);
nm_assert(!property_info->to_dbus_including_default);
val = *((const char *const *) _nm_setting_get_private(setting,
sett_info,
@ -948,7 +948,7 @@ _nm_setting_property_to_dbus_fcn_gprop(const NMSettInfoSetting * s
g_object_get_property(G_OBJECT(setting), property_info->param_spec->name, &prop_value);
if (!property_info->to_dbus_data.including_default
if (!property_info->to_dbus_including_default
&& g_param_value_defaults(property_info->param_spec, &prop_value))
return NULL;

View file

@ -4512,7 +4512,7 @@ check_done:;
}
if (!can_set_including_default)
g_assert(!sip->to_dbus_data.including_default);
g_assert(!sip->to_dbus_including_default);
g_assert(!sip->property_type->from_dbus_fcn
|| !sip->property_type->gprop_from_dbus_fcn);

View file

@ -744,13 +744,11 @@ struct _NMSettInfoProperty {
* except of marking those properties and serve as a reminder that special care needs to be taken. */
bool direct_has_special_setter : 1;
struct {
/* Usually, properties that are set to the default value for the GParamSpec
* are not serialized to GVariant (and NULL is returned by to_dbus_data().
* Set this flag to force always converting the property even if the value
* is the default. */
bool including_default : 1;
} to_dbus_data;
/* Usually, properties that are set to the default value for the GParamSpec
* are not serialized to GVariant (and NULL is returned by to_dbus_data().
* Set this flag to force always converting the property even if the value
* is the default. */
bool to_dbus_including_default : 1;
};
typedef struct {