diff options
| author | Michael Biebl <biebl@debian.org> | 2022-02-14 19:23:28 +0100 |
|---|---|---|
| committer | Michael Biebl <biebl@debian.org> | 2022-02-14 19:23:28 +0100 |
| commit | 2f94dba7385fd0e0ef19a06eb4a2fcf6c43d7946 (patch) | |
| tree | e2222f5577115985dd52044d2991253403cdd952 /src/libnm-core-impl | |
| parent | 88c227d90a6b7b388c5c85d72802a0ca8f05ed5c (diff) | |
New upstream version 1.35.91 upstream/1.35.91
Diffstat (limited to 'src/libnm-core-impl')
79 files changed, 4822 insertions, 5591 deletions
diff --git a/src/libnm-core-impl/nm-connection-private.h b/src/libnm-core-impl/nm-connection-private.h index 27769ec1..08abb9a4 100644 --- a/src/libnm-core-impl/nm-connection-private.h +++ b/src/libnm-core-impl/nm-connection-private.h @@ -18,12 +18,12 @@ NMSetting *_nm_connection_find_base_type_setting(NMConnection *connection); const char *_nm_connection_detect_slave_type(NMConnection *connection, NMSetting **out_s_port); gboolean _nm_connection_detect_slave_type_full(NMSettingConnection *s_con, - NMConnection * connection, - const char ** out_slave_type, - const char ** out_normerr_slave_setting_type, - const char ** out_normerr_missing_slave_type, + NMConnection *connection, + const char **out_slave_type, + const char **out_normerr_slave_setting_type, + const char **out_normerr_missing_slave_type, const char **out_normerr_missing_slave_type_port, - GError ** error); + GError **error); const char *_nm_connection_detect_bluetooth_type(NMConnection *self); @@ -32,11 +32,11 @@ gboolean _nm_setting_connection_verify_secondaries(GArray *secondaries, GError * gboolean _nm_connection_verify_required_interface_name(NMConnection *connection, GError **error); int _nm_setting_ovs_interface_verify_interface_type(NMSettingOvsInterface *self, - const char * type, - NMConnection * connection, + const char *type, + NMConnection *connection, gboolean normalize, - gboolean * out_modified, - const char ** out_normalized_type, - GError ** error); + gboolean *out_modified, + const char **out_normalized_type, + GError **error); #endif /* __NM_CONNECTION_PRIVATE_H__ */ diff --git a/src/libnm-core-impl/nm-connection.c b/src/libnm-core-impl/nm-connection.c index dc85ea0c..a9b130a7 100644 --- a/src/libnm-core-impl/nm-connection.c +++ b/src/libnm-core-impl/nm-connection.c @@ -126,7 +126,7 @@ _nm_connection_get_private_from_qdata(NMConnection *connection) #define NM_CONNECTION_GET_PRIVATE(connection) \ ({ \ - NMConnection * _connection = (connection); \ + NMConnection *_connection = (connection); \ NMConnectionPrivate *_priv; \ \ if (G_LIKELY(NM_IS_SIMPLE_CONNECTION(_connection))) \ @@ -215,8 +215,8 @@ static void _nm_connection_add_setting(NMConnection *connection, NMSetting *setting) { const NMMetaSettingInfo *setting_info; - NMConnectionPrivate * priv; - NMSetting * s_old; + NMConnectionPrivate *priv; + NMSetting *s_old; nm_assert(NM_IS_CONNECTION(connection)); nm_assert(NM_IS_SETTING(setting)); @@ -264,8 +264,8 @@ nm_connection_add_setting(NMConnection *connection, NMSetting *setting) gboolean _nm_connection_remove_setting(NMConnection *connection, GType setting_type) { - NMConnectionPrivate * priv; - NMSetting * setting; + NMConnectionPrivate *priv; + NMSetting *setting; const NMMetaSettingInfo *setting_info; g_return_val_if_fail(NM_IS_CONNECTION(connection), FALSE); @@ -302,7 +302,7 @@ nm_connection_remove_setting(NMConnection *connection, GType setting_type) static gpointer _connection_get_setting(NMConnection *connection, GType setting_type) { - NMSetting * setting; + NMSetting *setting; const NMMetaSettingInfo *setting_info; nm_assert(NM_IS_CONNECTION(connection)); @@ -399,8 +399,8 @@ nm_connection_get_setting_by_name(NMConnection *connection, const char *name) gpointer /* (NMSetting *) */ _nm_connection_check_main_setting(NMConnection *connection, - const char * setting_name, - GError ** error) + const char *setting_name, + GError **error) { NMSetting *setting; @@ -498,16 +498,16 @@ _auto_settings(NMSetting ***p_settings) * are lost. **/ gboolean -_nm_connection_replace_settings(NMConnection * connection, - GVariant * new_settings, +_nm_connection_replace_settings(NMConnection *connection, + GVariant *new_settings, NMSettingParseFlags parse_flags, - GError ** error) + GError **error) { - NMSetting * settings[_NM_META_SETTING_TYPE_NUM] = {}; + NMSetting *settings[_NM_META_SETTING_TYPE_NUM] = {}; nm_auto(_auto_settings) NMSetting **settings_cleanup = settings; GVariantIter iter; - const char * setting_name; - GVariant * setting_dict; + const char *setting_name; + GVariant *setting_dict; gboolean changed; gboolean success; guint n_settings = 0; @@ -528,9 +528,9 @@ _nm_connection_replace_settings(NMConnection * connection, g_variant_iter_init(&iter, new_settings); while (g_variant_iter_next(&iter, "{&s@a{sv}}", &setting_name, &setting_dict)) { gs_unref_variant GVariant *setting_dict_free = NULL; - GError * local = NULL; - NMSetting * setting; - const NMMetaSettingInfo * setting_info; + GError *local = NULL; + NMSetting *setting; + const NMMetaSettingInfo *setting_info; setting_dict_free = setting_dict; @@ -748,11 +748,11 @@ nm_connection_compare(NMConnection *a, NMConnection *b, NMSettingCompareFlags fl } static gboolean -diff_one_connection(NMConnection * a, - NMConnection * b, +diff_one_connection(NMConnection *a, + NMConnection *b, NMSettingCompareFlags flags, gboolean invert_results, - GHashTable * diffs) + GHashTable *diffs) { NMConnectionPrivate *a_priv = NM_CONNECTION_GET_PRIVATE(a); NMConnectionPrivate *b_priv = b ? NM_CONNECTION_GET_PRIVATE(b) : NULL; @@ -763,7 +763,7 @@ diff_one_connection(NMConnection * a, NMSetting *a_setting = a_priv->settings[i]; if (a_setting) { - NMSetting * b_setting = b ? b_priv->settings[i] : NULL; + NMSetting *b_setting = b ? b_priv->settings[i] : NULL; const char *setting_name = nm_setting_get_name(a_setting); GHashTable *results; gboolean new_results = TRUE; @@ -803,10 +803,10 @@ diff_one_connection(NMConnection * a, * not **/ gboolean -nm_connection_diff(NMConnection * a, - NMConnection * b, +nm_connection_diff(NMConnection *a, + NMConnection *b, NMSettingCompareFlags flags, - GHashTable ** out_settings) + GHashTable **out_settings) { GHashTable *diffs; gboolean diff_found = FALSE; @@ -845,12 +845,12 @@ NMSetting * _nm_connection_find_base_type_setting(NMConnection *connection) { NMConnectionPrivate *priv = NM_CONNECTION_GET_PRIVATE(connection); - NMSetting * setting = NULL; + NMSetting *setting = NULL; NMSettingPriority setting_prio = NM_SETTING_PRIORITY_USER; int i; for (i = 0; i < (int) _NM_META_SETTING_TYPE_NUM; i++) { - NMSetting * s_iter = priv->settings[i]; + NMSetting *s_iter = priv->settings[i]; NMSettingPriority s_iter_prio; if (!s_iter) @@ -865,7 +865,7 @@ _nm_connection_find_base_type_setting(NMConnection *connection) continue; } else if (s_iter_prio == setting_prio) { NMSettingConnection *s_con = nm_connection_get_setting_connection(connection); - const char * type; + const char *type; if (s_con) { type = nm_setting_connection_get_connection_type(s_con); @@ -886,7 +886,7 @@ _normalize_connection_uuid(NMConnection *self) { NMSettingConnection *s_con = nm_connection_get_setting_connection(self); char uuid_normalized[37]; - const char * uuid; + const char *uuid; nm_assert(s_con); @@ -942,7 +942,7 @@ _nm_setting_connection_verify_secondaries(GArray *secondaries, GError **error) if (len > 1) { gs_free const char **strv_to_free = NULL; - const char ** strv2; + const char **strv2; strv2 = nm_strv_dup_shallow_maybe_a(20, strv, len, &strv_to_free); nm_strv_sort(strv2, len); @@ -979,8 +979,8 @@ static gboolean _normalize_connection_secondaries(NMConnection *self) { NMSettingConnection *s_con = nm_connection_get_setting_connection(self); - GArray * secondaries; - gs_strfreev char ** strv = NULL; + GArray *secondaries; + gs_strfreev char **strv = NULL; guint i; guint j; @@ -1017,8 +1017,8 @@ static gboolean _normalize_connection_type(NMConnection *self) { NMSettingConnection *s_con = nm_connection_get_setting_connection(self); - NMSetting * s_base = NULL; - const char * type; + NMSetting *s_base = NULL; + const char *type; type = nm_setting_connection_get_connection_type(s_con); @@ -1066,12 +1066,12 @@ const char * _nm_connection_detect_slave_type(NMConnection *connection, NMSetting **out_s_port) { NMConnectionPrivate *priv = NM_CONNECTION_GET_PRIVATE(connection); - const char * slave_type = NULL; - NMSetting * s_port = NULL; + const char *slave_type = NULL; + NMSetting *s_port = NULL; int i; static const struct { NMMetaSettingType meta_type; - const char * controller_type_name; + const char *controller_type_name; } infos[] = { {NM_META_SETTING_TYPE_BRIDGE_PORT, NM_SETTING_BRIDGE_SETTING_NAME}, {NM_META_SETTING_TYPE_BOND_PORT, NM_SETTING_BOND_SETTING_NAME}, @@ -1105,7 +1105,7 @@ static gboolean _normalize_connection_slave_type(NMConnection *self) { NMSettingConnection *s_con = nm_connection_get_setting_connection(self); - const char * slave_type, *port_type; + const char *slave_type, *port_type; if (!s_con) return FALSE; @@ -1177,7 +1177,7 @@ _normalize_ethernet_link_neg(NMConnection *self) static gboolean _supports_addr_family(NMConnection *self, int family) { - const char * connection_type = nm_connection_get_connection_type(self); + const char *connection_type = nm_connection_get_connection_type(self); NMSettingConnection *s_con; g_return_val_if_fail(connection_type, TRUE); @@ -1198,8 +1198,8 @@ static gboolean _normalize_ip_config(NMConnection *self, GHashTable *parameters) { NMSettingIPConfig *s_ip4, *s_ip6; - NMSettingProxy * s_proxy; - NMSetting * setting; + NMSettingProxy *s_proxy; + NMSetting *setting; gboolean changed = FALSE; guint num, i; @@ -1397,7 +1397,7 @@ _normalize_bond_options(NMConnection *self) { NMSettingBond *s_bond = nm_connection_get_setting_bond(self); gboolean changed = FALSE; - const char * name, *mode_str; + const char *name, *mode_str; NMBondMode mode; guint32 num, i; @@ -1425,8 +1425,8 @@ again: static gboolean _normalize_wireless_mac_address_randomization(NMConnection *self) { - NMSettingWireless * s_wifi = nm_connection_get_setting_wireless(self); - const char * cloned_mac_address; + NMSettingWireless *s_wifi = nm_connection_get_setting_wireless(self); + const char *cloned_mac_address; NMSettingMacRandomization mac_address_randomization; if (!s_wifi) @@ -1645,7 +1645,7 @@ static gboolean _normalize_required_settings(NMConnection *self) { NMSettingBluetooth *s_bt = nm_connection_get_setting_bluetooth(self); - NMSetting * s_bridge; + NMSetting *s_bridge; gboolean changed = FALSE; if (nm_connection_get_setting_vlan(self)) { @@ -1671,7 +1671,7 @@ static gboolean _normalize_invalid_slave_port_settings(NMConnection *self) { NMSettingConnection *s_con = nm_connection_get_setting_connection(self); - const char * slave_type; + const char *slave_type; gboolean changed = FALSE; slave_type = nm_setting_connection_get_slave_type(s_con); @@ -1725,10 +1725,10 @@ nm_connection_verify(NMConnection *connection, GError **error) NMSettingVerifyResult _nm_connection_verify(NMConnection *connection, GError **error) { - NMConnectionPrivate *priv; - NMSettingIPConfig * s_ip4; - NMSettingIPConfig * s_ip6; - NMSettingProxy * s_proxy; + NMConnectionPrivate *priv; + NMSettingIPConfig *s_ip4; + NMSettingIPConfig *s_ip6; + NMSettingProxy *s_proxy; gs_free_error GError *normalizable_error = NULL; NMSettingVerifyResult normalizable_error_type = NM_SETTING_VERIFY_SUCCESS; int i; @@ -1748,8 +1748,8 @@ _nm_connection_verify(NMConnection *connection, GError **error) } for (i = 0; i < (int) _NM_META_SETTING_TYPE_NUM; i++) { - NMSetting * setting = priv->settings[nm_meta_setting_types_by_priority[i]]; - GError * verify_error = NULL; + NMSetting *setting = priv->settings[nm_meta_setting_types_by_priority[i]]; + GError *verify_error = NULL; NMSettingVerifyResult verify_result; if (!setting) @@ -1909,9 +1909,9 @@ nm_connection_verify_secrets(NMConnection *connection, GError **error) static gboolean _connection_normalize(NMConnection *connection, - GHashTable * parameters, - gboolean * modified, - GError ** error) + GHashTable *parameters, + gboolean *modified, + GError **error) { NMSettingVerifyResult success; gboolean was_modified; @@ -2006,9 +2006,9 @@ _connection_normalize(NMConnection *connection, **/ gboolean nm_connection_normalize(NMConnection *connection, - GHashTable * parameters, - gboolean * modified, - GError ** error) + GHashTable *parameters, + gboolean *modified, + GError **error) { NMSettingVerifyResult success; gs_free_error GError *normalizable_error = NULL; @@ -2044,16 +2044,16 @@ nm_connection_normalize(NMConnection *connection, } gboolean -_nm_connection_ensure_normalized(NMConnection * connection, +_nm_connection_ensure_normalized(NMConnection *connection, gboolean allow_modify, - const char * expected_uuid, + const char *expected_uuid, gboolean coerce_uuid, NMConnection **out_connection_clone, - GError ** error) + GError **error) { gs_unref_object NMConnection *connection_clone = NULL; - gs_free_error GError *local = NULL; - NMSettingVerifyResult vresult; + gs_free_error GError *local = NULL; + NMSettingVerifyResult vresult; nm_assert(NM_IS_CONNECTION(connection)); nm_assert(!out_connection_clone || !*out_connection_clone); @@ -2122,7 +2122,7 @@ _nm_assert_connection_unchanging_changed_cb(NMConnection *connection, gpointer u static void _nm_assert_connection_unchanging_secrets_updated_cb(NMConnection *connection, - const char * setting_name, + const char *setting_name, gpointer user_data) { nm_assert_not_reached(); @@ -2187,16 +2187,16 @@ nm_assert_connection_unchanging(NMConnection *connection) **/ gboolean nm_connection_update_secrets(NMConnection *connection, - const char * setting_name, - GVariant * secrets, - GError ** error) + const char *setting_name, + GVariant *secrets, + GError **error) { - NMSetting * setting; + NMSetting *setting; gboolean success = TRUE; gboolean updated = FALSE; - GVariant * setting_dict = NULL; + GVariant *setting_dict = NULL; GVariantIter iter; - const char * key; + const char *key; gboolean full_connection; int success_detail; @@ -2320,7 +2320,7 @@ nm_connection_update_secrets(NMConnection *connection, const char * nm_connection_need_secrets(NMConnection *connection, GPtrArray **hints) { - NMSetting * setting_before = NULL; + NMSetting *setting_before = NULL; NMConnectionPrivate *priv; int i; @@ -2380,7 +2380,7 @@ nm_connection_clear_secrets(NMConnection *connection) * Clears and frees secrets determined by @func. **/ void -nm_connection_clear_secrets_with_flags(NMConnection * connection, +nm_connection_clear_secrets_with_flags(NMConnection *connection, NMSettingClearSecretsWithFlagsFn func, gpointer user_data) { @@ -2406,8 +2406,8 @@ nm_connection_clear_secrets_with_flags(NMConnection * connecti } static gboolean -_clear_secrets_by_secret_flags_cb(NMSetting * setting, - const char * secret, +_clear_secrets_by_secret_flags_cb(NMSetting *setting, + const char *secret, NMSettingSecretFlags flags, gpointer user_data) { @@ -2454,8 +2454,8 @@ _nm_connection_clear_secrets_by_secret_flags(NMConnection *self, NMSettingSecret /* Returns always a non-NULL, floating variant that must * be unrefed by the caller. */ GVariant * -_nm_connection_for_each_secret(NMConnection * self, - GVariant * secrets, +_nm_connection_for_each_secret(NMConnection *self, + GVariant *secrets, gboolean remove_non_secrets, _NMConnectionForEachSecretFunc callback, gpointer callback_data) @@ -2463,8 +2463,8 @@ _nm_connection_for_each_secret(NMConnection * self, GVariantBuilder secrets_builder; GVariantBuilder setting_builder; GVariantIter secrets_iter; - GVariantIter * setting_iter; - const char * setting_name; + GVariantIter *setting_iter; + const char *setting_name; /* This function, given a dict of dicts representing new secrets of * an NMConnection, walks through each toplevel dict (which represents a @@ -2486,9 +2486,9 @@ _nm_connection_for_each_secret(NMConnection * self, g_variant_builder_init(&secrets_builder, NM_VARIANT_TYPE_CONNECTION); while (g_variant_iter_next(&secrets_iter, "{&sa{sv}}", &setting_name, &setting_iter)) { _nm_unused nm_auto_free_variant_iter GVariantIter *setting_iter_free = setting_iter; - NMSetting * setting; - const char * secret_name; - GVariant * val; + NMSetting *setting; + const char *secret_name; + GVariant *val; setting = nm_connection_get_setting_by_name(self, setting_name); if (!setting) @@ -2532,16 +2532,16 @@ find_secret_for_each_func(NMSettingSecretFlags flags, gpointer user_data) } gboolean -_nm_connection_find_secret(NMConnection * self, - GVariant * secrets, +_nm_connection_find_secret(NMConnection *self, + GVariant *secrets, NMConnectionFindSecretFunc callback, gpointer callback_data) { gs_unref_variant GVariant *dummy = NULL; FindSecretData data = { - .find_func = callback, - .find_func_data = callback_data, - .found = FALSE, + .find_func = callback, + .find_func_data = callback_data, + .found = FALSE, }; dummy = _nm_connection_for_each_secret(self, secrets, FALSE, find_secret_for_each_func, &data); @@ -2600,7 +2600,7 @@ nm_connection_to_dbus(NMConnection *connection, NMConnectionSerializationFlags f } GVariant * -nm_connection_to_dbus_full(NMConnection * connection, +nm_connection_to_dbus_full(NMConnection *connection, NMConnectionSerializationFlags flags, const NMConnectionSerializationOptions *options) { @@ -2618,7 +2618,7 @@ nm_connection_to_dbus_full(NMConnection * connection, for (i = 0; i < (int) _NM_META_SETTING_TYPE_NUM; i++) { NMSetting *setting = priv->settings[nm_meta_setting_types_by_priority[i]]; - GVariant * setting_dict; + GVariant *setting_dict; if (!setting) continue; @@ -2702,7 +2702,7 @@ NMSetting ** nm_connection_get_settings(NMConnection *connection, guint *out_length) { NMConnectionPrivate *priv; - NMSetting ** arr; + NMSetting **arr; int len; int i; int j; @@ -2746,7 +2746,7 @@ nm_connection_get_settings(NMConnection *connection, guint *out_length) * calling the supplied user function for each property. **/ void -nm_connection_for_each_setting_value(NMConnection * connection, +nm_connection_for_each_setting_value(NMConnection *connection, NMSettingValueIterFn func, gpointer user_data) { @@ -2931,7 +2931,7 @@ nm_connection_get_interface_name(NMConnection *connection) NMConnectionMultiConnect _nm_connection_get_multi_connect(NMConnection *connection) { - NMSettingConnection * s_con; + NMSettingConnection *s_con; NMConnectionMultiConnect multi_connect; const NMConnectionMultiConnect DEFAULT = NM_CONNECTION_MULTI_CONNECT_SINGLE; diff --git a/src/libnm-core-impl/nm-crypto-gnutls.c b/src/libnm-core-impl/nm-crypto-gnutls.c index 88b123ad..d9e59136 100644 --- a/src/libnm-core-impl/nm-crypto-gnutls.c +++ b/src/libnm-core-impl/nm-crypto-gnutls.c @@ -68,14 +68,14 @@ _nm_crypto_init(GError **error) guint8 * _nmtst_crypto_decrypt(NMCryptoCipherType cipher, - const guint8 * data, + const guint8 *data, gsize data_len, - const guint8 * iv, + const guint8 *iv, gsize iv_len, - const guint8 * key, + const guint8 *key, gsize key_len, - gsize * out_len, - GError ** error) + gsize *out_len, + GError **error) { gnutls_cipher_hd_t ctx; gnutls_datum_t key_dt, iv_dt; @@ -168,14 +168,14 @@ _nmtst_crypto_decrypt(NMCryptoCipherType cipher, guint8 * _nmtst_crypto_encrypt(NMCryptoCipherType cipher, - const guint8 * data, + const guint8 *data, gsize data_len, - const guint8 * iv, + const guint8 *iv, gsize iv_len, - const guint8 * key, + const guint8 *key, gsize key_len, - gsize * out_len, - GError ** error) + gsize *out_len, + GError **error) { gnutls_cipher_hd_t ctx; gnutls_datum_t key_dt, iv_dt; @@ -350,8 +350,8 @@ gboolean _nm_crypto_verify_pkcs8(const guint8 *data, gsize data_len, gboolean is_encrypted, - const char * password, - GError ** error) + const char *password, + GError **error) { gnutls_x509_privkey_t p8; gnutls_datum_t dt; diff --git a/src/libnm-core-impl/nm-crypto-impl.h b/src/libnm-core-impl/nm-crypto-impl.h index 0fd8f194..61c3f7f8 100644 --- a/src/libnm-core-impl/nm-crypto-impl.h +++ b/src/libnm-core-impl/nm-crypto-impl.h @@ -21,29 +21,29 @@ _nm_crypto_verify_pkcs12(const guint8 *data, gsize data_len, const char *passwor gboolean _nm_crypto_verify_pkcs8(const guint8 *data, gsize data_len, gboolean is_encrypted, - const char * password, - GError ** error); + const char *password, + GError **error); /*****************************************************************************/ guint8 *_nmtst_crypto_encrypt(NMCryptoCipherType cipher, - const guint8 * data, + const guint8 *data, gsize data_len, - const guint8 * iv, + const guint8 *iv, gsize iv_len, - const guint8 * key, + const guint8 *key, gsize key_len, - gsize * out_len, - GError ** error); + gsize *out_len, + GError **error); guint8 *_nmtst_crypto_decrypt(NMCryptoCipherType cipher, - const guint8 * data, + const guint8 *data, gsize data_len, - const guint8 * iv, + const guint8 *iv, gsize iv_len, - const guint8 * key, + const guint8 *key, gsize key_len, - gsize * out_len, - GError ** error); + gsize *out_len, + GError **error); #endif /* __NM_CRYPTO_IMPL_H__ */ diff --git a/src/libnm-core-impl/nm-crypto-nss.c b/src/libnm-core-impl/nm-crypto-nss.c index e59a11b9..c27bf09e 100644 --- a/src/libnm-core-impl/nm-crypto-nss.c +++ b/src/libnm-core-impl/nm-crypto-nss.c @@ -28,7 +28,7 @@ NM_PRAGMA_WARNING_REENABLE static gboolean _get_cipher_info(NMCryptoCipherType cipher, CK_MECHANISM_TYPE *out_cipher_mech, - guint8 * out_real_iv_len) + guint8 *out_real_iv_len) { static const CK_MECHANISM_TYPE cipher_mechs[] = { [NM_CRYPTO_CIPHER_DES_EDE3_CBC] = CKM_DES3_CBC_PAD, @@ -87,21 +87,21 @@ _nm_crypto_init(GError **error) guint8 * _nmtst_crypto_decrypt(NMCryptoCipherType cipher, - const guint8 * data, + const guint8 *data, gsize data_len, - const guint8 * iv, + const guint8 *iv, gsize iv_len, - const guint8 * key, + const guint8 *key, gsize key_len, - gsize * out_len, - GError ** error) + gsize *out_len, + GError **error) { CK_MECHANISM_TYPE cipher_mech; - PK11SlotInfo * slot = NULL; + PK11SlotInfo *slot = NULL; SECItem key_item; - PK11SymKey * sym_key = NULL; - SECItem * sec_param = NULL; - PK11Context * ctx = NULL; + PK11SymKey *sym_key = NULL; + SECItem *sec_param = NULL; + PK11Context *ctx = NULL; nm_auto_clear_secret_ptr NMSecretPtr output = {0}; SECStatus s; gboolean success = FALSE; @@ -258,23 +258,23 @@ out: guint8 * _nmtst_crypto_encrypt(NMCryptoCipherType cipher, - const guint8 * data, + const guint8 *data, gsize data_len, - const guint8 * iv, + const guint8 *iv, gsize iv_len, - const guint8 * key, + const guint8 *key, gsize key_len, - gsize * out_len, - GError ** error) + gsize *out_len, + GError **error) { SECStatus ret; CK_MECHANISM_TYPE cipher_mech = CKM_DES3_CBC_PAD; - PK11SlotInfo * slot = NULL; + PK11SlotInfo *slot = NULL; SECItem key_item = {.data = (unsigned char *) key, .len = key_len}; SECItem iv_item = {.data = (unsigned char *) iv, .len = iv_len}; - PK11SymKey * sym_key = NULL; - SECItem * sec_param = NULL; - PK11Context * ctx = NULL; + PK11SymKey *sym_key = NULL; + SECItem *sec_param = NULL; + PK11Context *ctx = NULL; nm_auto_clear_secret_ptr NMSecretPtr padded_buf = {0}; nm_auto_clear_secret_ptr NMSecretPtr output = {0}; int encrypted_len = 0, i; @@ -409,7 +409,7 @@ _nm_crypto_verify_pkcs12(const guint8 *data, gsize data_len, const char *passwor { SEC_PKCS12DecoderContext *p12ctx = NULL; SECItem pw = {0}; - PK11SlotInfo * slot = NULL; + PK11SlotInfo *slot = NULL; SECStatus s; gboolean success = FALSE; @@ -513,8 +513,8 @@ gboolean _nm_crypto_verify_pkcs8(const guint8 *data, gsize data_len, gboolean is_encrypted, - const char * password, - GError ** error) + const char *password, + GError **error) { g_return_val_if_fail(data != NULL, FALSE); diff --git a/src/libnm-core-impl/nm-crypto.c b/src/libnm-core-impl/nm-crypto.c index ea17449f..78f793bd 100644 --- a/src/libnm-core-impl/nm-crypto.c +++ b/src/libnm-core-impl/nm-crypto.c @@ -44,9 +44,9 @@ static const NMCryptoCipherInfo cipher_infos[] = { #define _CI(_cipher, _name, _digest_len, _real_iv_len) \ - [(_cipher) -1] = {.cipher = _cipher, \ - .name = ""_name \ - "", \ + [(_cipher) -1] = {.cipher = _cipher, \ + .name = ""_name \ + "", \ .digest_len = _digest_len, \ .real_iv_len = _real_iv_len} _CI(NM_CRYPTO_CIPHER_DES_EDE3_CBC, "DES-EDE3-CBC", 24, 8), @@ -166,26 +166,26 @@ _extract_line(const guint8 **p, const guint8 *p_end) } static gboolean -parse_old_openssl_key_file(const guint8 * data, +parse_old_openssl_key_file(const guint8 *data, gsize data_len, - NMSecretPtr * out_parsed, - NMCryptoKeyType * out_key_type, + NMSecretPtr *out_parsed, + NMCryptoKeyType *out_key_type, NMCryptoCipherType *out_cipher, - char ** out_iv, - GError ** error) + char **out_iv, + GError **error) { gsize start = 0, end = 0; - nm_auto_free_secret char * str = NULL; - char * str_p; + nm_auto_free_secret char *str = NULL; + char *str_p; gsize str_len; int enc_tags = 0; NMCryptoKeyType key_type; nm_auto_clear_secret_ptr NMSecretPtr parsed = {0}; - nm_auto_free_secret char * iv = NULL; + nm_auto_free_secret char *iv = NULL; NMCryptoCipherType cipher = NM_CRYPTO_CIPHER_UNKNOWN; - const char * start_tag; - const char * end_tag; - const guint8 * data_start, *data_end; + const char *start_tag; + const char *end_tag; + const guint8 *data_start, *data_end; nm_assert(!out_parsed || (out_parsed->len == 0 && !out_parsed->bin)); nm_assert(!out_iv || !*out_iv); @@ -229,7 +229,7 @@ parse_old_openssl_key_file(const guint8 * data, while (data_start < data_end) { nm_auto_free_secret char *line = NULL; - char * p; + char *p; line = _extract_line(&data_start, data_end); if (!line) @@ -257,7 +257,7 @@ parse_old_openssl_key_file(const guint8 * data, } } else if (!strncmp(p, DEK_INFO_TAG, strlen(DEK_INFO_TAG))) { const NMCryptoCipherInfo *cipher_info; - char * comma; + char *comma; gsize p_len; if (enc_tags++ != 1 || str_p != str) { @@ -335,12 +335,12 @@ parse_old_openssl_key_file(const guint8 * data, static gboolean parse_pkcs8_key_file(const guint8 *data, gsize data_len, - NMSecretPtr * parsed, - gboolean * out_encrypted, - GError ** error) + NMSecretPtr *parsed, + gboolean *out_encrypted, + GError **error) { gsize start = 0, end = 0; - const char * start_tag = NULL, *end_tag = NULL; + const char *start_tag = NULL, *end_tag = NULL; gboolean encrypted = FALSE; nm_auto_free_secret char *der_base64 = NULL; @@ -396,8 +396,8 @@ parse_pkcs8_key_file(const guint8 *data, static gboolean parse_tpm2_wrapped_key_file(const guint8 *data, gsize data_len, - gboolean * out_encrypted, - GError ** error) + gboolean *out_encrypted, + GError **error) { gsize start = 0, end = 0; const char *start_tag = NULL, *end_tag = NULL; @@ -467,7 +467,7 @@ nm_crypto_read_file(const char *filename, GError **error) static guint8 * _nmtst_convert_iv(const char *src, gsize *out_len, GError **error) { - gsize i, num; + gsize i, num; gs_free guint8 *c = NULL; int c0, c1; @@ -508,13 +508,13 @@ _nmtst_convert_iv(const char *src, gsize *out_len, GError **error) guint8 * nmtst_crypto_make_des_aes_key(NMCryptoCipherType cipher, - const guint8 * salt, + const guint8 *salt, gsize salt_len, - const char * password, - gsize * out_len, - GError ** error) + const char *password, + gsize *out_len, + GError **error) { - guint8 * key; + guint8 *key; const NMCryptoCipherInfo *cipher_info; g_return_val_if_fail(salt != NULL, NULL); @@ -546,12 +546,12 @@ nmtst_crypto_make_des_aes_key(NMCryptoCipherType cipher, static gboolean _nmtst_decrypt_key(NMCryptoCipherType cipher, - const guint8 * data, + const guint8 *data, gsize data_len, - const char * iv, - const char * password, - NMSecretPtr * parsed, - GError ** error) + const char *iv, + const char *password, + NMSecretPtr *parsed, + GError **error) { nm_auto_clear_secret_ptr NMSecretPtr bin_iv = {0}; nm_auto_clear_secret_ptr NMSecretPtr key = {0}; @@ -599,15 +599,15 @@ _nmtst_decrypt_key(NMCryptoCipherType cipher, } GBytes * -nmtst_crypto_decrypt_openssl_private_key_data(const guint8 * data, +nmtst_crypto_decrypt_openssl_private_key_data(const guint8 *data, gsize data_len, - const char * password, + const char *password, NMCryptoKeyType *out_key_type, - GError ** error) + GError **error) { NMCryptoKeyType key_type = NM_CRYPTO_KEY_TYPE_UNKNOWN; nm_auto_clear_secret_ptr NMSecretPtr parsed = {0}; - nm_auto_free_secret char * iv = NULL; + nm_auto_free_secret char *iv = NULL; NMCryptoCipherType cipher = NM_CRYPTO_CIPHER_UNKNOWN; g_return_val_if_fail(data != NULL, NULL); @@ -651,10 +651,10 @@ nmtst_crypto_decrypt_openssl_private_key_data(const guint8 * data, } GBytes * -nmtst_crypto_decrypt_openssl_private_key(const char * file, - const char * password, +nmtst_crypto_decrypt_openssl_private_key(const char *file, + const char *password, NMCryptoKeyType *out_key_type, - GError ** error) + GError **error) { nm_auto_clear_secret_ptr NMSecretPtr contents = {0}; @@ -674,8 +674,8 @@ nmtst_crypto_decrypt_openssl_private_key(const char * file, static gboolean extract_pem_cert_data(const guint8 *contents, gsize contents_len, - NMSecretPtr * out_cert, - GError ** error) + NMSecretPtr *out_cert, + GError **error) { gsize start = 0; gsize end = 0; @@ -722,10 +722,10 @@ extract_pem_cert_data(const guint8 *contents, } gboolean -nm_crypto_load_and_verify_certificate(const char * file, +nm_crypto_load_and_verify_certificate(const char *file, NMCryptoFileFormat *out_file_format, - GBytes ** out_certificate, - GError ** error) + GBytes **out_certificate, + GError **error) { nm_auto_clear_secret_ptr NMSecretPtr contents = {0}; @@ -786,7 +786,7 @@ out: gboolean nm_crypto_is_pkcs12_data(const guint8 *data, gsize data_len, GError **error) { - GError * local = NULL; + GError *local = NULL; gboolean success; if (!data_len) { @@ -838,9 +838,9 @@ nm_crypto_is_pkcs12_file(const char *file, GError **error) NMCryptoFileFormat nm_crypto_verify_private_key_data(const guint8 *data, gsize data_len, - const char * password, - gboolean * out_is_encrypted, - GError ** error) + const char *password, + gboolean *out_is_encrypted, + GError **error) { NMCryptoFileFormat format = NM_CRYPTO_FILE_FORMAT_UNKNOWN; gboolean is_encrypted = FALSE; @@ -894,8 +894,8 @@ nm_crypto_verify_private_key_data(const guint8 *data, NMCryptoFileFormat nm_crypto_verify_private_key(const char *filename, const char *password, - gboolean * out_is_encrypted, - GError ** error) + gboolean *out_is_encrypted, + GError **error) { nm_auto_clear_secret_ptr NMSecretPtr contents = {0}; @@ -939,21 +939,21 @@ nm_crypto_randomize(void *buffer, gsize buffer_len, GError **error) GBytes * nmtst_crypto_rsa_key_encrypt(const guint8 *data, gsize len, - const char * in_password, - char ** out_password, - GError ** error) + const char *in_password, + char **out_password, + GError **error) { guint8 salt[8]; - nm_auto_clear_secret_ptr NMSecretPtr key = {0}; - nm_auto_clear_secret_ptr NMSecretPtr enc = {0}; - gs_unref_ptrarray GPtrArray *pem = NULL; - nm_auto_free_secret char * tmp_password = NULL; - nm_auto_free_secret char * enc_base64 = NULL; - gsize enc_base64_len; - const char * p; - gsize ret_len, ret_idx; - guint i; - NMSecretBuf * ret; + nm_auto_clear_secret_ptr NMSecretPtr key = {0}; + nm_auto_clear_secret_ptr NMSecretPtr enc = {0}; + gs_unref_ptrarray GPtrArray *pem = NULL; + nm_auto_free_secret char *tmp_password = NULL; + nm_auto_free_secret char *enc_base64 = NULL; + gsize enc_base64_len; + const char *p; + gsize ret_len, ret_idx; + guint i; + NMSecretBuf *ret; g_return_val_if_fail(data, NULL); g_return_val_if_fail(len > 0, NULL); diff --git a/src/libnm-core-impl/nm-crypto.h b/src/libnm-core-impl/nm-crypto.h index 855e4f9c..a740c43c 100644 --- a/src/libnm-core-impl/nm-crypto.h +++ b/src/libnm-core-impl/nm-crypto.h @@ -17,7 +17,7 @@ typedef enum { } NMCryptoCipherType; typedef struct { - const char * name; + const char *name; NMCryptoCipherType cipher; guint8 digest_len; guint8 real_iv_len; @@ -43,10 +43,10 @@ typedef enum { GBytes *nm_crypto_read_file(const char *filename, GError **error); -gboolean nm_crypto_load_and_verify_certificate(const char * file, +gboolean nm_crypto_load_and_verify_certificate(const char *file, NMCryptoFileFormat *out_file_format, - GBytes ** out_certificat, - GError ** error); + GBytes **out_certificat, + GError **error); gboolean nm_crypto_is_pkcs12_file(const char *file, GError **error); @@ -54,42 +54,42 @@ gboolean nm_crypto_is_pkcs12_data(const guint8 *data, gsize len, GError **error) NMCryptoFileFormat nm_crypto_verify_private_key_data(const guint8 *data, gsize data_len, - const char * password, - gboolean * out_is_encrypted, - GError ** error); + const char *password, + gboolean *out_is_encrypted, + GError **error); NMCryptoFileFormat nm_crypto_verify_private_key(const char *file, const char *password, - gboolean * out_is_encrypted, - GError ** error); + gboolean *out_is_encrypted, + GError **error); gboolean nm_crypto_randomize(void *buffer, gsize buffer_len, GError **error); /*****************************************************************************/ -GBytes *nmtst_crypto_decrypt_openssl_private_key_data(const guint8 * data, +GBytes *nmtst_crypto_decrypt_openssl_private_key_data(const guint8 *data, gsize data_len, - const char * password, + const char *password, NMCryptoKeyType *out_key_type, - GError ** error); + GError **error); -GBytes *nmtst_crypto_decrypt_openssl_private_key(const char * file, - const char * password, +GBytes *nmtst_crypto_decrypt_openssl_private_key(const char *file, + const char *password, NMCryptoKeyType *out_key_type, - GError ** error); + GError **error); GBytes *nmtst_crypto_rsa_key_encrypt(const guint8 *data, gsize len, - const char * in_password, - char ** out_password, - GError ** error); + const char *in_password, + char **out_password, + GError **error); guint8 *nmtst_crypto_make_des_aes_key(NMCryptoCipherType cipher, - const guint8 * salt, + const guint8 *salt, gsize salt_len, - const char * password, - gsize * out_len, - GError ** error); + const char *password, + gsize *out_len, + GError **error); /*****************************************************************************/ diff --git a/src/libnm-core-impl/nm-dbus-utils.c b/src/libnm-core-impl/nm-dbus-utils.c index a272f08c..c9443ff9 100644 --- a/src/libnm-core-impl/nm-dbus-utils.c +++ b/src/libnm-core-impl/nm-dbus-utils.c @@ -8,7 +8,7 @@ #include "libnm-core-intern/nm-core-internal.h" typedef struct { - char * signal_name; + char *signal_name; const GVariantType *signature; } NMDBusSignalData; @@ -22,17 +22,17 @@ dbus_signal_data_free(gpointer data, GClosure *closure) } static void -dbus_signal_meta_marshal(GClosure * closure, - GValue * return_value, +dbus_signal_meta_marshal(GClosure *closure, + GValue *return_value, guint n_param_values, const GValue *param_values, gpointer invocation_hint, gpointer marshal_data) { NMDBusSignalData *sd = marshal_data; - const char * signal_name; - GVariant * parameters, *param; - GValue * closure_params; + const char *signal_name; + GVariant *parameters, *param; + GValue *closure_params; gsize n_params, i; g_return_if_fail(n_param_values == 4); @@ -110,8 +110,8 @@ dbus_signal_meta_marshal(GClosure * closure, * g_signal_handlers_disconnect_by_data() will work correctly. */ gulong -_nm_dbus_signal_connect_data(GDBusProxy * proxy, - const char * signal_name, +_nm_dbus_signal_connect_data(GDBusProxy *proxy, + const char *signal_name, const GVariantType *signature, GCallback c_handler, gpointer data, @@ -119,7 +119,7 @@ _nm_dbus_signal_connect_data(GDBusProxy * proxy, GConnectFlags connect_flags) { NMDBusSignalData *sd; - GClosure * closure; + GClosure *closure; gboolean swapped = !!(connect_flags & G_CONNECT_SWAPPED); gboolean after = !!(connect_flags & G_CONNECT_AFTER); @@ -201,10 +201,10 @@ _nm_dbus_typecheck_response(GVariant *response, const GVariantType *reply_type, * return values. Free with g_variant_unref(). */ GVariant * -_nm_dbus_proxy_call_finish(GDBusProxy * proxy, - GAsyncResult * res, +_nm_dbus_proxy_call_finish(GDBusProxy *proxy, + GAsyncResult *res, const GVariantType *reply_type, - GError ** error) + GError **error) { GVariant *variant; @@ -215,10 +215,10 @@ _nm_dbus_proxy_call_finish(GDBusProxy * proxy, } GVariant * -_nm_dbus_connection_call_finish(GDBusConnection * dbus_connection, - GAsyncResult * result, +_nm_dbus_connection_call_finish(GDBusConnection *dbus_connection, + GAsyncResult *result, const GVariantType *reply_type, - GError ** error) + GError **error) { GVariant *variant; diff --git a/src/libnm-core-impl/nm-keyfile-utils.c b/src/libnm-core-impl/nm-keyfile-utils.c index f8c2f387..0e2e2d45 100644 --- a/src/libnm-core-impl/nm-keyfile-utils.c +++ b/src/libnm-core-impl/nm-keyfile-utils.c @@ -107,15 +107,15 @@ nm_keyfile_plugin_get_setting_name_for_alias(const char *alias) /*****************************************************************************/ char ** -nm_keyfile_plugin_kf_get_string_list(GKeyFile * kf, +nm_keyfile_plugin_kf_get_string_list(GKeyFile *kf, const char *group, const char *key, - gsize * out_length, - GError ** error) + gsize *out_length, + GError **error) { - char ** list; + char **list; const char *alias; - GError * local = NULL; + GError *local = NULL; gsize l; list = g_key_file_get_string_list(kf, group, key, &l, &local); @@ -135,16 +135,16 @@ nm_keyfile_plugin_kf_get_string_list(GKeyFile * kf, } guint * -nm_keyfile_plugin_kf_get_integer_list_uint(GKeyFile * key_file, +nm_keyfile_plugin_kf_get_integer_list_uint(GKeyFile *key_file, const char *group_name, const char *key, - gsize * out_length, - GError ** error) + gsize *out_length, + GError **error) { - GError * key_file_error = NULL; + GError *key_file_error = NULL; gs_strfreev char **values = NULL; - gs_free guint *int_values = NULL; - gsize i, num_ints; + gs_free guint *int_values = NULL; + gsize i, num_ints; NM_SET_OUT(out_length, 0); @@ -183,9 +183,9 @@ nm_keyfile_plugin_kf_get_integer_list_uint(GKeyFile * key_file, } void -nm_keyfile_plugin_kf_set_string_list(GKeyFile * kf, - const char * group, - const char * key, +nm_keyfile_plugin_kf_set_string_list(GKeyFile *kf, + const char *group, + const char *key, const char *const *list, gsize length) { @@ -196,9 +196,9 @@ nm_keyfile_plugin_kf_set_string_list(GKeyFile * kf, } void -nm_keyfile_plugin_kf_set_integer_list_uint(GKeyFile * kf, - const char * group, - const char * key, +nm_keyfile_plugin_kf_set_integer_list_uint(GKeyFile *kf, + const char *group, + const char *key, const guint *data, gsize length) { @@ -217,9 +217,9 @@ nm_keyfile_plugin_kf_set_integer_list_uint(GKeyFile * kf, } void -nm_keyfile_plugin_kf_set_integer_list_uint8(GKeyFile * kf, - const char * group, - const char * key, +nm_keyfile_plugin_kf_set_integer_list_uint8(GKeyFile *kf, + const char *group, + const char *key, const guint8 *data, gsize length) { @@ -242,7 +242,7 @@ nm_keyfile_plugin_kf_set_integer_list_uint8(GKeyFile * kf, { \ get_ctype val; \ const char *alias; \ - GError * local = NULL; \ + GError *local = NULL; \ \ val = key_file_get_fcn(kf, group, key, &local); \ if (nm_g_error_matches(local, G_KEY_FILE_ERROR, G_KEY_FILE_ERROR_GROUP_NOT_FOUND)) { \ @@ -275,14 +275,14 @@ DEFINE_KF_WRAPPER_SET(nm_keyfile_plugin_kf_set_boolean, gboolean, g_key_file_set DEFINE_KF_WRAPPER_SET(nm_keyfile_plugin_kf_set_value, const char *, g_key_file_set_value); gint64 -nm_keyfile_plugin_kf_get_int64(GKeyFile * kf, +nm_keyfile_plugin_kf_get_int64(GKeyFile *kf, const char *group, const char *key, guint base, gint64 min, gint64 max, gint64 fallback, - GError ** error) + GError **error) { gs_free char *s = NULL; int errsv; @@ -311,9 +311,9 @@ nm_keyfile_plugin_kf_get_int64(GKeyFile * kf, char ** nm_keyfile_plugin_kf_get_keys(GKeyFile *kf, const char *group, gsize *out_length, GError **error) { - char ** keys; + char **keys; const char *alias; - GError * local = NULL; + GError *local = NULL; gsize l; keys = g_key_file_get_keys(kf, group, &l, &local); @@ -339,7 +339,7 @@ nm_keyfile_plugin_kf_has_key(GKeyFile *kf, const char *group, const char *key, G { gboolean has; const char *alias; - GError * local = NULL; + GError *local = NULL; has = g_key_file_has_key(kf, group, key, &local); if (nm_g_error_matches(local, G_KEY_FILE_ERROR, G_KEY_FILE_ERROR_GROUP_NOT_FOUND)) { @@ -364,7 +364,7 @@ _nm_keyfile_copy(GKeyFile *dst, GKeyFile *src) groups = g_key_file_get_groups(src, NULL); for (g = 0; groups && groups[g]; g++) { - const char * group = groups[g]; + const char *group = groups[g]; gs_strfreev char **keys = NULL; keys = g_key_file_get_keys(src, group, NULL, NULL); @@ -372,7 +372,7 @@ _nm_keyfile_copy(GKeyFile *dst, GKeyFile *src) continue; for (k = 0; keys[k]; k++) { - const char * key = keys[k]; + const char *key = keys[k]; gs_free char *value = NULL; value = g_key_file_get_value(src, group, key, NULL); @@ -644,7 +644,7 @@ nm_keyfile_key_encode(const char *name, char **out_to_free) nm_assert(!*out_to_free || !nm_streq0(name, key)); { gs_free char *to_free2 = NULL; - const char * name2; + const char *name2; name2 = _keyfile_key_decode(key, &to_free2); /* name2, the result of encode()+decode() is identical to name. @@ -669,7 +669,7 @@ nm_keyfile_key_decode(const char *key, char **out_to_free) nm_assert(!*out_to_free || name == *out_to_free); { gs_free char *to_free2 = NULL; - const char * key2; + const char *key2; key2 = _keyfile_key_encode(name, &to_free2); /* key2, the result of decode+encode may not be identical diff --git a/src/libnm-core-impl/nm-keyfile.c b/src/libnm-core-impl/nm-keyfile.c index 1171ab03..4ff9b582 100644 --- a/src/libnm-core-impl/nm-keyfile.c +++ b/src/libnm-core-impl/nm-keyfile.c @@ -41,22 +41,22 @@ typedef struct _ParseInfoProperty ParseInfoProperty; typedef struct { - NMConnection * connection; - GKeyFile * keyfile; - const char * base_dir; + NMConnection *connection; + GKeyFile *keyfile; + const char *base_dir; NMKeyfileReadHandler read_handler; - void * user_data; - GError * error; - const char * group; - NMSetting * setting; + void *user_data; + GError *error; + const char *group; + NMSetting *setting; } KeyfileReaderInfo; typedef struct { - NMConnection * connection; - GKeyFile * keyfile; - GError * error; + NMConnection *connection; + GKeyFile *keyfile; + GError *error; NMKeyfileWriteHandler write_handler; - void * user_data; + void *user_data; } KeyfileWriterInfo; /*****************************************************************************/ @@ -64,11 +64,11 @@ typedef struct { static void _key_file_handler_data_init(NMKeyfileHandlerData *handler_data, NMKeyfileHandlerType handler_type, - const char * kf_group_name, - const char * kf_key, - NMSetting * cur_setting, - const char * cur_property, - GError ** p_error) + const char *kf_group_name, + const char *kf_key, + NMSetting *cur_setting, + const char *cur_property, + GError **p_error) { nm_assert(handler_data); nm_assert(p_error && !*p_error); @@ -84,9 +84,9 @@ _key_file_handler_data_init(NMKeyfileHandlerData *handler_data, static void _key_file_handler_data_init_read(NMKeyfileHandlerData *handler_data, NMKeyfileHandlerType handler_type, - KeyfileReaderInfo * info, - const char * kf_key, - const char * cur_property) + KeyfileReaderInfo *info, + const char *kf_key, + const char *cur_property) { _key_file_handler_data_init(handler_data, handler_type, @@ -100,11 +100,11 @@ _key_file_handler_data_init_read(NMKeyfileHandlerData *handler_data, static void _key_file_handler_data_init_write(NMKeyfileHandlerData *handler_data, NMKeyfileHandlerType handler_type, - KeyfileWriterInfo * info, - const char * kf_group, - const char * kf_key, - NMSetting * cur_setting, - const char * cur_property) + KeyfileWriterInfo *info, + const char *kf_group, + const char *kf_key, + NMSetting *cur_setting, + const char *cur_property) { _key_file_handler_data_init(handler_data, handler_type, @@ -115,11 +115,11 @@ _key_file_handler_data_init_write(NMKeyfileHandlerData *handler_data, &info->error); } -_nm_printf(5, 6) static void _handle_warn(KeyfileReaderInfo * info, - const char * kf_key, - const char * cur_property, +_nm_printf(5, 6) static void _handle_warn(KeyfileReaderInfo *info, + const char *kf_key, + const char *cur_property, NMKeyfileWarnSeverity severity, - const char * fmt, + const char *fmt, ...) { NMKeyfileHandlerData handler_data; @@ -178,8 +178,8 @@ _secret_flags_persist_secret(NMSettingSecretFlags flags) static void setting_alias_parser(KeyfileReaderInfo *info, NMSetting *setting, const char *key) { - const char * setting_name = nm_setting_get_name(setting); - const char * key_setting_name; + const char *setting_name = nm_setting_get_name(setting); + const char *key_setting_name; gs_free char *s = NULL; s = nm_keyfile_plugin_kf_get_string(info->keyfile, setting_name, key, NULL); @@ -193,10 +193,10 @@ setting_alias_parser(KeyfileReaderInfo *info, NMSetting *setting, const char *ke static void sriov_vfs_parser(KeyfileReaderInfo *info, NMSetting *setting, const char *key) { - const char * setting_name = nm_setting_get_name(setting); - gs_unref_ptrarray GPtrArray *vfs = NULL; - gs_strfreev char ** keys = NULL; - gsize n_keys = 0; + const char *setting_name = nm_setting_get_name(setting); + gs_unref_ptrarray GPtrArray *vfs = NULL; + gs_strfreev char **keys = NULL; + gsize n_keys = 0; int i; keys = nm_keyfile_plugin_kf_get_keys(info->keyfile, setting_name, &n_keys, NULL); @@ -207,8 +207,8 @@ sriov_vfs_parser(KeyfileReaderInfo *info, NMSetting *setting, const char *key) for (i = 0; i < n_keys; i++) { gs_free char *value = NULL; - NMSriovVF * vf; - const char * rest; + NMSriovVF *vf; + const char *rest; if (!g_str_has_prefix(keys[i], "vf.")) continue; @@ -232,9 +232,9 @@ static void read_array_of_uint(GKeyFile *file, NMSetting *setting, const char *key) { gs_unref_array GArray *array = NULL; - gs_free_error GError *error = NULL; - gs_free guint *tmp = NULL; - gsize length; + gs_free_error GError *error = NULL; + gs_free guint *tmp = NULL; + gsize length; tmp = nm_keyfile_plugin_kf_get_integer_list_uint(file, nm_setting_get_name(setting), @@ -251,11 +251,11 @@ read_array_of_uint(GKeyFile *file, NMSetting *setting, const char *key) static gboolean get_one_int(KeyfileReaderInfo *info, - const char * kf_key, - const char * property_name, - const char * str, + const char *kf_key, + const char *property_name, + const char *str, guint32 max_val, - guint32 * out) + guint32 *out) { gint64 tmp; @@ -292,14 +292,14 @@ get_one_int(KeyfileReaderInfo *info, static gpointer build_address(KeyfileReaderInfo *info, - const char * kf_key, - const char * property_name, + const char *kf_key, + const char *property_name, int family, - const char * address_str, + const char *address_str, guint32 plen) { NMIPAddress *addr; - GError * error = NULL; + GError *error = NULL; g_return_val_if_fail(address_str, NULL); @@ -320,18 +320,18 @@ build_address(KeyfileReaderInfo *info, static gpointer build_route(KeyfileReaderInfo *info, - const char * kf_key, - const char * property_name, + const char *kf_key, + const char *property_name, int family, - const char * dest_str, + const char *dest_str, guint32 plen, - const char * gateway_str, - const char * metric_str) + const char *gateway_str, + const char *metric_str) { NMIPRoute *route; guint32 u32; gint64 metric = -1; - GError * error = NULL; + GError *error = NULL; g_return_val_if_fail(dest_str, NULL); @@ -455,7 +455,7 @@ read_field(char **current, const char **out_err_str, const char *characters, con static void openconnect_fix_secret_flags(NMSetting *setting) { - NMSettingVpn * s_vpn; + NMSettingVpn *s_vpn; NMSettingSecretFlags flags; /* Huge hack. There were some openconnect changes that needed to happen @@ -518,22 +518,22 @@ openconnect_fix_secret_flags(NMSetting *setting) */ static gpointer read_one_ip_address_or_route(KeyfileReaderInfo *info, - const char * property_name, - const char * setting_name, - const char * kf_key, + const char *property_name, + const char *setting_name, + const char *kf_key, gboolean ipv6, gboolean route, - char ** out_gateway, - NMSetting * setting) + char **out_gateway, + NMSetting *setting) { guint plen; gpointer result; - const char * address_str; - const char * plen_str; - const char * gateway_str; - const char * metric_str; - const char * err_str = NULL; - char * current; + const char *address_str; + const char *plen_str; + const char *gateway_str; + const char *metric_str; + const char *err_str = NULL; + char *current; gs_free char *value = NULL; gs_free char *value_orig = NULL; @@ -680,17 +680,17 @@ read_one_ip_address_or_route(KeyfileReaderInfo *info, } static void -fill_route_attributes(GKeyFile * kf, - NMIPRoute * route, +fill_route_attributes(GKeyFile *kf, + NMIPRoute *route, const char *setting, const char *key, int family) { - gs_free char * value = NULL; - gs_unref_hashtable GHashTable *hash = NULL; + gs_free char *value = NULL; + gs_unref_hashtable GHashTable *hash = NULL; GHashTableIter iter; - char * name; - GVariant * variant; + char *name; + GVariant *variant; value = nm_keyfile_plugin_kf_get_string(kf, setting, key, NULL); if (!value || !value[0]) @@ -751,7 +751,7 @@ static gboolean _build_list_match_key_w_name_impl(const char *key, const char *base_name, gsize base_name_l, - gint32 * out_key_idx) + gint32 *out_key_idx) { gint64 v; @@ -798,14 +798,14 @@ _build_list_match_key_w_name_impl(const char *key, _build_list_match_key_w_name_impl(key, base_name, NM_STRLEN(base_name), out_key_idx) static BuildListData * -_build_list_create(GKeyFile * keyfile, - const char * group_name, +_build_list_create(GKeyFile *keyfile, + const char *group_name, BuildListType build_list_type, - gsize * out_build_list_len, - char *** out_keys_strv) + gsize *out_build_list_len, + char ***out_keys_strv) { - gs_strfreev char **keys = NULL; - gsize i_keys, n_keys; + gs_strfreev char **keys = NULL; + gsize i_keys, n_keys; gs_free BuildListData *build_list = NULL; gsize build_list_len = 0; @@ -878,14 +878,14 @@ _build_list_create(GKeyFile * keyfile, static void ip_address_or_route_parser(KeyfileReaderInfo *info, NMSetting *setting, const char *setting_key) { - const char * setting_name = nm_setting_get_name(setting); - gboolean is_ipv6 = nm_streq(setting_name, "ipv6"); - gboolean is_routes = nm_streq(setting_key, "routes"); - gs_free char * gateway = NULL; - gs_unref_ptrarray GPtrArray *list = NULL; - gs_strfreev char ** keys = NULL; - gs_free BuildListData *build_list = NULL; - gsize i_build_list, build_list_len = 0; + const char *setting_name = nm_setting_get_name(setting); + gboolean is_ipv6 = nm_streq(setting_name, "ipv6"); + gboolean is_routes = nm_streq(setting_key, "routes"); + gs_free char *gateway = NULL; + gs_unref_ptrarray GPtrArray *list = NULL; + gs_strfreev char **keys = NULL; + gs_free BuildListData *build_list = NULL; + gsize i_build_list, build_list_len = 0; build_list = _build_list_create(info->keyfile, setting_name, @@ -940,16 +940,16 @@ ip_address_or_route_parser(KeyfileReaderInfo *info, NMSetting *setting, const ch } static void -ip_routing_rule_parser_full(KeyfileReaderInfo * info, - const NMMetaSettingInfo * setting_info, +ip_routing_rule_parser_full(KeyfileReaderInfo *info, + const NMMetaSettingInfo *setting_info, const NMSettInfoProperty *property_info, - const ParseInfoProperty * pip, - NMSetting * setting) + const ParseInfoProperty *pip, + NMSetting *setting) { - const char * setting_name = nm_setting_get_name(setting); - gboolean is_ipv6 = nm_streq(setting_name, "ipv6"); - gs_strfreev char **keys = NULL; - gs_free BuildListData *build_list = NULL; + const char *setting_name = nm_setting_get_name(setting); + gboolean is_ipv6 = nm_streq(setting_name, "ipv6"); + gs_strfreev char **keys = NULL; + gs_free BuildListData *build_list = NULL; gsize i_build_list, build_list_len = 0; build_list = _build_list_create(info->keyfile, @@ -962,8 +962,8 @@ ip_routing_rule_parser_full(KeyfileReaderInfo * info, for (i_build_list = 0; i_build_list < build_list_len; i_build_list++) { nm_auto_unref_ip_routing_rule NMIPRoutingRule *rule = NULL; - gs_free char * value = NULL; - gs_free_error GError *local = NULL; + gs_free char *value = NULL; + gs_free_error GError *local = NULL; if (_build_list_data_is_shadowed(build_list, build_list_len, i_build_list)) continue; @@ -999,13 +999,13 @@ ip_routing_rule_parser_full(KeyfileReaderInfo * info, } static void -_parser_full_ovs_external_ids_data(KeyfileReaderInfo * info, - const NMMetaSettingInfo * setting_info, +_parser_full_ovs_external_ids_data(KeyfileReaderInfo *info, + const NMMetaSettingInfo *setting_info, const NMSettInfoProperty *property_info, - const ParseInfoProperty * pip, - NMSetting * setting) + const ParseInfoProperty *pip, + NMSetting *setting) { - const char * setting_name = NM_SETTING_OVS_EXTERNAL_IDS_SETTING_NAME; + const char *setting_name = NM_SETTING_OVS_EXTERNAL_IDS_SETTING_NAME; gs_strfreev char **keys = NULL; gsize n_keys; gsize i; @@ -1018,10 +1018,10 @@ _parser_full_ovs_external_ids_data(KeyfileReaderInfo * info, keys = nm_keyfile_plugin_kf_get_keys(info->keyfile, setting_name, &n_keys, NULL); for (i = 0; i < n_keys; i++) { - const char * key = keys[i]; + const char *key = keys[i]; gs_free char *name_to_free = NULL; gs_free char *value = NULL; - const char * name; + const char *name; if (!NM_STR_HAS_PREFIX(key, OVS_EXTERNAL_IDS_DATA_PREFIX)) continue; @@ -1089,8 +1089,8 @@ static void ip6_addr_gen_mode_parser(KeyfileReaderInfo *info, NMSetting *setting, const char *key) { NMSettingIP6ConfigAddrGenMode addr_gen_mode; - const char * setting_name = nm_setting_get_name(setting); - gs_free char * s = NULL; + const char *setting_name = nm_setting_get_name(setting); + gs_free char *s = NULL; s = nm_keyfile_plugin_kf_get_string(info->keyfile, setting_name, key, NULL); if (s) { @@ -1115,17 +1115,17 @@ ip6_addr_gen_mode_parser(KeyfileReaderInfo *info, NMSetting *setting, const char static void mac_address_parser(KeyfileReaderInfo *info, - NMSetting * setting, - const char * key, + NMSetting *setting, + const char *key, gsize addr_len, gboolean cloned_mac_addr) { - const char * setting_name = nm_setting_get_name(setting); - char addr_str[NM_UTILS_HWADDR_LEN_MAX * 3]; - guint8 addr_bin[NM_UTILS_HWADDR_LEN_MAX]; - gs_free char *tmp_string = NULL; - gs_free guint *int_list = NULL; - const char * mac_str; + const char *setting_name = nm_setting_get_name(setting); + char addr_str[NM_UTILS_HWADDR_LEN_MAX * 3]; + guint8 addr_bin[NM_UTILS_HWADDR_LEN_MAX]; + gs_free char *tmp_string = NULL; + gs_free guint *int_list = NULL; + const char *mac_str; gsize int_list_len; gsize i; @@ -1191,13 +1191,13 @@ mac_address_parser_INFINIBAND(KeyfileReaderInfo *info, NMSetting *setting, const static void read_hash_of_string(KeyfileReaderInfo *info, - GKeyFile * file, - NMSetting * setting, - const char * kf_group) + GKeyFile *file, + NMSetting *setting, + const char *kf_group) { gs_strfreev char **keys = NULL; const char *const *iter; - const char * setting_name = nm_setting_get_name(setting); + const char *setting_name = nm_setting_get_name(setting); gboolean is_vpn; gsize n_keys; @@ -1212,10 +1212,10 @@ read_hash_of_string(KeyfileReaderInfo *info, if ((is_vpn = NM_IS_SETTING_VPN(setting)) || NM_IS_SETTING_BOND(setting)) { for (iter = (const char *const *) keys; *iter; iter++) { - const char * kf_key = *iter; + const char *kf_key = *iter; gs_free char *to_free = NULL; gs_free char *value = NULL; - const char * name; + const char *name; value = nm_keyfile_plugin_kf_get_string(file, setting_name, kf_key, NULL); if (!value) @@ -1256,8 +1256,8 @@ read_hash_of_string(KeyfileReaderInfo *info, data = g_hash_table_new_full(nm_str_hash, g_str_equal, g_free, g_free); for (iter = (const char *const *) keys; *iter; iter++) { gs_free char *to_free = NULL; - char * value = NULL; - const char * name; + char *value = NULL; + const char *name; value = nm_keyfile_plugin_kf_get_string(file, setting_name, *iter, NULL); if (!value) @@ -1288,15 +1288,15 @@ unescape_semicolons(char *str) static GBytes * get_bytes(KeyfileReaderInfo *info, - const char * setting_name, - const char * key, + const char *setting_name, + const char *key, gboolean zero_terminate, gboolean unescape_semicolon) { nm_auto_free_secret char *tmp_string = NULL; gboolean may_be_int_list = TRUE; gsize length; - GBytes * result; + GBytes *result; /* New format: just a string * Old format: integer list; e.g. 11;25;38; @@ -1421,8 +1421,8 @@ get_bytes(KeyfileReaderInfo *info, static void ssid_parser(KeyfileReaderInfo *info, NMSetting *setting, const char *key) { - const char * setting_name = nm_setting_get_name(setting); - gs_unref_bytes GBytes *bytes = NULL; + const char *setting_name = nm_setting_get_name(setting); + gs_unref_bytes GBytes *bytes = NULL; bytes = get_bytes(info, setting_name, key, FALSE, TRUE); if (!bytes) { @@ -1435,8 +1435,8 @@ ssid_parser(KeyfileReaderInfo *info, NMSetting *setting, const char *key) static void password_raw_parser(KeyfileReaderInfo *info, NMSetting *setting, const char *key) { - const char * setting_name = nm_setting_get_name(setting); - gs_unref_bytes GBytes *bytes = NULL; + const char *setting_name = nm_setting_get_name(setting); + gs_unref_bytes GBytes *bytes = NULL; bytes = get_bytes(info, setting_name, key, FALSE, TRUE); if (!bytes) { @@ -1454,7 +1454,7 @@ static char * get_cert_path(const char *base_dir, const guint8 *cert_path, gsize cert_path_len) { const char *base; - char * p = NULL, *path, *tmp; + char *p = NULL, *path, *tmp; g_return_val_if_fail(base_dir != NULL, NULL); g_return_val_if_fail(cert_path != NULL, NULL); @@ -1489,13 +1489,13 @@ has_cert_ext(const char *path) } char * -nm_keyfile_detect_unqualified_path_scheme(const char * base_dir, +nm_keyfile_detect_unqualified_path_scheme(const char *base_dir, gconstpointer pdata, gsize data_len, gboolean consider_exists, - gboolean * out_exists) + gboolean *out_exists) { - const char * data = pdata; + const char *data = pdata; gboolean exists = FALSE; gsize validate_len; gsize path_len, pathuri_len; @@ -1573,11 +1573,11 @@ nm_keyfile_detect_unqualified_path_scheme(const char * base_dir, static void cert_parser(KeyfileReaderInfo *info, NMSetting *setting, const char *key) { - const char * setting_name = nm_setting_get_name(setting); - gs_unref_bytes GBytes *bytes = NULL; - const char * bin = NULL; - gsize bin_len = 0; - char * path; + const char *setting_name = nm_setting_get_name(setting); + gs_unref_bytes GBytes *bytes = NULL; + const char *bin = NULL; + gsize bin_len = 0; + char *path; gboolean path_exists; bytes = get_bytes(info, setting_name, key, TRUE, FALSE); @@ -1591,7 +1591,7 @@ cert_parser(KeyfileReaderInfo *info, NMSetting *setting, const char *key) } if (HAS_SCHEME_PREFIX(bin, bin_len, NM_KEYFILE_CERT_SCHEME_PREFIX_PATH)) { - const char * path2 = &bin[NM_STRLEN(NM_KEYFILE_CERT_SCHEME_PREFIX_PATH)]; + const char *path2 = &bin[NM_STRLEN(NM_KEYFILE_CERT_SCHEME_PREFIX_PATH)]; gs_free char *path2_free = NULL; if (nm_setting_802_1x_check_cert_scheme(bin, bin_len, NULL) @@ -1648,8 +1648,8 @@ cert_parser(KeyfileReaderInfo *info, NMSetting *setting, const char *key) } if (HAS_SCHEME_PREFIX(bin, bin_len, NM_KEYFILE_CERT_SCHEME_PREFIX_BLOB)) { - const char *cdata = bin + NM_STRLEN(NM_KEYFILE_CERT_SCHEME_PREFIX_BLOB); - gsize cdata_len = bin_len - NM_STRLEN(NM_KEYFILE_CERT_SCHEME_PREFIX_BLOB) - 1; + const char *cdata = bin + NM_STRLEN(NM_KEYFILE_CERT_SCHEME_PREFIX_BLOB); + gsize cdata_len = bin_len - NM_STRLEN(NM_KEYFILE_CERT_SCHEME_PREFIX_BLOB) - 1; gs_free guchar *bin_decoded = NULL; gsize bin_decoded_len = 0; gsize i; @@ -1801,10 +1801,10 @@ _parity_from_char(int ch) static void parity_parser(KeyfileReaderInfo *info, NMSetting *setting, const char *key) { - const char * setting_name = nm_setting_get_name(setting); - gs_free_error GError *err = NULL; + const char *setting_name = nm_setting_get_name(setting); + gs_free_error GError *err = NULL; int parity; - gs_free char * tmp_str = NULL; + gs_free char *tmp_str = NULL; gint64 i64; /* Keyfile traditionally stored this as the ASCII value for 'E', 'o', or 'n'. @@ -1869,9 +1869,9 @@ out_err: static void team_config_parser(KeyfileReaderInfo *info, NMSetting *setting, const char *key) { - const char * setting_name = nm_setting_get_name(setting); - gs_free char *conf = NULL; - gs_free_error GError *error = NULL; + const char *setting_name = nm_setting_get_name(setting); + gs_free char *conf = NULL; + gs_free_error GError *error = NULL; conf = nm_keyfile_plugin_kf_get_string(info->keyfile, setting_name, key, NULL); @@ -1892,11 +1892,11 @@ static void bridge_vlan_parser(KeyfileReaderInfo *info, NMSetting *setting, const char *key) { gs_unref_ptrarray GPtrArray *vlans = NULL; - gs_free char * value = NULL; - gs_free const char ** strv = NULL; - const char *const * iter; - GError * local = NULL; - NMBridgeVlan * vlan; + gs_free char *value = NULL; + gs_free const char **strv = NULL; + const char *const *iter; + GError *local = NULL; + NMBridgeVlan *vlan; value = nm_keyfile_plugin_kf_get_string(info->keyfile, nm_setting_get_name(setting), key, NULL); if (!value || !value[0]) @@ -1929,10 +1929,10 @@ bridge_vlan_parser(KeyfileReaderInfo *info, NMSetting *setting, const char *key) static void qdisc_parser(KeyfileReaderInfo *info, NMSetting *setting, const char *key) { - const char * setting_name = nm_setting_get_name(setting); - gs_unref_ptrarray GPtrArray *qdiscs = NULL; - gs_strfreev char ** keys = NULL; - gsize n_keys = 0; + const char *setting_name = nm_setting_get_name(setting); + gs_unref_ptrarray GPtrArray *qdiscs = NULL; + gs_strfreev char **keys = NULL; + gsize n_keys = 0; int i; keys = nm_keyfile_plugin_kf_get_keys(info->keyfile, setting_name, &n_keys, NULL); @@ -1942,11 +1942,11 @@ qdisc_parser(KeyfileReaderInfo *info, NMSetting *setting, const char *key) qdiscs = g_ptr_array_new_with_free_func((GDestroyNotify) nm_tc_qdisc_unref); for (i = 0; i < n_keys; i++) { - NMTCQdisc * qdisc; - const char * qdisc_parent; - gs_free char *qdisc_rest = NULL; - gs_free char *qdisc_str = NULL; - gs_free_error GError *err = NULL; + NMTCQdisc *qdisc; + const char *qdisc_parent; + gs_free char *qdisc_rest = NULL; + gs_free char *qdisc_str = NULL; + gs_free_error GError *err = NULL; if (!g_str_has_prefix(keys[i], "qdisc.")) continue; @@ -1979,10 +1979,10 @@ qdisc_parser(KeyfileReaderInfo *info, NMSetting *setting, const char *key) static void tfilter_parser(KeyfileReaderInfo *info, NMSetting *setting, const char *key) { - const char * setting_name = nm_setting_get_name(setting); - gs_unref_ptrarray GPtrArray *tfilters = NULL; - gs_strfreev char ** keys = NULL; - gsize n_keys = 0; + const char *setting_name = nm_setting_get_name(setting); + gs_unref_ptrarray GPtrArray *tfilters = NULL; + gs_strfreev char **keys = NULL; + gsize n_keys = 0; int i; keys = nm_keyfile_plugin_kf_get_keys(info->keyfile, setting_name, &n_keys, NULL); @@ -1992,11 +1992,11 @@ tfilter_parser(KeyfileReaderInfo *info, NMSetting *setting, const char *key) tfilters = g_ptr_array_new_with_free_func((GDestroyNotify) nm_tc_tfilter_unref); for (i = 0; i < n_keys; i++) { - NMTCTfilter * tfilter; - const char * tfilter_parent; - gs_free char *tfilter_rest = NULL; - gs_free char *tfilter_str = NULL; - gs_free_error GError *err = NULL; + NMTCTfilter *tfilter; + const char *tfilter_parent; + gs_free char *tfilter_rest = NULL; + gs_free char *tfilter_str = NULL; + gs_free_error GError *err = NULL; if (!g_str_has_prefix(keys[i], "tfilter.")) continue; @@ -2037,9 +2037,9 @@ tfilter_parser(KeyfileReaderInfo *info, NMSetting *setting, const char *key) */ static void setting_alias_writer(KeyfileWriterInfo *info, - NMSetting * setting, - const char * key, - const GValue * value) + NMSetting *setting, + const char *key, + const GValue *value) { const char *str, *alias; @@ -2060,7 +2060,7 @@ sriov_vfs_writer(KeyfileWriterInfo *info, NMSetting *setting, const char *key, c for (i = 0; i < vfs->len; i++) { const NMSriovVF *vf = vfs->pdata[i]; - gs_free char * kf_value = NULL; + gs_free char *kf_value = NULL; char kf_key[32]; kf_value = nm_utils_sriov_vf_to_str(vf, TRUE, NULL); @@ -2112,12 +2112,12 @@ dns_writer(KeyfileWriterInfo *info, NMSetting *setting, const char *key, const G static void ip6_addr_gen_mode_writer(KeyfileWriterInfo *info, - NMSetting * setting, - const char * key, - const GValue * value) + NMSetting *setting, + const char *key, + const GValue *value) { NMSettingIP6ConfigAddrGenMode addr_gen_mode; - gs_free char * str = NULL; + gs_free char *str = NULL; addr_gen_mode = (NMSettingIP6ConfigAddrGenMode) g_value_get_int(value); str = nm_utils_enum_to_str(nm_setting_ip6_config_addr_gen_mode_get_type(), addr_gen_mode); @@ -2125,9 +2125,9 @@ ip6_addr_gen_mode_writer(KeyfileWriterInfo *info, } static void -write_ip_values(GKeyFile * file, +write_ip_values(GKeyFile *file, const char *setting_name, - GPtrArray * array, + GPtrArray *array, const char *gateway, gboolean is_route) { @@ -2135,11 +2135,11 @@ write_ip_values(GKeyFile * file, nm_auto_str_buf NMStrBuf output = NM_STR_BUF_INIT(2 * INET_ADDRSTRLEN + 10, FALSE); int addr_family; guint i; - const char * addr; - const char * gw; + const char *addr; + const char *gw; guint32 plen; char key_name[64]; - char * key_name_idx; + char *key_name_idx; addr_family = nm_streq(setting_name, NM_SETTING_IP4_CONFIG_SETTING_NAME) ? AF_INET : AF_INET6; @@ -2211,7 +2211,7 @@ write_ip_values(GKeyFile * file, static void addr_writer(KeyfileWriterInfo *info, NMSetting *setting, const char *key, const GValue *value) { - GPtrArray * array; + GPtrArray *array; const char *setting_name = nm_setting_get_name(setting); const char *gateway = nm_setting_ip_config_get_gateway(NM_SETTING_IP_CONFIG(setting)); @@ -2223,7 +2223,7 @@ addr_writer(KeyfileWriterInfo *info, NMSetting *setting, const char *key, const static void route_writer(KeyfileWriterInfo *info, NMSetting *setting, const char *key, const GValue *value) { - GPtrArray * array; + GPtrArray *array; const char *setting_name = nm_setting_get_name(setting); array = (GPtrArray *) g_value_get_boxed(value); @@ -2233,9 +2233,9 @@ route_writer(KeyfileWriterInfo *info, NMSetting *setting, const char *key, const static void bridge_vlan_writer(KeyfileWriterInfo *info, - NMSetting * setting, - const char * key, - const GValue * value) + NMSetting *setting, + const char *key, + const GValue *value) { GPtrArray *vlans; @@ -2262,13 +2262,13 @@ bridge_vlan_writer(KeyfileWriterInfo *info, } static void -wired_s390_options_parser_full(KeyfileReaderInfo * info, - const NMMetaSettingInfo * setting_info, +wired_s390_options_parser_full(KeyfileReaderInfo *info, + const NMMetaSettingInfo *setting_info, const NMSettInfoProperty *property_info, - const ParseInfoProperty * pip, - NMSetting * setting) + const ParseInfoProperty *pip, + NMSetting *setting) { - NMSettingWired * s_wired = NM_SETTING_WIRED(setting); + NMSettingWired *s_wired = NM_SETTING_WIRED(setting); gs_strfreev char **keys = NULL; gsize n_keys; gsize i; @@ -2297,11 +2297,11 @@ wired_s390_options_parser_full(KeyfileReaderInfo * info, } static void -wired_s390_options_writer_full(KeyfileWriterInfo * info, - const NMMetaSettingInfo * setting_info, +wired_s390_options_writer_full(KeyfileWriterInfo *info, + const NMMetaSettingInfo *setting_info, const NMSettInfoProperty *property_info, - const ParseInfoProperty * pip, - NMSetting * setting) + const ParseInfoProperty *pip, + NMSetting *setting) { NMSettingWired *s_wired = NM_SETTING_WIRED(setting); guint i, n; @@ -2309,8 +2309,8 @@ wired_s390_options_writer_full(KeyfileWriterInfo * info, n = nm_setting_wired_get_num_s390_options(s_wired); for (i = 0; i < n; i++) { gs_free char *key_to_free = NULL; - const char * opt_key; - const char * opt_val; + const char *opt_key; + const char *opt_val; nm_setting_wired_get_s390_option(s_wired, i, &opt_key, &opt_val); nm_keyfile_plugin_kf_set_string(info->keyfile, @@ -2321,23 +2321,23 @@ wired_s390_options_writer_full(KeyfileWriterInfo * info, } static void -ip_routing_rule_writer_full(KeyfileWriterInfo * info, - const NMMetaSettingInfo * setting_info, +ip_routing_rule_writer_full(KeyfileWriterInfo *info, + const NMMetaSettingInfo *setting_info, const NMSettInfoProperty *property_info, - const ParseInfoProperty * pip, - NMSetting * setting) + const ParseInfoProperty *pip, + NMSetting *setting) { - const char * setting_name = nm_setting_get_name(setting); + const char *setting_name = nm_setting_get_name(setting); NMSettingIPConfig *s_ip = NM_SETTING_IP_CONFIG(setting); guint i, j, n; char key_name_full[100] = "routing-rule"; - char * key_name_num = &key_name_full[NM_STRLEN("routing-rule")]; + char *key_name_num = &key_name_full[NM_STRLEN("routing-rule")]; n = nm_setting_ip_config_get_num_routing_rules(s_ip); j = 0; for (i = 0; i < n; i++) { NMIPRoutingRule *rule = nm_setting_ip_config_get_routing_rule(s_ip, i); - gs_free char * str = NULL; + gs_free char *str = NULL; str = nm_ip_routing_rule_to_string(rule, NM_IP_ROUTING_RULE_AS_STRING_FLAGS_NONE, NULL, NULL); @@ -2354,7 +2354,7 @@ qdisc_writer(KeyfileWriterInfo *info, NMSetting *setting, const char *key, const { nm_auto_free_gstring GString *key_name = NULL; nm_auto_free_gstring GString *value_str = NULL; - GPtrArray * array; + GPtrArray *array; guint i; array = g_value_get_boxed(value); @@ -2383,7 +2383,7 @@ tfilter_writer(KeyfileWriterInfo *info, NMSetting *setting, const char *key, con { nm_auto_free_gstring GString *key_name = NULL; nm_auto_free_gstring GString *value_str = NULL; - GPtrArray * array; + GPtrArray *array; guint i; array = g_value_get_boxed(value); @@ -2408,16 +2408,16 @@ tfilter_writer(KeyfileWriterInfo *info, NMSetting *setting, const char *key, con } static void -_writer_full_ovs_external_ids_data(KeyfileWriterInfo * info, - const NMMetaSettingInfo * setting_info, +_writer_full_ovs_external_ids_data(KeyfileWriterInfo *info, + const NMMetaSettingInfo *setting_info, const NMSettInfoProperty *property_info, - const ParseInfoProperty * pip, - NMSetting * setting) + const ParseInfoProperty *pip, + NMSetting *setting) { - GHashTable * hash; - NMUtilsNamedValue data_static[300u / sizeof(NMUtilsNamedValue)]; + GHashTable *hash; + NMUtilsNamedValue data_static[300u / sizeof(NMUtilsNamedValue)]; gs_free NMUtilsNamedValue *data_free = NULL; - const NMUtilsNamedValue * data; + const NMUtilsNamedValue *data; guint data_len; char full_key_static[NM_STRLEN(OVS_EXTERNAL_IDS_DATA_PREFIX) + 300u]; guint i; @@ -2436,13 +2436,13 @@ _writer_full_ovs_external_ids_data(KeyfileWriterInfo * info, memcpy(full_key_static, OVS_EXTERNAL_IDS_DATA_PREFIX, NM_STRLEN(OVS_EXTERNAL_IDS_DATA_PREFIX)); for (i = 0; i < data_len; i++) { - const char * key = data[i].name; - const char * val = data[i].value_str; + const char *key = data[i].name; + const char *val = data[i].value_str; gs_free char *escaped_key_to_free = NULL; - const char * escaped_key; + const char *escaped_key; gsize len; gs_free char *full_key_free = NULL; - char * full_key = full_key_static; + char *full_key = full_key_static; escaped_key = nm_keyfile_key_encode(key, &escaped_key_to_free); @@ -2464,8 +2464,8 @@ _writer_full_ovs_external_ids_data(KeyfileWriterInfo * info, static void write_hash_of_string(GKeyFile *file, NMSetting *setting, const char *key, const GValue *value) { - GHashTable * hash; - const char * group_name = nm_setting_get_name(setting); + GHashTable *hash; + const char *group_name = nm_setting_get_name(setting); gboolean vpn_secrets = FALSE; gs_free const char **keys = NULL; guint i, l; @@ -2486,7 +2486,7 @@ write_hash_of_string(GKeyFile *file, NMSetting *setting, const char *key, const keys = nm_strdict_get_keys(hash, TRUE, &l); for (i = 0; i < l; i++) { gs_free char *to_free = NULL; - const char * property, *data; + const char *property, *data; property = keys[i]; @@ -2514,10 +2514,10 @@ write_hash_of_string(GKeyFile *file, NMSetting *setting, const char *key, const static void ssid_writer(KeyfileWriterInfo *info, NMSetting *setting, const char *key, const GValue *value) { - GBytes * bytes; + GBytes *bytes; const guint8 *ssid_data; gsize ssid_len; - const char * setting_name = nm_setting_get_name(setting); + const char *setting_name = nm_setting_get_name(setting); gboolean new_format = TRUE; gsize semicolons = 0; gsize i; @@ -2576,12 +2576,12 @@ ssid_writer(KeyfileWriterInfo *info, NMSetting *setting, const char *key, const static void password_raw_writer(KeyfileWriterInfo *info, - NMSetting * setting, - const char * key, - const GValue * value) + NMSetting *setting, + const char *key, + const GValue *value) { - const char * setting_name = nm_setting_get_name(setting); - GBytes * array; + const char *setting_name = nm_setting_get_name(setting); + GBytes *array; gsize len; const guint8 *data; @@ -2599,10 +2599,10 @@ password_raw_writer(KeyfileWriterInfo *info, /*****************************************************************************/ static void -cert_writer_default(NMConnection * connection, - GKeyFile * file, - NMSetting8021x * setting, - const char * setting_name, +cert_writer_default(NMConnection *connection, + GKeyFile *file, + NMSetting8021x *setting, + const char *setting_name, const NMSetting8021xSchemeVtable *vtable) { NMSetting8021xCKScheme scheme; @@ -2612,7 +2612,7 @@ cert_writer_default(NMConnection * connection, gs_free char *path_free = NULL; gs_free char *base_dir = NULL; gs_free char *tmp = NULL; - const char * path; + const char *path; path = vtable->path_func(setting); g_assert(path); @@ -2643,7 +2643,7 @@ cert_writer_default(NMConnection * connection, nm_keyfile_plugin_kf_set_string(file, setting_name, vtable->setting_key, path); } else if (scheme == NM_SETTING_802_1X_CK_SCHEME_BLOB) { - GBytes * blob; + GBytes *blob; const guint8 *blob_data; gsize blob_len; gs_free char *blob_base64 = NULL; @@ -2677,7 +2677,7 @@ static void cert_writer(KeyfileWriterInfo *info, NMSetting *setting, const char *key, const GValue *value) { const NMSetting8021xSchemeVtable *vtable = NULL; - const char * setting_name; + const char *setting_name; guint i; for (i = 0; nm_setting_8021x_scheme_vtable[i].setting_key; i++) { @@ -2728,22 +2728,22 @@ struct _ParseInfoProperty { const char *property_name; union { void (*parser)(KeyfileReaderInfo *info, NMSetting *setting, const char *key); - void (*parser_full)(KeyfileReaderInfo * info, - const NMMetaSettingInfo * setting_info, + void (*parser_full)(KeyfileReaderInfo *info, + const NMMetaSettingInfo *setting_info, const NMSettInfoProperty *property_info, - const ParseInfoProperty * pip, - NMSetting * setting); + const ParseInfoProperty *pip, + NMSetting *setting); }; union { void (*writer)(KeyfileWriterInfo *info, - NMSetting * setting, - const char * key, - const GValue * value); - void (*writer_full)(KeyfileWriterInfo * info, - const NMMetaSettingInfo * setting_info, + NMSetting *setting, + const char *key, + const GValue *value); + void (*writer_full)(KeyfileWriterInfo *info, + const NMMetaSettingInfo *setting_info, const NMSettInfoProperty *property_info, - const ParseInfoProperty * pip, - NMSetting * setting); + const ParseInfoProperty *pip, + NMSetting *setting); }; bool parser_skip; bool parser_no_check_key : 1; @@ -3021,14 +3021,14 @@ static const ParseInfoSetting *const parse_infos[_NM_META_SETTING_TYPE_NUM] = { }; static void -_parse_info_find(NMSetting * setting, - const char * property_name, +_parse_info_find(NMSetting *setting, + const char *property_name, const NMMetaSettingInfo **out_setting_info, - const ParseInfoSetting ** out_parse_info_setting, + const ParseInfoSetting **out_parse_info_setting, const ParseInfoProperty **out_parse_info_property) { const NMMetaSettingInfo *setting_info; - const ParseInfoSetting * pis; + const ParseInfoSetting *pis; const ParseInfoProperty *pip; #if NM_MORE_ASSERTS > 10 @@ -3105,16 +3105,16 @@ _parse_info_find(NMSetting * setting, /*****************************************************************************/ static void -read_one_setting_value(KeyfileReaderInfo * info, - NMSetting * setting, +read_one_setting_value(KeyfileReaderInfo *info, + NMSetting *setting, const NMSettInfoProperty *property_info) { - GKeyFile * keyfile = info->keyfile; - gs_free_error GError * err = NULL; + GKeyFile *keyfile = info->keyfile; + gs_free_error GError *err = NULL; const NMMetaSettingInfo *setting_info; const ParseInfoProperty *pip; - gs_free char * tmp_str = NULL; - const char * key; + gs_free char *tmp_str = NULL; + const char *key; GType type; guint64 u64; gint64 i64; @@ -3255,11 +3255,11 @@ read_one_setting_value(KeyfileReaderInfo * info, } } else if (type == G_TYPE_BYTES) { nm_auto_unref_bytearray GByteArray *array = NULL; - gs_unref_bytes GBytes *bytes = NULL; - gs_free guint *tmp = NULL; - gsize length; - int i; - gboolean already_warned = FALSE; + gs_unref_bytes GBytes *bytes = NULL; + gs_free guint *tmp = NULL; + gsize length; + int i; + gboolean already_warned = FALSE; tmp = nm_keyfile_plugin_kf_get_integer_list_uint(keyfile, setting_info->setting_name, @@ -3347,9 +3347,9 @@ read_one_setting_value(KeyfileReaderInfo * info, static void _read_setting(KeyfileReaderInfo *info) { - const NMSettInfoSetting *sett_info; + const NMSettInfoSetting *sett_info; gs_unref_object NMSetting *setting = NULL; - const char * alias; + const char *alias; GType type; guint16 i; @@ -3386,10 +3386,10 @@ _read_setting(KeyfileReaderInfo *info) nm_strv_sort(keys, n_keys); for (k = 0; k < n_keys; k++) { - gs_free char *key = keys[k]; + gs_free char *key = keys[k]; gs_free_error GError *local = NULL; - const GVariantType * variant_type; - GVariant * variant; + const GVariantType *variant_type; + GVariant *variant; /* a GKeyFile can return duplicate keys, there is just no API to make sense * of them. Skip them. */ @@ -3477,16 +3477,16 @@ out: static void _read_setting_wireguard_peer(KeyfileReaderInfo *info) { - gs_unref_object NMSettingWireGuard *s_wg_new = NULL; - nm_auto_unref_wgpeer NMWireGuardPeer *peer = NULL; - gs_free_error GError *error = NULL; - NMSettingWireGuard * s_wg; - gs_free char * str = NULL; - const char * cstr = NULL; - const char * key; - gint64 i64; - gs_strfreev char ** sa = NULL; - gsize n_sa; + gs_unref_object NMSettingWireGuard *s_wg_new = NULL; + nm_auto_unref_wgpeer NMWireGuardPeer *peer = NULL; + gs_free_error GError *error = NULL; + NMSettingWireGuard *s_wg; + gs_free char *str = NULL; + const char *cstr = NULL; + const char *key; + gint64 i64; + gs_strfreev char **sa = NULL; + gsize n_sa; peer = nm_wireguard_peer_new(); @@ -3643,7 +3643,7 @@ _read_setting_vpn_secrets(KeyfileReaderInfo *info) { gs_strfreev char **keys = NULL; gsize i, n_keys; - NMSettingVpn * s_vpn; + NMSettingVpn *s_vpn; s_vpn = nm_connection_get_setting_vpn(info->connection); if (!s_vpn) { @@ -3689,7 +3689,7 @@ gboolean nm_keyfile_read_ensure_uuid(NMConnection *connection, const char *fallback_uuid_seed) { NMSettingConnection *s_con; - gs_free char * hashed_uuid = NULL; + gs_free char *hashed_uuid = NULL; g_return_val_if_fail(NM_IS_CONNECTION(connection), FALSE); g_return_val_if_fail(fallback_uuid_seed, FALSE); @@ -3724,16 +3724,16 @@ nm_keyfile_read_ensure_uuid(NMConnection *connection, const char *fallback_uuid_ * Since: 1.30 */ NMConnection * -nm_keyfile_read(GKeyFile * keyfile, - const char * base_dir, +nm_keyfile_read(GKeyFile *keyfile, + const char *base_dir, NMKeyfileHandlerFlags handler_flags, NMKeyfileReadHandler handler, - void * user_data, - GError ** error) + void *user_data, + GError **error) { gs_unref_object NMConnection *connection = NULL; - NMSettingConnection * s_con; - gs_strfreev char ** groups = NULL; + NMSettingConnection *s_con; + gs_strfreev char **groups = NULL; gsize n_groups; gsize i; gboolean vpn_secrets = FALSE; @@ -3814,13 +3814,13 @@ out_with_info_error: /*****************************************************************************/ static void -write_setting_value(KeyfileWriterInfo * info, - NMSetting * setting, +write_setting_value(KeyfileWriterInfo *info, + NMSetting *setting, const NMSettInfoProperty *property_info) { const NMMetaSettingInfo *setting_info; const ParseInfoProperty *pip; - const char * key; + const char *key; char numstr[64]; GValue value; GType type; @@ -3919,7 +3919,7 @@ write_setting_value(KeyfileWriterInfo * info, nm_sprintf_buf(numstr, "%d", (int) g_value_get_schar(&value)); nm_keyfile_plugin_kf_set_value(info->keyfile, setting_info->setting_name, key, numstr); } else if (type == G_TYPE_BYTES) { - GBytes * bytes; + GBytes *bytes; const guint8 *data; gsize len = 0; @@ -3968,13 +3968,13 @@ _write_setting_wireguard(NMSetting *setting, KeyfileWriterInfo *info) n_peers = nm_setting_wireguard_get_peers_len(s_wg); for (i_peer = 0; i_peer < n_peers; i_peer++) { - NMWireGuardPeer * peer = nm_setting_wireguard_get_peer(s_wg, i_peer); - const char * public_key; + NMWireGuardPeer *peer = nm_setting_wireguard_get_peer(s_wg, i_peer); + const char *public_key; char group[NM_STRLEN(NM_KEYFILE_GROUPPREFIX_WIREGUARD_PEER) + 200]; NMSettingSecretFlags secret_flags; gboolean any_key = FALSE; guint i_aip, n_aip; - const char * cstr; + const char *cstr; guint32 u32; public_key = nm_wireguard_peer_get_public_key(peer); @@ -4073,16 +4073,16 @@ _write_setting_wireguard(NMSetting *setting, KeyfileWriterInfo *info) * Since: 1.30 */ GKeyFile * -nm_keyfile_write(NMConnection * connection, +nm_keyfile_write(NMConnection *connection, NMKeyfileHandlerFlags handler_flags, NMKeyfileWriteHandler handler, - void * user_data, - GError ** error) + void *user_data, + GError **error) { nm_auto_unref_keyfile GKeyFile *keyfile = NULL; - GError * local = NULL; + GError *local = NULL; KeyfileWriterInfo info; - NMSetting ** settings; + NMSetting **settings; int i; guint16 j; @@ -4124,10 +4124,10 @@ nm_keyfile_write(NMConnection * connection, settings = _nm_connection_get_settings_arr(connection); for (i = 0; i < (int) _NM_META_SETTING_TYPE_NUM; i++) { - NMSetting * setting = settings[nm_meta_setting_types_by_priority[i]]; + NMSetting *setting = settings[nm_meta_setting_types_by_priority[i]]; const NMSettInfoSetting *sett_info; - const char * setting_name; - const char * setting_alias; + const char *setting_name; + const char *setting_alias; if (!setting) continue; @@ -4150,7 +4150,7 @@ nm_keyfile_write(NMConnection * connection, for (k = 0; k < n_keys; k++) { const char *key = keys[k]; - GVariant * v; + GVariant *v; v = g_hash_table_lookup(h, key); @@ -4305,7 +4305,7 @@ nm_keyfile_utils_create_filename(const char *name, gboolean with_extension) const char ESCAPE_CHAR = with_extension ? '_' : '*'; const char ESCAPE_CHAR2 = '_'; NMStrBuf str; - char * p; + char *p; gsize len; gsize i; @@ -4392,10 +4392,10 @@ nm_keyfile_handler_data_fail_with_error(NMKeyfileHandlerData *handler_data, GErr */ void nm_keyfile_handler_data_get_context(const NMKeyfileHandlerData *handler_data, - const char ** out_kf_group_name, - const char ** out_kf_key_name, - NMSetting ** out_cur_setting, - const char ** out_cur_property_name) + const char **out_kf_group_name, + const char **out_kf_key_name, + NMSetting **out_cur_setting, + const char **out_cur_property_name) { g_return_if_fail(handler_data); @@ -4435,8 +4435,8 @@ _nm_keyfile_handler_data_warn_get_message(const NMKeyfileHandlerData *handler_da */ void nm_keyfile_handler_data_warn_get(const NMKeyfileHandlerData *handler_data, - const char ** out_message, - NMKeyfileWarnSeverity * out_severity) + const char **out_message, + NMKeyfileWarnSeverity *out_severity) { g_return_if_fail(handler_data); g_return_if_fail(handler_data->type == NM_KEYFILE_HANDLER_TYPE_WARN); diff --git a/src/libnm-core-impl/nm-meta-setting-base-impl.c b/src/libnm-core-impl/nm-meta-setting-base-impl.c index 8c1ad10e..cd55779f 100644 --- a/src/libnm-core-impl/nm-meta-setting-base-impl.c +++ b/src/libnm-core-impl/nm-meta-setting-base-impl.c @@ -646,8 +646,8 @@ nm_meta_setting_infos_by_gtype(GType gtype) { #if _NM_META_SETTING_BASE_IMPL_LIBNM nm_auto_unref_gtypeclass GTypeClass *gtypeclass_unref = NULL; - GTypeClass * gtypeclass; - NMSettingClass * klass; + GTypeClass *gtypeclass; + NMSettingClass *klass; if (!g_type_is_a(gtype, NM_TYPE_SETTING)) goto out_none; diff --git a/src/libnm-core-impl/nm-property-compare.c b/src/libnm-core-impl/nm-property-compare.c index 4347d6d6..6273e90b 100644 --- a/src/libnm-core-impl/nm-property-compare.c +++ b/src/libnm-core-impl/nm-property-compare.c @@ -43,8 +43,8 @@ _nm_property_compare_vardict(GVariant *value1, GVariant *value2) { GVariantIter iter; int len1, len2; - const char * key; - GVariant * val1, *val2; + const char *key; + GVariant *val1, *val2; len1 = g_variant_n_children(value1); len2 = g_variant_n_children(value2); @@ -75,7 +75,7 @@ _nm_property_compare_strdict(GVariant *value1, GVariant *value2) { GVariantIter iter; int len1, len2; - const char * key, *val1, *val2; + const char *key, *val1, *val2; int ret; len1 = g_variant_n_children(value1); diff --git a/src/libnm-core-impl/nm-setting-6lowpan.c b/src/libnm-core-impl/nm-setting-6lowpan.c index 606fa824..765af69b 100644 --- a/src/libnm-core-impl/nm-setting-6lowpan.c +++ b/src/libnm-core-impl/nm-setting-6lowpan.c @@ -66,7 +66,7 @@ static gboolean verify(NMSetting *setting, NMConnection *connection, GError **error) { NMSetting6LowpanPrivate *priv = NM_SETTING_6LOWPAN_GET_PRIVATE(setting); - NMSettingConnection * s_con = NULL; + NMSettingConnection *s_con = NULL; if (connection) s_con = nm_connection_get_setting_connection(connection); @@ -150,9 +150,9 @@ nm_setting_6lowpan_new(void) static void nm_setting_6lowpan_class_init(NMSetting6LowpanClass *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(NMSetting6LowpanPrivate)); diff --git a/src/libnm-core-impl/nm-setting-8021x.c b/src/libnm-core-impl/nm-setting-8021x.c index 103443ba..884f8830 100644 --- a/src/libnm-core-impl/nm-setting-8021x.c +++ b/src/libnm-core-impl/nm-setting-8021x.c @@ -72,7 +72,7 @@ typedef void (*EAPMethodNeedSecretsFunc)(NMSetting8021x *self, GPtrArray *secret typedef gboolean (*EAPMethodValidateFunc)(NMSetting8021x *self, gboolean phase2, GError **error); typedef struct { - const char * method; + const char *method; EAPMethodNeedSecretsFunc ns_func; EAPMethodValidateFunc v_func; } EAPMethodsTable; @@ -132,39 +132,39 @@ NM_GOBJECT_PROPERTIES_DEFINE(NMSetting8021x, typedef struct { GSList *eap; /* GSList of strings */ - char * identity; - char * anonymous_identity; - char * pac_file; + char *identity; + char *anonymous_identity; + char *pac_file; GBytes *ca_cert; - char * ca_cert_password; - char * ca_path; - char * subject_match; + char *ca_cert_password; + char *ca_path; + char *subject_match; GSList *altsubject_matches; - char * domain_suffix_match; - char * domain_match; + char *domain_suffix_match; + char *domain_match; GBytes *client_cert; - char * client_cert_password; - char * phase1_peapver; - char * phase1_peaplabel; - char * phase1_fast_provisioning; - char * phase2_auth; - char * phase2_autheap; + char *client_cert_password; + char *phase1_peapver; + char *phase1_peaplabel; + char *phase1_fast_provisioning; + char *phase2_auth; + char *phase2_autheap; GBytes *phase2_ca_cert; - char * phase2_ca_cert_password; - char * phase2_ca_path; - char * phase2_subject_match; + char *phase2_ca_cert_password; + char *phase2_ca_path; + char *phase2_subject_match; GSList *phase2_altsubject_matches; - char * phase2_domain_suffix_match; - char * phase2_domain_match; + char *phase2_domain_suffix_match; + char *phase2_domain_match; GBytes *phase2_client_cert; - char * phase2_client_cert_password; - char * password; + char *phase2_client_cert_password; + char *password; GBytes *password_raw; - char * pin; + char *pin; GBytes *private_key; - char * private_key_password; + char *private_key_password; GBytes *phase2_private_key; - char * phase2_private_key_password; + char *phase2_private_key_password; guint ca_cert_password_flags; guint client_cert_password_flags; guint phase2_ca_cert_password_flags; @@ -221,7 +221,7 @@ G_DEFINE_TYPE(NMSetting8021x, nm_setting_802_1x, NM_TYPE_SETTING) NMSetting8021xCKScheme nm_setting_802_1x_check_cert_scheme(gconstpointer pdata, gsize length, GError **error) { - const char * data = pdata; + const char *data = pdata; NMSetting8021xCKScheme scheme; gsize prefix_length; @@ -309,7 +309,7 @@ _nm_setting_802_1x_cert_get_scheme(GBytes *bytes, GError **error) static gboolean _cert_verify_scheme(NMSetting8021xCKScheme scheme, GBytes *bytes, GError **error) { - GError * local = NULL; + GError *local = NULL; NMSetting8021xCKScheme scheme_detected; nm_assert(bytes); @@ -337,12 +337,12 @@ _cert_verify_scheme(NMSetting8021xCKScheme scheme, GBytes *bytes, GError **error GBytes * _nm_setting_802_1x_cert_value_to_bytes(NMSetting8021xCKScheme scheme, - const guint8 * val_bin, + const guint8 *val_bin, gssize val_len, - GError ** error) + GError **error) { gs_unref_bytes GBytes *bytes = NULL; - guint8 * mem; + guint8 *mem; gsize total_len; nm_assert(val_bin); @@ -411,7 +411,7 @@ _cert_get_path(GBytes *bytes) G_STMT_START \ { \ NMSetting8021x *const _setting = (setting); \ - GBytes * _cert; \ + GBytes *_cert; \ \ g_return_val_if_fail(NM_IS_SETTING_802_1X(_setting), NM_SETTING_802_1X_CK_SCHEME_UNKNOWN); \ \ @@ -425,7 +425,7 @@ _cert_get_path(GBytes *bytes) G_STMT_START \ { \ NMSetting8021x *const _setting = (setting); \ - GBytes * _cert; \ + GBytes *_cert; \ \ g_return_val_if_fail(NM_IS_SETTING_802_1X(_setting), NULL); \ \ @@ -441,7 +441,7 @@ _cert_get_path(GBytes *bytes) G_STMT_START \ { \ NMSetting8021x *const _setting = (setting); \ - GBytes * _cert; \ + GBytes *_cert; \ \ g_return_val_if_fail(NM_IS_SETTING_802_1X(_setting), NULL); \ \ @@ -457,7 +457,7 @@ _cert_get_path(GBytes *bytes) G_STMT_START \ { \ NMSetting8021x *const _setting = (setting); \ - GBytes * _cert; \ + GBytes *_cert; \ \ g_return_val_if_fail(NM_IS_SETTING_802_1X(_setting), NULL); \ \ @@ -470,20 +470,20 @@ _cert_get_path(GBytes *bytes) G_STMT_END static gboolean -_cert_impl_set(NMSetting8021x * setting, +_cert_impl_set(NMSetting8021x *setting, _PropertyEnums property, - const char * value, - const char * password, + const char *value, + const char *password, NMSetting8021xCKScheme scheme, NMSetting8021xCKFormat *out_format, - GError ** error) + GError **error) { NMSetting8021xPrivate *priv; NMCryptoFileFormat format = NM_CRYPTO_FILE_FORMAT_UNKNOWN; gs_unref_bytes GBytes *cert = NULL; - GBytes ** p_cert = NULL; - GBytes ** p_client_cert = NULL; - char ** p_password = NULL; + GBytes **p_cert = NULL; + GBytes **p_client_cert = NULL; + char **p_password = NULL; _PropertyEnums notify_cert = property; _PropertyEnums notify_password = PROP_0; _PropertyEnums notify_client_cert = PROP_0; @@ -630,7 +630,7 @@ static NMSetting8021xCKFormat _cert_impl_get_key_format_from_bytes(GBytes *private_key) { const char *path; - GError * error = NULL; + GError *error = NULL; if (!private_key) return NM_SETTING_802_1X_CK_FORMAT_UNKNOWN; @@ -660,7 +660,7 @@ _cert_impl_get_key_format_from_bytes(GBytes *private_key) } #define _cert_impl_get_key_format(setting, private_key_field) \ ({ \ - NMSetting8021x * _setting = (setting); \ + NMSetting8021x *_setting = (setting); \ NMSetting8021xPrivate *_priv; \ \ g_return_val_if_fail(NM_IS_SETTING_802_1X(_setting), NM_SETTING_802_1X_CK_FORMAT_UNKNOWN); \ @@ -670,13 +670,13 @@ _cert_impl_get_key_format_from_bytes(GBytes *private_key) }) static gboolean -_cert_verify_property(GBytes * bytes, +_cert_verify_property(GBytes *bytes, const char *prop_name, const char *password, const char *password_prop_name, - GError ** error) + GError **error) { - GError * local = NULL; + GError *local = NULL; NMSetting8021xCKScheme scheme; if (!bytes) @@ -766,7 +766,7 @@ gboolean nm_setting_802_1x_add_eap_method(NMSetting8021x *setting, const char *eap) { NMSetting8021xPrivate *priv; - GSList * iter; + GSList *iter; g_return_val_if_fail(NM_IS_SETTING_802_1X(setting), FALSE); g_return_val_if_fail(eap != NULL, FALSE); @@ -793,7 +793,7 @@ void nm_setting_802_1x_remove_eap_method(NMSetting8021x *setting, guint32 i) { NMSetting8021xPrivate *priv; - GSList * elt; + GSList *elt; g_return_if_fail(NM_IS_SETTING_802_1X(setting)); @@ -819,7 +819,7 @@ gboolean nm_setting_802_1x_remove_eap_method_by_value(NMSetting8021x *setting, const char *eap) { NMSetting8021xPrivate *priv; - GSList * iter; + GSList *iter; g_return_val_if_fail(NM_IS_SETTING_802_1X(setting), FALSE); g_return_val_if_fail(eap != NULL, FALSE); @@ -1044,11 +1044,11 @@ nm_setting_802_1x_get_ca_cert_uri(NMSetting8021x *setting) * Returns: %TRUE if the operation succeeded, %FALSE if it was unsuccessful **/ gboolean -nm_setting_802_1x_set_ca_cert(NMSetting8021x * setting, - const char * value, +nm_setting_802_1x_set_ca_cert(NMSetting8021x *setting, + const char *value, NMSetting8021xCKScheme scheme, NMSetting8021xCKFormat *out_format, - GError ** error) + GError **error) { return _cert_impl_set(setting, PROP_CA_CERT, value, NULL, scheme, out_format, error); } @@ -1160,7 +1160,7 @@ gboolean nm_setting_802_1x_add_altsubject_match(NMSetting8021x *setting, const char *altsubject_match) { NMSetting8021xPrivate *priv; - GSList * iter; + GSList *iter; g_return_val_if_fail(NM_IS_SETTING_802_1X(setting), FALSE); g_return_val_if_fail(altsubject_match != NULL, FALSE); @@ -1187,7 +1187,7 @@ void nm_setting_802_1x_remove_altsubject_match(NMSetting8021x *setting, guint32 i) { NMSetting8021xPrivate *priv; - GSList * elt; + GSList *elt; g_return_if_fail(NM_IS_SETTING_802_1X(setting)); @@ -1212,10 +1212,10 @@ nm_setting_802_1x_remove_altsubject_match(NMSetting8021x *setting, guint32 i) **/ gboolean nm_setting_802_1x_remove_altsubject_match_by_value(NMSetting8021x *setting, - const char * altsubject_match) + const char *altsubject_match) { NMSetting8021xPrivate *priv; - GSList * iter; + GSList *iter; g_return_val_if_fail(NM_IS_SETTING_802_1X(setting), FALSE); g_return_val_if_fail(altsubject_match != NULL, FALSE); @@ -1377,11 +1377,11 @@ nm_setting_802_1x_get_client_cert_uri(NMSetting8021x *setting) * Returns: %TRUE if the operation succeeded, %FALSE if it was unsuccessful **/ gboolean -nm_setting_802_1x_set_client_cert(NMSetting8021x * setting, - const char * value, +nm_setting_802_1x_set_client_cert(NMSetting8021x *setting, + const char *value, NMSetting8021xCKScheme scheme, NMSetting8021xCKFormat *out_format, - GError ** error) + GError **error) { return _cert_impl_set(setting, PROP_CLIENT_CERT, value, NULL, scheme, out_format, error); } @@ -1635,11 +1635,11 @@ nm_setting_802_1x_get_phase2_ca_cert_uri(NMSetting8021x *setting) * Returns: %TRUE if the operation succeeded, %FALSE if it was unsuccessful **/ gboolean -nm_setting_802_1x_set_phase2_ca_cert(NMSetting8021x * setting, - const char * value, +nm_setting_802_1x_set_phase2_ca_cert(NMSetting8021x *setting, + const char *value, NMSetting8021xCKScheme scheme, NMSetting8021xCKFormat *out_format, - GError ** error) + GError **error) { return _cert_impl_set(setting, PROP_PHASE2_CA_CERT, value, NULL, scheme, out_format, error); } @@ -1782,10 +1782,10 @@ nm_setting_802_1x_get_phase2_altsubject_match(NMSetting8021x *setting, guint32 i **/ gboolean nm_setting_802_1x_add_phase2_altsubject_match(NMSetting8021x *setting, - const char * phase2_altsubject_match) + const char *phase2_altsubject_match) { NMSetting8021xPrivate *priv; - GSList * iter; + GSList *iter; g_return_val_if_fail(NM_IS_SETTING_802_1X(setting), FALSE); g_return_val_if_fail(phase2_altsubject_match != NULL, FALSE); @@ -1813,7 +1813,7 @@ void nm_setting_802_1x_remove_phase2_altsubject_match(NMSetting8021x *setting, guint32 i) { NMSetting8021xPrivate *priv; - GSList * elt; + GSList *elt; g_return_if_fail(NM_IS_SETTING_802_1X(setting)); @@ -1838,10 +1838,10 @@ nm_setting_802_1x_remove_phase2_altsubject_match(NMSetting8021x *setting, guint3 **/ gboolean nm_setting_802_1x_remove_phase2_altsubject_match_by_value(NMSetting8021x *setting, - const char * phase2_altsubject_match) + const char *phase2_altsubject_match) { NMSetting8021xPrivate *priv; - GSList * iter; + GSList *iter; g_return_val_if_fail(NM_IS_SETTING_802_1X(setting), FALSE); g_return_val_if_fail(phase2_altsubject_match != NULL, FALSE); @@ -1975,11 +1975,11 @@ nm_setting_802_1x_get_phase2_client_cert_uri(NMSetting8021x *setting) * Returns: %TRUE if the operation succeeded, %FALSE if it was unsuccessful **/ gboolean -nm_setting_802_1x_set_phase2_client_cert(NMSetting8021x * setting, - const char * value, +nm_setting_802_1x_set_phase2_client_cert(NMSetting8021x *setting, + const char *value, NMSetting8021xCKScheme scheme, NMSetting8021xCKFormat *out_format, - GError ** error) + GError **error) { return _cert_impl_set(setting, PROP_PHASE2_CLIENT_CERT, value, NULL, scheme, out_format, error); } @@ -2227,12 +2227,12 @@ nm_setting_802_1x_get_private_key_uri(NMSetting8021x *setting) * Returns: %TRUE if the operation succeeded, %FALSE if it was unsuccessful **/ gboolean -nm_setting_802_1x_set_private_key(NMSetting8021x * setting, - const char * value, - const char * password, +nm_setting_802_1x_set_private_key(NMSetting8021x *setting, + const char *value, + const char *password, NMSetting8021xCKScheme scheme, NMSetting8021xCKFormat *out_format, - GError ** error) + GError **error) { return _cert_impl_set(setting, PROP_PRIVATE_KEY, value, password, scheme, out_format, error); } @@ -2430,12 +2430,12 @@ nm_setting_802_1x_get_phase2_private_key_uri(NMSetting8021x *setting) * Returns: %TRUE if the operation succeeded, %FALSE if it was unsuccessful **/ gboolean -nm_setting_802_1x_set_phase2_private_key(NMSetting8021x * setting, - const char * value, - const char * password, +nm_setting_802_1x_set_phase2_private_key(NMSetting8021x *setting, + const char *value, + const char *password, NMSetting8021xCKScheme scheme, NMSetting8021xCKFormat *out_format, - GError ** error) + GError **error) { return _cert_impl_set(setting, PROP_PHASE2_PRIVATE_KEY, @@ -2504,7 +2504,7 @@ need_secrets_password(NMSetting8021x *self, GPtrArray *secrets, gboolean phase2) { NMSetting8021xPrivate *priv = NM_SETTING_802_1X_GET_PRIVATE(self); - if ((!priv->password || !strlen(priv->password)) + if (nm_str_is_empty(priv->password) && (!priv->password_raw || !g_bytes_get_size(priv->password_raw))) { g_ptr_array_add(secrets, NM_SETTING_802_1X_PASSWORD); g_ptr_array_add(secrets, NM_SETTING_802_1X_PASSWORD_RAW); @@ -2521,10 +2521,10 @@ need_secrets_sim(NMSetting8021x *self, GPtrArray *secrets, gboolean phase2) } static gboolean -need_private_key_password(GBytes * blob, +need_private_key_password(GBytes *blob, NMSetting8021xCKScheme scheme, - const char * path, - const char * password, + const char *path, + const char *password, NMSettingSecretFlags flags) { NMCryptoFileFormat format = NM_CRYPTO_FILE_FORMAT_UNKNOWN; @@ -2554,8 +2554,8 @@ need_secrets_tls(NMSetting8021x *self, GPtrArray *secrets, gboolean phase2) { NMSetting8021xPrivate *priv = NM_SETTING_802_1X_GET_PRIVATE(self); NMSetting8021xCKScheme scheme; - GBytes * blob = NULL; - const char * path = NULL; + GBytes *blob = NULL; + const char *path = NULL; if (phase2) { scheme = nm_setting_802_1x_get_phase2_private_key_scheme(self); @@ -2823,7 +2823,7 @@ static void need_secrets_phase2(NMSetting8021x *self, GPtrArray *secrets, gboolean phase2) { NMSetting8021xPrivate *priv = NM_SETTING_802_1X_GET_PRIVATE(self); - char * method = NULL; + char *method = NULL; int i; g_return_if_fail(phase2 == FALSE); @@ -2871,9 +2871,9 @@ static const EAPMethodsTable eap_methods_table[] = { static gboolean verify(NMSetting *setting, NMConnection *connection, GError **error) { - NMSetting8021x * self = NM_SETTING_802_1X(setting); + NMSetting8021x *self = NM_SETTING_802_1X(setting); NMSetting8021xPrivate *priv = NM_SETTING_802_1X_GET_PRIVATE(self); - const char * valid_eap[] = + const char *valid_eap[] = {"leap", "md5", "tls", "peap", "ttls", "sim", "fast", "pwd", "external", NULL}; GSList *iter; @@ -3057,10 +3057,10 @@ verify(NMSetting *setting, NMConnection *connection, GError **error) static GPtrArray * need_secrets(NMSetting *setting) { - NMSetting8021x * self = NM_SETTING_802_1X(setting); + NMSetting8021x *self = NM_SETTING_802_1X(setting); NMSetting8021xPrivate *priv = NM_SETTING_802_1X_GET_PRIVATE(self); - GSList * iter; - GPtrArray * secrets; + GSList *iter; + GPtrArray *secrets; gboolean eap_method_found = FALSE; secrets = g_ptr_array_sized_new(4); @@ -3099,7 +3099,7 @@ need_secrets(NMSetting *setting) static void get_property(GObject *object, guint prop_id, GValue *value, GParamSpec *pspec) { - NMSetting8021x * setting = NM_SETTING_802_1X(object); + NMSetting8021x *setting = NM_SETTING_802_1X(object); NMSetting8021xPrivate *priv = NM_SETTING_802_1X_GET_PRIVATE(setting); switch (prop_id) { @@ -3121,7 +3121,7 @@ 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) { - NMSetting8021x * setting = NM_SETTING_802_1X(object); + NMSetting8021x *setting = NM_SETTING_802_1X(object); NMSetting8021xPrivate *priv = NM_SETTING_802_1X_GET_PRIVATE(setting); switch (prop_id) { @@ -3165,7 +3165,7 @@ nm_setting_802_1x_new(void) static void finalize(GObject *object) { - NMSetting8021x * self = NM_SETTING_802_1X(object); + NMSetting8021x *self = NM_SETTING_802_1X(object); NMSetting8021xPrivate *priv = NM_SETTING_802_1X_GET_PRIVATE(self); g_slist_free_full(priv->eap, g_free); @@ -3178,9 +3178,9 @@ finalize(GObject *object) static void nm_setting_802_1x_class_init(NMSetting8021xClass *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(NMSetting8021xPrivate)); diff --git a/src/libnm-core-impl/nm-setting-adsl.c b/src/libnm-core-impl/nm-setting-adsl.c index 8e5dc8cf..88606b69 100644 --- a/src/libnm-core-impl/nm-setting-adsl.c +++ b/src/libnm-core-impl/nm-setting-adsl.c @@ -31,10 +31,10 @@ NM_GOBJECT_PROPERTIES_DEFINE_BASE(PROP_USERNAME, PROP_VCI, ); typedef struct { - char * username; - char * password; - char * protocol; - char * encapsulation; + char *username; + char *password; + char *protocol; + char *encapsulation; guint password_flags; guint32 vpi; guint32 vci; @@ -228,7 +228,7 @@ static GPtrArray * need_secrets(NMSetting *setting) { NMSettingAdslPrivate *priv = NM_SETTING_ADSL_GET_PRIVATE(setting); - GPtrArray * secrets = NULL; + GPtrArray *secrets = NULL; if (priv->password && *priv->password) return NULL; @@ -263,9 +263,9 @@ nm_setting_adsl_new(void) static void nm_setting_adsl_class_init(NMSettingAdslClass *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(NMSettingAdslPrivate)); diff --git a/src/libnm-core-impl/nm-setting-bluetooth.c b/src/libnm-core-impl/nm-setting-bluetooth.c index 53e4912f..f657ff13 100644 --- a/src/libnm-core-impl/nm-setting-bluetooth.c +++ b/src/libnm-core-impl/nm-setting-bluetooth.c @@ -100,7 +100,7 @@ static gboolean verify(NMSetting *setting, NMConnection *connection, GError **error) { NMSettingBluetoothPrivate *priv = NM_SETTING_BLUETOOTH_GET_PRIVATE(setting); - const char * type; + const char *type; gboolean missing_nap_bridge = FALSE; if (priv->bdaddr && !nm_utils_hwaddr_valid(priv->bdaddr, ETH_ALEN)) { @@ -250,9 +250,9 @@ nm_setting_bluetooth_new(void) static void nm_setting_bluetooth_class_init(NMSettingBluetoothClass *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(NMSettingBluetoothPrivate)); diff --git a/src/libnm-core-impl/nm-setting-bond-port.c b/src/libnm-core-impl/nm-setting-bond-port.c index 4538e8b9..9b41a74f 100644 --- a/src/libnm-core-impl/nm-setting-bond-port.c +++ b/src/libnm-core-impl/nm-setting-bond-port.c @@ -72,7 +72,7 @@ verify(NMSetting *setting, NMConnection *connection, GError **error) { if (connection) { NMSettingConnection *s_con; - const char * slave_type; + const char *slave_type; s_con = nm_connection_get_setting_connection(connection); if (!s_con) { @@ -127,9 +127,9 @@ nm_setting_bond_port_new(void) static void nm_setting_bond_port_class_init(NMSettingBondPortClass *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(); object_class->get_property = _nm_setting_property_get_property_direct; object_class->set_property = _nm_setting_property_set_property_direct; diff --git a/src/libnm-core-impl/nm-setting-bond.c b/src/libnm-core-impl/nm-setting-bond.c index e81130cd..ae2fe051 100644 --- a/src/libnm-core-impl/nm-setting-bond.c +++ b/src/libnm-core-impl/nm-setting-bond.c @@ -34,7 +34,7 @@ NM_GOBJECT_PROPERTIES_DEFINE(NMSettingBond, PROP_OPTIONS, ); typedef struct { - GHashTable * options; + GHashTable *options; NMUtilsNamedValue *options_idx_cache; } NMSettingBondPrivate; @@ -95,7 +95,7 @@ static const char *const valid_options_lst[] = { }; typedef struct { - const char * val; + const char *val; NMBondOptionType opt_type; guint min; guint max; @@ -449,8 +449,8 @@ _ensure_options_idx_cache(NMSettingBondPrivate *priv) gboolean nm_setting_bond_get_option(NMSettingBond *setting, guint32 idx, - const char ** out_name, - const char ** out_value) + const char **out_name, + const char **out_value) { NMSettingBondPrivate *priv; guint len; @@ -778,17 +778,17 @@ _nm_setting_bond_get_option_type(NMSettingBond *setting, const char *name) static gboolean verify(NMSetting *setting, NMConnection *connection, GError **error) { - NMSettingBond * self = NM_SETTING_BOND(setting); - NMSettingBondPrivate * priv = NM_SETTING_BOND_GET_PRIVATE(setting); + NMSettingBond *self = NM_SETTING_BOND(setting); + NMSettingBondPrivate *priv = NM_SETTING_BOND_GET_PRIVATE(setting); int miimon; int arp_interval; int num_grat_arp; int num_unsol_na; int peer_notif_delay; - const char * mode_str; - const char * arp_ip_target = NULL; - const char * lacp_rate; - const char * primary; + const char *mode_str; + const char *arp_ip_target = NULL; + const char *lacp_rate; + const char *primary; NMBondMode bond_mode; guint i; const NMUtilsNamedValue *n; @@ -1062,7 +1062,7 @@ static gboolean options_equal_asym(NMSettingBond *s_bond, NMSettingBond *s_bond2, NMSettingCompareFlags flags) { GHashTableIter iter; - const char * key, *value; + const char *key, *value; g_hash_table_iter_init(&iter, NM_SETTING_BOND_GET_PRIVATE(s_bond)->options); while (g_hash_table_iter_next(&iter, (gpointer *) &key, (gpointer *) &value)) { @@ -1169,9 +1169,9 @@ finalize(GObject *object) static void nm_setting_bond_class_init(NMSettingBondClass *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(NMSettingBondPrivate)); diff --git a/src/libnm-core-impl/nm-setting-bridge-port.c b/src/libnm-core-impl/nm-setting-bridge-port.c index 48ad74a1..b94a348e 100644 --- a/src/libnm-core-impl/nm-setting-bridge-port.c +++ b/src/libnm-core-impl/nm-setting-bridge-port.c @@ -318,7 +318,7 @@ verify(NMSetting *setting, NMConnection *connection, GError **error) if (connection) { NMSettingConnection *s_con; - const char * slave_type; + const char *slave_type; s_con = nm_connection_get_setting_connection(connection); if (!s_con) { @@ -451,9 +451,9 @@ finalize(GObject *object) static void nm_setting_bridge_port_class_init(NMSettingBridgePortClass *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(NMSettingBridgePortPrivate)); diff --git a/src/libnm-core-impl/nm-setting-bridge.c b/src/libnm-core-impl/nm-setting-bridge.c index 9045d619..41cd6632 100644 --- a/src/libnm-core-impl/nm-setting-bridge.c +++ b/src/libnm-core-impl/nm-setting-bridge.c @@ -57,10 +57,10 @@ NM_GOBJECT_PROPERTIES_DEFINE(NMSettingBridge, typedef struct { GPtrArray *vlans; - char * mac_address; - char * multicast_router; - char * group_address; - char * vlan_protocol; + char *mac_address; + char *multicast_router; + char *group_address; + char *vlan_protocol; guint64 multicast_last_member_interval; guint64 multicast_membership_interval; guint64 multicast_querier_interval; @@ -465,12 +465,12 @@ nm_bridge_vlan_to_str(const NMBridgeVlan *vlan, GError **error) NMBridgeVlan * nm_bridge_vlan_from_str(const char *str, GError **error) { - NMBridgeVlan * vlan = NULL; + NMBridgeVlan *vlan = NULL; gs_free const char **tokens = NULL; guint i, vid_start, vid_end = 0; gboolean pvid = FALSE; gboolean untagged = FALSE; - char * c; + char *c; g_return_val_if_fail(str, NULL); g_return_val_if_fail(!error || !*error, NULL); @@ -868,7 +868,7 @@ gboolean nm_setting_bridge_remove_vlan_by_vid(NMSettingBridge *setting, guint16 vid_start, guint16 vid_end) { NMSettingBridgePrivate *priv; - NMBridgeVlan * vlan; + NMBridgeVlan *vlan; guint i; g_return_val_if_fail(NM_IS_SETTING_BRIDGE(setting), FALSE); @@ -1398,9 +1398,9 @@ finalize(GObject *object) static void nm_setting_bridge_class_init(NMSettingBridgeClass *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(); object_class->get_property = get_property; object_class->set_property = set_property; @@ -1443,8 +1443,8 @@ nm_setting_bridge_class_init(NMSettingBridgeClass *klass) NM_SETTING_BRIDGE_MAC_ADDRESS, PROP_MAC_ADDRESS, NM_SETTING_PARAM_INFERRABLE, - NMSettingBridgePrivate, - mac_address, + NMSettingBridge, + _priv.mac_address, .direct_set_string_mac_address_len = ETH_ALEN); /** @@ -1465,8 +1465,8 @@ nm_setting_bridge_class_init(NMSettingBridgeClass *klass) PROP_STP, NM_BRIDGE_STP_DEF, NM_SETTING_PARAM_INFERRABLE, - NMSettingBridgePrivate, - stp); + NMSettingBridge, + _priv.stp); /** * NMSettingBridge:priority: @@ -1491,8 +1491,8 @@ nm_setting_bridge_class_init(NMSettingBridgeClass *klass) NM_BRIDGE_PRIORITY_MAX, NM_BRIDGE_PRIORITY_DEF, NM_SETTING_PARAM_INFERRABLE, - NMSettingBridgePrivate, - priority); + NMSettingBridge, + _priv.priority); /** * NMSettingBridge:forward-delay: @@ -1515,8 +1515,8 @@ nm_setting_bridge_class_init(NMSettingBridgeClass *klass) NM_BRIDGE_FORWARD_DELAY_MAX, NM_BRIDGE_FORWARD_DELAY_DEF, NM_SETTING_PARAM_INFERRABLE, - NMSettingBridgePrivate, - forward_delay); + NMSettingBridge, + _priv.forward_delay); /** * NMSettingBridge:hello-time: @@ -1539,8 +1539,8 @@ nm_setting_bridge_class_init(NMSettingBridgeClass *klass) NM_BRIDGE_HELLO_TIME_MAX, NM_BRIDGE_HELLO_TIME_DEF, NM_SETTING_PARAM_INFERRABLE, - NMSettingBridgePrivate, - hello_time); + NMSettingBridge, + _priv.hello_time); /** * NMSettingBridge:max-age: @@ -1563,8 +1563,8 @@ nm_setting_bridge_class_init(NMSettingBridgeClass *klass) NM_BRIDGE_MAX_AGE_MAX, NM_BRIDGE_MAX_AGE_DEF, NM_SETTING_PARAM_INFERRABLE, - NMSettingBridgePrivate, - max_age); + NMSettingBridge, + _priv.max_age); /** * NMSettingBridge:ageing-time: @@ -1587,8 +1587,8 @@ nm_setting_bridge_class_init(NMSettingBridgeClass *klass) NM_BRIDGE_AGEING_TIME_MAX, NM_BRIDGE_AGEING_TIME_DEF, NM_SETTING_PARAM_INFERRABLE, - NMSettingBridgePrivate, - ageing_time); + NMSettingBridge, + _priv.ageing_time); /** * NMSettingBridge:group-forward-mask: @@ -1610,8 +1610,8 @@ nm_setting_bridge_class_init(NMSettingBridgeClass *klass) 0xFFFF, 0, NM_SETTING_PARAM_INFERRABLE, - NMSettingBridgePrivate, - group_forward_mask); + NMSettingBridge, + _priv.group_forward_mask); /** * NMSettingBridge:multicast-snooping: @@ -1637,8 +1637,8 @@ nm_setting_bridge_class_init(NMSettingBridgeClass *klass) PROP_MULTICAST_SNOOPING, NM_BRIDGE_MULTICAST_SNOOPING_DEF, NM_SETTING_PARAM_INFERRABLE, - NMSettingBridgePrivate, - multicast_snooping); + NMSettingBridge, + _priv.multicast_snooping); /** * NMSettingBridge:vlan-filtering: @@ -1661,8 +1661,8 @@ nm_setting_bridge_class_init(NMSettingBridgeClass *klass) PROP_VLAN_FILTERING, FALSE, NM_SETTING_PARAM_INFERRABLE, - NMSettingBridgePrivate, - vlan_filtering); + NMSettingBridge, + _priv.vlan_filtering); /** * NMSettingBridge:vlan-default-pvid: @@ -1688,8 +1688,8 @@ nm_setting_bridge_class_init(NMSettingBridgeClass *klass) NM_BRIDGE_VLAN_VID_MAX, NM_BRIDGE_VLAN_DEFAULT_PVID_DEF, NM_SETTING_PARAM_INFERRABLE, - NMSettingBridgePrivate, - vlan_default_pvid); + NMSettingBridge, + _priv.vlan_default_pvid); /** * NMSettingBridge:vlans: (type GPtrArray(NMBridgeVlan)) @@ -1764,8 +1764,8 @@ nm_setting_bridge_class_init(NMSettingBridgeClass *klass) NM_SETTING_BRIDGE_GROUP_ADDRESS, PROP_GROUP_ADDRESS, NM_SETTING_PARAM_INFERRABLE, - NMSettingBridgePrivate, - group_address, + NMSettingBridge, + _priv.group_address, .direct_set_string_mac_address_len = ETH_ALEN); /** @@ -1792,8 +1792,8 @@ nm_setting_bridge_class_init(NMSettingBridgeClass *klass) NM_SETTING_BRIDGE_VLAN_PROTOCOL, PROP_VLAN_PROTOCOL, NM_SETTING_PARAM_INFERRABLE, - NMSettingBridgePrivate, - vlan_protocol); + NMSettingBridge, + _priv.vlan_protocol); /** * NMSettingBridge:vlan-stats-enabled: @@ -1815,8 +1815,8 @@ nm_setting_bridge_class_init(NMSettingBridgeClass *klass) PROP_VLAN_STATS_ENABLED, NM_BRIDGE_VLAN_STATS_ENABLED_DEF, NM_SETTING_PARAM_INFERRABLE, - NMSettingBridgePrivate, - vlan_stats_enabled); + NMSettingBridge, + _priv.vlan_stats_enabled); /** * NMSettingBridge:multicast-router: @@ -1843,8 +1843,8 @@ nm_setting_bridge_class_init(NMSettingBridgeClass *klass) NM_SETTING_BRIDGE_MULTICAST_ROUTER, PROP_MULTICAST_ROUTER, NM_SETTING_PARAM_INFERRABLE, - NMSettingBridgePrivate, - multicast_router); + NMSettingBridge, + _priv.multicast_router); /** * NMSettingBridge:multicast-query-use-ifaddr: @@ -1868,8 +1868,8 @@ nm_setting_bridge_class_init(NMSettingBridgeClass *klass) PROP_MULTICAST_QUERY_USE_IFADDR, NM_BRIDGE_MULTICAST_QUERY_USE_IFADDR_DEF, NM_SETTING_PARAM_INFERRABLE, - NMSettingBridgePrivate, - multicast_query_use_ifaddr); + NMSettingBridge, + _priv.multicast_query_use_ifaddr); /** * NMSettingBridge:multicast-querier: @@ -1892,8 +1892,8 @@ nm_setting_bridge_class_init(NMSettingBridgeClass *klass) PROP_MULTICAST_QUERIER, NM_BRIDGE_MULTICAST_QUERIER_DEF, NM_SETTING_PARAM_INFERRABLE, - NMSettingBridgePrivate, - multicast_querier); + NMSettingBridge, + _priv.multicast_querier); /** * NMSettingBridge:multicast-hash-max: @@ -1917,8 +1917,8 @@ nm_setting_bridge_class_init(NMSettingBridgeClass *klass) NM_BRIDGE_MULTICAST_HASH_MAX_MAX, NM_BRIDGE_MULTICAST_HASH_MAX_DEF, NM_SETTING_PARAM_INFERRABLE, - NMSettingBridgePrivate, - multicast_hash_max); + NMSettingBridge, + _priv.multicast_hash_max); /** * NMSettingBridge:multicast-last-member-count: @@ -1944,8 +1944,8 @@ nm_setting_bridge_class_init(NMSettingBridgeClass *klass) NM_BRIDGE_MULTICAST_LAST_MEMBER_COUNT_MAX, NM_BRIDGE_MULTICAST_LAST_MEMBER_COUNT_DEF, NM_SETTING_PARAM_INFERRABLE, - NMSettingBridgePrivate, - multicast_last_member_count); + NMSettingBridge, + _priv.multicast_last_member_count); /** * NMSettingBridge:multicast-last-member-interval: @@ -1970,8 +1970,8 @@ nm_setting_bridge_class_init(NMSettingBridgeClass *klass) NM_BRIDGE_MULTICAST_LAST_MEMBER_INTERVAL_MAX, NM_BRIDGE_MULTICAST_LAST_MEMBER_INTERVAL_DEF, NM_SETTING_PARAM_INFERRABLE, - NMSettingBridgePrivate, - multicast_last_member_interval); + NMSettingBridge, + _priv.multicast_last_member_interval); /** * NMSettingBridge:multicast-membership-interval: @@ -1997,8 +1997,8 @@ nm_setting_bridge_class_init(NMSettingBridgeClass *klass) NM_BRIDGE_MULTICAST_MEMBERSHIP_INTERVAL_MAX, NM_BRIDGE_MULTICAST_MEMBERSHIP_INTERVAL_DEF, NM_SETTING_PARAM_INFERRABLE, - NMSettingBridgePrivate, - multicast_membership_interval); + NMSettingBridge, + _priv.multicast_membership_interval); /** * NMSettingBridge:multicast-querier-interval: @@ -2023,8 +2023,8 @@ nm_setting_bridge_class_init(NMSettingBridgeClass *klass) NM_BRIDGE_MULTICAST_QUERIER_INTERVAL_MAX, NM_BRIDGE_MULTICAST_QUERIER_INTERVAL_DEF, NM_SETTING_PARAM_INFERRABLE, - NMSettingBridgePrivate, - multicast_querier_interval); + NMSettingBridge, + _priv.multicast_querier_interval); /** * NMSettingBridge:multicast-query-interval: @@ -2049,8 +2049,8 @@ nm_setting_bridge_class_init(NMSettingBridgeClass *klass) NM_BRIDGE_MULTICAST_QUERY_INTERVAL_MAX, NM_BRIDGE_MULTICAST_QUERY_INTERVAL_DEF, NM_SETTING_PARAM_INFERRABLE, - NMSettingBridgePrivate, - multicast_query_interval); + NMSettingBridge, + _priv.multicast_query_interval); /** * NMSettingBridge:multicast-query-response-interval: @@ -2075,8 +2075,8 @@ nm_setting_bridge_class_init(NMSettingBridgeClass *klass) NM_BRIDGE_MULTICAST_QUERY_RESPONSE_INTERVAL_MAX, NM_BRIDGE_MULTICAST_QUERY_RESPONSE_INTERVAL_DEF, NM_SETTING_PARAM_INFERRABLE, - NMSettingBridgePrivate, - multicast_query_response_interval); + NMSettingBridge, + _priv.multicast_query_response_interval); /** * NMSettingBridge:multicast-startup-query-count: @@ -2100,8 +2100,8 @@ nm_setting_bridge_class_init(NMSettingBridgeClass *klass) NM_BRIDGE_MULTICAST_STARTUP_QUERY_COUNT_MAX, NM_BRIDGE_MULTICAST_STARTUP_QUERY_COUNT_DEF, NM_SETTING_PARAM_INFERRABLE, - NMSettingBridgePrivate, - multicast_startup_query_count); + NMSettingBridge, + _priv.multicast_startup_query_count); /** * NMSettingBridge:multicast-startup-query-interval: @@ -2126,8 +2126,8 @@ nm_setting_bridge_class_init(NMSettingBridgeClass *klass) NM_BRIDGE_MULTICAST_STARTUP_QUERY_INTERVAL_MAX, NM_BRIDGE_MULTICAST_STARTUP_QUERY_INTERVAL_DEF, NM_SETTING_PARAM_INFERRABLE, - NMSettingBridgePrivate, - multicast_startup_query_interval); + NMSettingBridge, + _priv.multicast_startup_query_interval); g_object_class_install_properties(object_class, _PROPERTY_ENUMS_LAST, obj_properties); @@ -2135,5 +2135,5 @@ nm_setting_bridge_class_init(NMSettingBridgeClass *klass) NM_META_SETTING_TYPE_BRIDGE, NULL, properties_override, - G_STRUCT_OFFSET(NMSettingBridge, _priv)); + 0); } diff --git a/src/libnm-core-impl/nm-setting-cdma.c b/src/libnm-core-impl/nm-setting-cdma.c index 214f3b91..46f29f96 100644 --- a/src/libnm-core-impl/nm-setting-cdma.c +++ b/src/libnm-core-impl/nm-setting-cdma.c @@ -29,9 +29,9 @@ NM_GOBJECT_PROPERTIES_DEFINE_BASE(PROP_NUMBER, PROP_MTU, ); typedef struct { - char * number; - char * username; - char * password; + char *number; + char *username; + char *password; guint32 mtu; NMSettingSecretFlags password_flags; } NMSettingCdmaPrivate; @@ -177,7 +177,7 @@ static GPtrArray * need_secrets(NMSetting *setting) { NMSettingCdmaPrivate *priv = NM_SETTING_CDMA_GET_PRIVATE(setting); - GPtrArray * secrets = NULL; + GPtrArray *secrets = NULL; if (!nm_str_is_empty(priv->password)) return NULL; @@ -214,9 +214,9 @@ nm_setting_cdma_new(void) static void nm_setting_cdma_class_init(NMSettingCdmaClass *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(NMSettingCdmaPrivate)); diff --git a/src/libnm-core-impl/nm-setting-connection.c b/src/libnm-core-impl/nm-setting-connection.c index 322250f8..73611004 100644 --- a/src/libnm-core-impl/nm-setting-connection.c +++ b/src/libnm-core-impl/nm-setting-connection.c @@ -39,7 +39,7 @@ typedef enum _nm_packed { typedef struct { PermType ptype; - char * item; + char *item; } Permission; NM_GOBJECT_PROPERTIES_DEFINE(NMSettingConnection, @@ -73,15 +73,15 @@ NM_GOBJECT_PROPERTIES_DEFINE(NMSettingConnection, typedef struct { GArray *permissions; GArray *secondaries; - char * id; - char * uuid; - char * stable_id; - char * interface_name; - char * type; - char * master; - char * slave_type; - char * zone; - char * mud_url; + char *id; + char *uuid; + char *stable_id; + char *interface_name; + char *type; + char *master; + char *slave_type; + char *zone; + char *mud_url; guint64 timestamp; int autoconnect_slaves; int metered; @@ -322,12 +322,12 @@ nm_setting_connection_get_num_permissions(NMSettingConnection *setting) gboolean nm_setting_connection_get_permission(NMSettingConnection *setting, guint32 idx, - const char ** out_ptype, - const char ** out_pitem, - const char ** out_detail) + const char **out_ptype, + const char **out_pitem, + const char **out_detail) { NMSettingConnectionPrivate *priv; - Permission * permission; + Permission *permission; g_return_val_if_fail(NM_IS_SETTING_CONNECTION(setting), FALSE); @@ -408,9 +408,9 @@ nm_setting_connection_permissions_user_allowed(NMSettingConnection *setting, con */ gboolean nm_setting_connection_add_permission(NMSettingConnection *setting, - const char * ptype, - const char * pitem, - const char * detail) + const char *ptype, + const char *pitem, + const char *detail) { NMSettingConnectionPrivate *priv; guint i; @@ -487,9 +487,9 @@ nm_setting_connection_remove_permission(NMSettingConnection *setting, guint32 id */ gboolean nm_setting_connection_remove_permission_by_value(NMSettingConnection *setting, - const char * ptype, - const char * pitem, - const char * detail) + const char *ptype, + const char *pitem, + const char *detail) { NMSettingConnectionPrivate *priv; guint i; @@ -1009,20 +1009,20 @@ _set_error_missing_base_setting(GError **error, const char *type) gboolean _nm_connection_detect_slave_type_full(NMSettingConnection *s_con, - NMConnection * connection, - const char ** out_slave_type, - const char ** out_normerr_slave_setting_type, - const char ** out_normerr_missing_slave_type, - const char ** out_normerr_missing_slave_type_port, - GError ** error) + NMConnection *connection, + const char **out_slave_type, + const char **out_normerr_slave_setting_type, + const char **out_normerr_missing_slave_type, + const char **out_normerr_missing_slave_type_port, + GError **error) { NMSettingConnectionPrivate *priv = NM_SETTING_CONNECTION_GET_PRIVATE(s_con); gboolean is_slave; - const char * slave_setting_type; - const char * slave_type; - const char * normerr_slave_setting_type = NULL; - const char * normerr_missing_slave_type = NULL; - const char * normerr_missing_slave_type_port = NULL; + const char *slave_setting_type; + const char *slave_type; + const char *normerr_slave_setting_type = NULL; + const char *normerr_missing_slave_type = NULL; + const char *normerr_missing_slave_type_port = NULL; is_slave = FALSE; slave_setting_type = NULL; @@ -1094,14 +1094,14 @@ _nm_connection_detect_slave_type_full(NMSettingConnection *s_con, static gboolean verify(NMSetting *setting, NMConnection *connection, GError **error) { - NMSettingConnection * self = NM_SETTING_CONNECTION(setting); + NMSettingConnection *self = NM_SETTING_CONNECTION(setting); NMSettingConnectionPrivate *priv = NM_SETTING_CONNECTION_GET_PRIVATE(self); - NMSetting * normerr_base_type = NULL; - const char * type; - const char * slave_type; - const char * normerr_slave_setting_type = NULL; - const char * normerr_missing_slave_type = NULL; - const char * normerr_missing_slave_type_port = NULL; + NMSetting *normerr_base_type = NULL; + const char *type; + const char *slave_type; + const char *normerr_slave_setting_type = NULL; + const char *normerr_missing_slave_type = NULL; + const char *normerr_missing_slave_type_port = NULL; gboolean normerr_base_setting = FALSE; gboolean uuid_was_normalized = FALSE; @@ -1187,7 +1187,7 @@ verify(NMSetting *setting, NMConnection *connection, GError **error) /* Make sure the corresponding 'type' item is present */ if (connection && !nm_connection_get_setting_by_name(connection, type)) { - NMSetting * s_base; + NMSetting *s_base; NMConnection *connection2; s_base = g_object_new(base_type, NULL); @@ -1206,7 +1206,7 @@ verify(NMSetting *setting, NMConnection *connection, GError **error) } if (priv->interface_name) { - GError * tmp_error = NULL; + GError *tmp_error = NULL; NMUtilsIfaceType iface_type; if (NM_IN_STRSET(type, @@ -1215,7 +1215,7 @@ verify(NMSetting *setting, NMConnection *connection, GError **error) iface_type = NMU_IFACE_OVS; else if (nm_streq(type, NM_SETTING_OVS_INTERFACE_SETTING_NAME)) { NMSettingOvsInterface *s_ovs_iface = NULL; - const char * ovs_iface_type; + const char *ovs_iface_type; if (connection) s_ovs_iface = nm_connection_get_setting_ovs_interface(connection); @@ -1533,7 +1533,7 @@ after_interface_name: static const char * find_virtual_interface_name(GVariant *connection_dict, GVariant **variant_to_free) { - GVariant * setting_dict; + GVariant *setting_dict; const char *interface_name; nm_assert(variant_to_free && !*variant_to_free); @@ -1569,7 +1569,7 @@ find_virtual_interface_name(GVariant *connection_dict, GVariant **variant_to_fre static gboolean nm_setting_connection_no_interface_name(_NM_SETT_INFO_PROP_MISSING_FROM_DBUS_FCN_ARGS _nm_nil) { - const char * virtual_interface_name; + const char *virtual_interface_name; gs_unref_variant GVariant *variant_to_free = NULL; virtual_interface_name = find_virtual_interface_name(connection_dict, &variant_to_free); @@ -1615,7 +1615,7 @@ compare_fcn_timestamp(_NM_SETT_INFO_PROP_COMPARE_FCN_ARGS _nm_nil) static void get_property(GObject *object, guint prop_id, GValue *value, GParamSpec *pspec) { - NMSettingConnection * setting = NM_SETTING_CONNECTION(object); + NMSettingConnection *setting = NM_SETTING_CONNECTION(object); NMSettingConnectionPrivate *priv = NM_SETTING_CONNECTION_GET_PRIVATE(setting); switch (prop_id) { @@ -1717,9 +1717,9 @@ finalize(GObject *object) static void nm_setting_connection_class_init(NMSettingConnectionClass *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(NMSettingConnectionPrivate)); @@ -1908,7 +1908,8 @@ nm_setting_connection_class_init(NMSettingConnectionClass *klass) PROP_TYPE, NM_SETTING_PARAM_INFERRABLE, NMSettingConnectionPrivate, - type); + type, + .direct_string_is_refstr = TRUE); /** * NMSettingConnection:permissions: diff --git a/src/libnm-core-impl/nm-setting-dcb.c b/src/libnm-core-impl/nm-setting-dcb.c index a6f4a973..d6890891 100644 --- a/src/libnm-core-impl/nm-setting-dcb.c +++ b/src/libnm-core-impl/nm-setting-dcb.c @@ -48,7 +48,7 @@ NM_GOBJECT_PROPERTIES_DEFINE(NMSettingDcb, PROP_PRIORITY_TRAFFIC_CLASS, ); typedef struct { - char * app_fcoe_mode; + char *app_fcoe_mode; guint pfc[8]; guint priority_group_id[8]; guint priority_group_bandwidth[8]; @@ -514,14 +514,14 @@ check_dcb_flags(NMSettingDcbFlags flags, const char *prop_name, GError **error) } static gboolean -check_uint_array(const guint * array, +check_uint_array(const guint *array, guint len, NMSettingDcbFlags flags, guint max, guint extra, gboolean sum_pct, - const char * prop_name, - GError ** error) + const char *prop_name, + GError **error) { guint i, sum = 0; @@ -714,7 +714,7 @@ G_STATIC_ASSERT(sizeof(guint) == sizeof(gboolean)); static void set_array_from_gvalue(const GValue *v, uint *a, size_t len) { - GArray * src = g_value_get_boxed(v); + GArray *src = g_value_get_boxed(v); const guint total_len = len * sizeof(a[0]); memset(a, 0, total_len); @@ -761,7 +761,7 @@ static const NMSettInfoPropertType nm_sett_info_propert_type_dcb_au = static void get_property(GObject *object, guint prop_id, GValue *value, GParamSpec *pspec) { - NMSettingDcb * setting = NM_SETTING_DCB(object); + NMSettingDcb *setting = NM_SETTING_DCB(object); NMSettingDcbPrivate *priv = NM_SETTING_DCB_GET_PRIVATE(setting); switch (prop_id) { @@ -841,9 +841,9 @@ nm_setting_dcb_new(void) static void nm_setting_dcb_class_init(NMSettingDcbClass *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(NMSettingDcbPrivate)); diff --git a/src/libnm-core-impl/nm-setting-ethtool.c b/src/libnm-core-impl/nm-setting-ethtool.c index 901dab48..49c0d780 100644 --- a/src/libnm-core-impl/nm-setting-ethtool.c +++ b/src/libnm-core-impl/nm-setting-ethtool.c @@ -212,14 +212,14 @@ nm_setting_ethtool_clear_features(NMSettingEthtool *setting) guint nm_setting_ethtool_init_features( NMSettingEthtool *setting, - NMOptionBool * requested /* indexed by NMEthtoolID - _NM_ETHTOOL_ID_FEATURE_FIRST */) + NMOptionBool *requested /* indexed by NMEthtoolID - _NM_ETHTOOL_ID_FEATURE_FIRST */) { - GHashTable * hash; + GHashTable *hash; GHashTableIter iter; guint i; guint n_req = 0; - const char * name; - GVariant * variant; + const char *name; + GVariant *variant; nm_assert(NM_IS_SETTING_ETHTOOL(setting)); nm_assert(requested); @@ -286,7 +286,7 @@ static gboolean verify(NMSetting *setting, NMConnection *connection, GError **error) { const char *const *optnames; - GVariant *const * variants; + GVariant *const *variants; guint len; guint i; NMTernary pause_autoneg = NM_TERNARY_DEFAULT; @@ -296,8 +296,8 @@ verify(NMSetting *setting, NMConnection *connection, GError **error) len = _nm_setting_option_get_all(setting, &optnames, &variants); for (i = 0; i < len; i++) { - const char * optname = optnames[i]; - GVariant * variant = variants[i]; + const char *optname = optnames[i]; + GVariant *variant = variants[i]; const GVariantType *variant_type; NMEthtoolID ethtool_id; diff --git a/src/libnm-core-impl/nm-setting-gsm.c b/src/libnm-core-impl/nm-setting-gsm.c index 8b2749d9..15460ccc 100644 --- a/src/libnm-core-impl/nm-setting-gsm.c +++ b/src/libnm-core-impl/nm-setting-gsm.c @@ -39,20 +39,20 @@ NM_GOBJECT_PROPERTIES_DEFINE_BASE(PROP_AUTO_CONFIG, PROP_MTU, ); typedef struct { - char * number; /* For dialing, duh */ - char * username; - char * password; - char * device_id; - char * sim_id; - char * sim_operator_id; - char * apn; /* NULL for dynamic */ - char * network_id; /* for manual registration or NULL for automatic */ - char * pin; - NMSettingSecretFlags password_flags; - NMSettingSecretFlags pin_flags; - guint32 mtu; - bool auto_config; - bool home_only; + char *number; + char *username; + char *password; + char *device_id; + char *sim_id; + char *sim_operator_id; + char *apn; + char *network_id; + char *pin; + guint password_flags; + guint pin_flags; + guint32 mtu; + bool auto_config; + bool home_only; } NMSettingGsmPrivate; /** @@ -463,7 +463,7 @@ static GPtrArray * need_secrets(NMSetting *setting) { NMSettingGsmPrivate *priv = NM_SETTING_GSM_GET_PRIVATE(setting); - GPtrArray * secrets = NULL; + GPtrArray *secrets = NULL; if (priv->password && *priv->password) return NULL; @@ -481,132 +481,6 @@ need_secrets(NMSetting *setting) /*****************************************************************************/ static void -get_property(GObject *object, guint prop_id, GValue *value, GParamSpec *pspec) -{ - NMSettingGsm *setting = NM_SETTING_GSM(object); - - switch (prop_id) { - case PROP_AUTO_CONFIG: - g_value_set_boolean(value, nm_setting_gsm_get_auto_config(setting)); - break; - case PROP_NUMBER: - g_value_set_string(value, nm_setting_gsm_get_number(setting)); - break; - case PROP_USERNAME: - g_value_set_string(value, nm_setting_gsm_get_username(setting)); - break; - case PROP_PASSWORD: - g_value_set_string(value, nm_setting_gsm_get_password(setting)); - break; - case PROP_PASSWORD_FLAGS: - g_value_set_flags(value, nm_setting_gsm_get_password_flags(setting)); - break; - case PROP_APN: - g_value_set_string(value, nm_setting_gsm_get_apn(setting)); - break; - case PROP_NETWORK_ID: - g_value_set_string(value, nm_setting_gsm_get_network_id(setting)); - break; - case PROP_PIN: - g_value_set_string(value, nm_setting_gsm_get_pin(setting)); - break; - case PROP_PIN_FLAGS: - g_value_set_flags(value, nm_setting_gsm_get_pin_flags(setting)); - break; - case PROP_HOME_ONLY: - g_value_set_boolean(value, nm_setting_gsm_get_home_only(setting)); - break; - case PROP_DEVICE_ID: - g_value_set_string(value, nm_setting_gsm_get_device_id(setting)); - break; - case PROP_SIM_ID: - g_value_set_string(value, nm_setting_gsm_get_sim_id(setting)); - break; - case PROP_SIM_OPERATOR_ID: - g_value_set_string(value, nm_setting_gsm_get_sim_operator_id(setting)); - break; - case PROP_MTU: - g_value_set_uint(value, nm_setting_gsm_get_mtu(setting)); - break; - default: - G_OBJECT_WARN_INVALID_PROPERTY_ID(object, prop_id, pspec); - break; - } -} - -static void -set_property(GObject *object, guint prop_id, const GValue *value, GParamSpec *pspec) -{ - NMSettingGsmPrivate *priv = NM_SETTING_GSM_GET_PRIVATE(object); - char * tmp; - - switch (prop_id) { - case PROP_AUTO_CONFIG: - priv->auto_config = g_value_get_boolean(value); - break; - case PROP_NUMBER: - g_free(priv->number); - priv->number = g_value_dup_string(value); - break; - case PROP_USERNAME: - g_free(priv->username); - priv->username = g_value_dup_string(value); - break; - case PROP_PASSWORD: - g_free(priv->password); - priv->password = g_value_dup_string(value); - break; - case PROP_PASSWORD_FLAGS: - priv->password_flags = g_value_get_flags(value); - break; - case PROP_APN: - g_free(priv->apn); - priv->apn = NULL; - tmp = g_value_dup_string(value); - if (tmp) - priv->apn = g_strstrip(tmp); - break; - case PROP_NETWORK_ID: - g_free(priv->network_id); - priv->network_id = NULL; - tmp = g_value_dup_string(value); - if (tmp) - priv->network_id = g_strstrip(tmp); - break; - case PROP_PIN: - g_free(priv->pin); - priv->pin = g_value_dup_string(value); - break; - case PROP_PIN_FLAGS: - priv->pin_flags = g_value_get_flags(value); - break; - case PROP_HOME_ONLY: - priv->home_only = g_value_get_boolean(value); - break; - case PROP_DEVICE_ID: - g_free(priv->device_id); - priv->device_id = g_value_dup_string(value); - break; - case PROP_SIM_ID: - g_free(priv->sim_id); - priv->sim_id = g_value_dup_string(value); - break; - case PROP_SIM_OPERATOR_ID: - g_free(priv->sim_operator_id); - priv->sim_operator_id = g_value_dup_string(value); - break; - case PROP_MTU: - priv->mtu = g_value_get_uint(value); - break; - default: - G_OBJECT_WARN_INVALID_PROPERTY_ID(object, prop_id, pspec); - break; - } -} - -/*****************************************************************************/ - -static void nm_setting_gsm_init(NMSettingGsm *setting) {} @@ -624,35 +498,16 @@ nm_setting_gsm_new(void) } static void -finalize(GObject *object) -{ - NMSettingGsmPrivate *priv = NM_SETTING_GSM_GET_PRIVATE(object); - - g_free(priv->number); - g_free(priv->username); - g_free(priv->password); - g_free(priv->apn); - g_free(priv->network_id); - g_free(priv->pin); - g_free(priv->device_id); - g_free(priv->sim_id); - g_free(priv->sim_operator_id); - - G_OBJECT_CLASS(nm_setting_gsm_parent_class)->finalize(object); -} - -static void nm_setting_gsm_class_init(NMSettingGsmClass *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(NMSettingGsmPrivate)); - object_class->get_property = get_property; - object_class->set_property = set_property; - object_class->finalize = finalize; + object_class->get_property = _nm_setting_property_get_property_direct; + object_class->set_property = _nm_setting_property_set_property_direct; setting_class->verify = verify; setting_class->verify_secrets = verify_secrets; @@ -684,11 +539,13 @@ nm_setting_gsm_class_init(NMSettingGsmClass *klass) * * Deprecated: 1.16: User-provided values for this setting are no longer used. **/ - obj_properties[PROP_NUMBER] = g_param_spec_string(NM_SETTING_GSM_NUMBER, - "", - "", - NULL, - G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS); + _nm_setting_property_define_direct_string(properties_override, + obj_properties, + NM_SETTING_GSM_NUMBER, + PROP_NUMBER, + NM_SETTING_PARAM_NONE, + NMSettingGsmPrivate, + number); /** * NMSettingGsm:username: @@ -697,11 +554,13 @@ nm_setting_gsm_class_init(NMSettingGsmClass *klass) * providers do not require a username, or accept any username. But if a * username is required, it is specified here. **/ - obj_properties[PROP_USERNAME] = g_param_spec_string(NM_SETTING_GSM_USERNAME, - "", - "", - NULL, - G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS); + _nm_setting_property_define_direct_string(properties_override, + obj_properties, + NM_SETTING_GSM_USERNAME, + PROP_USERNAME, + NM_SETTING_PARAM_NONE, + NMSettingGsmPrivate, + username); /** * NMSettingGsm:password: @@ -710,26 +569,25 @@ nm_setting_gsm_class_init(NMSettingGsmClass *klass) * providers do not require a password, or accept any password. But if a * password is required, it is specified here. **/ - obj_properties[PROP_PASSWORD] = - g_param_spec_string(NM_SETTING_GSM_PASSWORD, - "", - "", - NULL, - G_PARAM_READWRITE | NM_SETTING_PARAM_SECRET | G_PARAM_STATIC_STRINGS); + _nm_setting_property_define_direct_string(properties_override, + obj_properties, + NM_SETTING_GSM_PASSWORD, + PROP_PASSWORD, + NM_SETTING_PARAM_SECRET, + NMSettingGsmPrivate, + password); /** * NMSettingGsm:password-flags: * * Flags indicating how to handle the #NMSettingGsm:password property. **/ - obj_properties[PROP_PASSWORD_FLAGS] = - g_param_spec_flags(NM_SETTING_GSM_PASSWORD_FLAGS, - "", - "", - NM_TYPE_SETTING_SECRET_FLAGS, - NM_SETTING_SECRET_FLAG_NONE, - G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS); - + _nm_setting_property_define_direct_secret_flags(properties_override, + obj_properties, + NM_SETTING_GSM_PASSWORD_FLAGS, + PROP_PASSWORD_FLAGS, + NMSettingGsmPrivate, + password_flags); /** * NMSettingGsm:apn: * @@ -741,11 +599,14 @@ nm_setting_gsm_class_init(NMSettingGsmClass *klass) * The APN may only be composed of the characters a-z, 0-9, ., and - per GSM * 03.60 Section 14.9. **/ - obj_properties[PROP_APN] = g_param_spec_string(NM_SETTING_GSM_APN, - "", - "", - NULL, - G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS); + _nm_setting_property_define_direct_string(properties_override, + obj_properties, + NM_SETTING_GSM_APN, + PROP_APN, + NM_SETTING_PARAM_NONE, + NMSettingGsmPrivate, + apn, + .direct_set_string_strip = TRUE); /** * NMSettingGsm:network-id: @@ -756,12 +617,14 @@ nm_setting_gsm_class_init(NMSettingGsmClass *klass) * This can be used to ensure that the device does not roam when direct * roaming control of the device is not otherwise possible. **/ - obj_properties[PROP_NETWORK_ID] = - g_param_spec_string(NM_SETTING_GSM_NETWORK_ID, - "", - "", - NULL, - G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS); + _nm_setting_property_define_direct_string(properties_override, + obj_properties, + NM_SETTING_GSM_NETWORK_ID, + PROP_NETWORK_ID, + NM_SETTING_PARAM_NONE, + NMSettingGsmPrivate, + network_id, + .direct_set_string_strip = TRUE); /** * NMSettingGsm:pin: @@ -770,24 +633,25 @@ nm_setting_gsm_class_init(NMSettingGsmClass *klass) * operations are requested. Specify the PIN here to allow operation of the * device. **/ - obj_properties[PROP_PIN] = - g_param_spec_string(NM_SETTING_GSM_PIN, - "", - "", - NULL, - G_PARAM_READWRITE | NM_SETTING_PARAM_SECRET | G_PARAM_STATIC_STRINGS); + _nm_setting_property_define_direct_string(properties_override, + obj_properties, + NM_SETTING_GSM_PIN, + PROP_PIN, + NM_SETTING_PARAM_SECRET, + NMSettingGsmPrivate, + pin); /** * NMSettingGsm:pin-flags: * * Flags indicating how to handle the #NMSettingGsm:pin property. **/ - obj_properties[PROP_PIN_FLAGS] = g_param_spec_flags(NM_SETTING_GSM_PIN_FLAGS, - "", - "", - NM_TYPE_SETTING_SECRET_FLAGS, - NM_SETTING_SECRET_FLAG_NONE, - G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS); + _nm_setting_property_define_direct_secret_flags(properties_override, + obj_properties, + NM_SETTING_GSM_PIN_FLAGS, + PROP_PIN_FLAGS, + NMSettingGsmPrivate, + pin_flags); /** * NMSettingGsm:home-only: @@ -813,12 +677,13 @@ nm_setting_gsm_class_init(NMSettingGsmClass *klass) * * Since: 1.2 **/ - obj_properties[PROP_DEVICE_ID] = - g_param_spec_string(NM_SETTING_GSM_DEVICE_ID, - "", - "", - NULL, - G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS); + _nm_setting_property_define_direct_string(properties_override, + obj_properties, + NM_SETTING_GSM_DEVICE_ID, + PROP_DEVICE_ID, + NM_SETTING_PARAM_NONE, + NMSettingGsmPrivate, + device_id); /** * NMSettingGsm:sim-id: @@ -830,11 +695,13 @@ nm_setting_gsm_class_init(NMSettingGsmClass *klass) * * Since: 1.2 **/ - obj_properties[PROP_SIM_ID] = g_param_spec_string(NM_SETTING_GSM_SIM_ID, - "", - "", - NULL, - G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS); + _nm_setting_property_define_direct_string(properties_override, + obj_properties, + NM_SETTING_GSM_SIM_ID, + PROP_SIM_ID, + NM_SETTING_PARAM_NONE, + NMSettingGsmPrivate, + sim_id); /** * NMSettingGsm:sim-operator-id: @@ -847,12 +714,13 @@ nm_setting_gsm_class_init(NMSettingGsmClass *klass) * * Since: 1.2 **/ - obj_properties[PROP_SIM_OPERATOR_ID] = - g_param_spec_string(NM_SETTING_GSM_SIM_OPERATOR_ID, - "", - "", - NULL, - G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS); + _nm_setting_property_define_direct_string(properties_override, + obj_properties, + NM_SETTING_GSM_SIM_OPERATOR_ID, + PROP_SIM_OPERATOR_ID, + NM_SETTING_PARAM_NONE, + NMSettingGsmPrivate, + sim_operator_id); /** * NMSettingGsm:mtu: @@ -862,14 +730,16 @@ nm_setting_gsm_class_init(NMSettingGsmClass *klass) * * Since: 1.8 **/ - obj_properties[PROP_MTU] = g_param_spec_uint(NM_SETTING_GSM_MTU, - "", - "", - 0, - G_MAXUINT32, - 0, - G_PARAM_READWRITE | NM_SETTING_PARAM_FUZZY_IGNORE - | G_PARAM_STATIC_STRINGS); + _nm_setting_property_define_direct_uint32(properties_override, + obj_properties, + NM_SETTING_GSM_MTU, + PROP_MTU, + 0, + G_MAXUINT32, + 0, + NM_SETTING_PARAM_FUZZY_IGNORE, + NMSettingGsmPrivate, + mtu); /* Ignore incoming deprecated properties */ _nm_properties_override_dbus(properties_override, diff --git a/src/libnm-core-impl/nm-setting-hostname.c b/src/libnm-core-impl/nm-setting-hostname.c index d0a15684..276a75a8 100644 --- a/src/libnm-core-impl/nm-setting-hostname.c +++ b/src/libnm-core-impl/nm-setting-hostname.c @@ -145,9 +145,9 @@ nm_setting_hostname_new(void) static void nm_setting_hostname_class_init(NMSettingHostnameClass *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(); object_class->get_property = _nm_setting_property_get_property_direct; object_class->set_property = _nm_setting_property_set_property_direct; diff --git a/src/libnm-core-impl/nm-setting-infiniband.c b/src/libnm-core-impl/nm-setting-infiniband.c index adbf3636..eb6c9536 100644 --- a/src/libnm-core-impl/nm-setting-infiniband.c +++ b/src/libnm-core-impl/nm-setting-infiniband.c @@ -32,11 +32,13 @@ NM_GOBJECT_PROPERTIES_DEFINE_BASE(PROP_MAC_ADDRESS, PROP_PARENT, ); typedef struct { - char * mac_address; - char * transport_mode; - char * parent; - char * virtual_iface_name; - int p_key; + char *mac_address; + char *transport_mode; + char *parent; + char *virtual_iface_name; + gsize virtual_iface_name_parent_length; + gint32 virtual_iface_name_p_key; + gint32 p_key; guint32 mtu; } NMSettingInfinibandPrivate; @@ -156,20 +158,30 @@ const char * nm_setting_infiniband_get_virtual_interface_name(NMSettingInfiniband *setting) { NMSettingInfinibandPrivate *priv = NM_SETTING_INFINIBAND_GET_PRIVATE(setting); + gsize len; - if (priv->p_key == -1 || !priv->parent) + if (priv->p_key == -1 || !priv->parent) { + nm_clear_g_free(&priv->virtual_iface_name); return NULL; + } - if (!priv->virtual_iface_name) + len = strlen(priv->parent); + if (!priv->virtual_iface_name || priv->virtual_iface_name_p_key != priv->p_key + || priv->virtual_iface_name_parent_length != len + || memcmp(priv->parent, priv->virtual_iface_name, len) != 0) { + priv->virtual_iface_name_p_key = priv->p_key; + priv->virtual_iface_name_parent_length = len; + g_free(priv->virtual_iface_name); priv->virtual_iface_name = g_strdup_printf("%s.%04x", priv->parent, priv->p_key); + } - return NM_SETTING_INFINIBAND_GET_PRIVATE(setting)->virtual_iface_name; + return priv->virtual_iface_name; } static gboolean verify(NMSetting *setting, NMConnection *connection, GError **error) { - NMSettingConnection * s_con = NULL; + NMSettingConnection *s_con = NULL; NMSettingInfinibandPrivate *priv = NM_SETTING_INFINIBAND_GET_PRIVATE(setting); if (priv->mac_address && !nm_utils_hwaddr_valid(priv->mac_address, INFINIBAND_ALEN)) { @@ -237,10 +249,12 @@ verify(NMSetting *setting, NMConnection *connection, GError **error) const char *interface_name = nm_setting_connection_get_interface_name(s_con); if (interface_name && priv->p_key != -1) { - if (!priv->virtual_iface_name) - priv->virtual_iface_name = g_strdup_printf("%s.%04x", priv->parent, priv->p_key); + const char *virtual_iface_name; - if (strcmp(interface_name, priv->virtual_iface_name) != 0) { + virtual_iface_name = + nm_setting_infiniband_get_virtual_interface_name(NM_SETTING_INFINIBAND(setting)); + + if (!nm_streq(interface_name, virtual_iface_name)) { /* We don't support renaming software infiniband devices. Later we might, but * for now just reject such connections. **/ @@ -249,7 +263,7 @@ verify(NMSetting *setting, NMConnection *connection, GError **error) NM_CONNECTION_ERROR_INVALID_PROPERTY, _("interface name of software infiniband device must be '%s' or unset " "(instead it is '%s')"), - priv->virtual_iface_name, + virtual_iface_name, interface_name); g_prefix_error(error, "%s.%s: ", @@ -291,74 +305,8 @@ verify(NMSetting *setting, NMConnection *connection, GError **error) /*****************************************************************************/ static void -get_property(GObject *object, guint prop_id, GValue *value, GParamSpec *pspec) -{ - NMSettingInfiniband *setting = NM_SETTING_INFINIBAND(object); - - switch (prop_id) { - case PROP_MAC_ADDRESS: - g_value_set_string(value, nm_setting_infiniband_get_mac_address(setting)); - break; - case PROP_MTU: - g_value_set_uint(value, nm_setting_infiniband_get_mtu(setting)); - break; - case PROP_TRANSPORT_MODE: - g_value_set_string(value, nm_setting_infiniband_get_transport_mode(setting)); - break; - case PROP_P_KEY: - g_value_set_int(value, nm_setting_infiniband_get_p_key(setting)); - break; - case PROP_PARENT: - g_value_set_string(value, nm_setting_infiniband_get_parent(setting)); - break; - default: - G_OBJECT_WARN_INVALID_PROPERTY_ID(object, prop_id, pspec); - break; - } -} - -static void -set_property(GObject *object, guint prop_id, const GValue *value, GParamSpec *pspec) -{ - NMSettingInfinibandPrivate *priv = NM_SETTING_INFINIBAND_GET_PRIVATE(object); - - switch (prop_id) { - case PROP_MAC_ADDRESS: - g_free(priv->mac_address); - priv->mac_address = - _nm_utils_hwaddr_canonical_or_invalid(g_value_get_string(value), INFINIBAND_ALEN); - break; - case PROP_MTU: - priv->mtu = g_value_get_uint(value); - break; - case PROP_TRANSPORT_MODE: - g_free(priv->transport_mode); - priv->transport_mode = g_value_dup_string(value); - break; - case PROP_P_KEY: - priv->p_key = g_value_get_int(value); - nm_clear_g_free(&priv->virtual_iface_name); - break; - case PROP_PARENT: - g_free(priv->parent); - priv->parent = g_value_dup_string(value); - nm_clear_g_free(&priv->virtual_iface_name); - break; - default: - G_OBJECT_WARN_INVALID_PROPERTY_ID(object, prop_id, pspec); - break; - } -} - -/*****************************************************************************/ - -static void nm_setting_infiniband_init(NMSettingInfiniband *self) -{ - NMSettingInfinibandPrivate *priv = NM_SETTING_INFINIBAND_GET_PRIVATE(self); - - priv->p_key = -1; -} +{} /** * nm_setting_infiniband_new: @@ -378,8 +326,6 @@ finalize(GObject *object) { NMSettingInfinibandPrivate *priv = NM_SETTING_INFINIBAND_GET_PRIVATE(object); - g_free(priv->transport_mode); - g_free(priv->parent); g_free(priv->virtual_iface_name); G_OBJECT_CLASS(nm_setting_infiniband_parent_class)->finalize(object); @@ -388,14 +334,14 @@ finalize(GObject *object) static void nm_setting_infiniband_class_init(NMSettingInfinibandClass *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(NMSettingInfinibandPrivate)); - object_class->get_property = get_property; - object_class->set_property = set_property; + 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; @@ -447,14 +393,16 @@ nm_setting_infiniband_class_init(NMSettingInfinibandClass *klass) * description: MTU of the interface. * ---end--- */ - obj_properties[PROP_MTU] = g_param_spec_uint(NM_SETTING_INFINIBAND_MTU, - "", - "", - 0, - G_MAXUINT32, - 0, - G_PARAM_READWRITE | NM_SETTING_PARAM_FUZZY_IGNORE - | G_PARAM_STATIC_STRINGS); + _nm_setting_property_define_direct_uint32(properties_override, + obj_properties, + NM_SETTING_INFINIBAND_MTU, + PROP_MTU, + 0, + G_MAXUINT32, + 0, + NM_SETTING_PARAM_FUZZY_IGNORE, + NMSettingInfinibandPrivate, + mtu); /** * NMSettingInfiniband:transport-mode: @@ -470,12 +418,13 @@ nm_setting_infiniband_class_init(NMSettingInfinibandClass *klass) * "datagram" mode * ---end--- */ - obj_properties[PROP_TRANSPORT_MODE] = g_param_spec_string( - NM_SETTING_INFINIBAND_TRANSPORT_MODE, - "", - "", - NULL, - G_PARAM_READWRITE | NM_SETTING_PARAM_INFERRABLE | G_PARAM_STATIC_STRINGS); + _nm_setting_property_define_direct_string(properties_override, + obj_properties, + NM_SETTING_INFINIBAND_TRANSPORT_MODE, + PROP_TRANSPORT_MODE, + NM_SETTING_PARAM_INFERRABLE, + NMSettingInfinibandPrivate, + transport_mode); /** * NMSettingInfiniband:p-key: @@ -495,14 +444,16 @@ nm_setting_infiniband_class_init(NMSettingInfinibandClass *klass) * example: PKEY=yes PKEY_ID=2 PHYSDEV=mlx4_ib0 DEVICE=mlx4_ib0.8002 * ---end--- */ - obj_properties[PROP_P_KEY] = - g_param_spec_int(NM_SETTING_INFINIBAND_P_KEY, - "", - "", - -1, - 0xFFFF, - -1, - G_PARAM_READWRITE | NM_SETTING_PARAM_INFERRABLE | G_PARAM_STATIC_STRINGS); + _nm_setting_property_define_direct_int32(properties_override, + obj_properties, + NM_SETTING_INFINIBAND_P_KEY, + PROP_P_KEY, + -1, + 0xFFFF, + -1, + NM_SETTING_PARAM_INFERRABLE, + NMSettingInfinibandPrivate, + p_key); /** * NMSettingInfiniband:parent: @@ -520,12 +471,13 @@ nm_setting_infiniband_class_init(NMSettingInfinibandClass *klass) * example: PHYSDEV=ib0 * ---end--- */ - obj_properties[PROP_PARENT] = g_param_spec_string( - NM_SETTING_INFINIBAND_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_INFINIBAND_PARENT, + PROP_PARENT, + NM_SETTING_PARAM_INFERRABLE, + NMSettingInfinibandPrivate, + parent); g_object_class_install_properties(object_class, _PROPERTY_ENUMS_LAST, obj_properties); diff --git a/src/libnm-core-impl/nm-setting-ip-config.c b/src/libnm-core-impl/nm-setting-ip-config.c index 33779ed9..52aa6515 100644 --- a/src/libnm-core-impl/nm-setting-ip-config.c +++ b/src/libnm-core-impl/nm-setting-ip-config.c @@ -54,56 +54,24 @@ const NMUtilsDNSOptionDesc _nm_utils_dns_option_descs[] = { {NULL, FALSE, FALSE}}; static char * -canonicalize_ip(int family, const char *ip, gboolean null_any) +canonicalize_ip_binary(int family, const NMIPAddr *ip, gboolean null_any) { - guint8 addr_bytes[sizeof(struct in6_addr)]; - char addr_str[NM_UTILS_INET_ADDRSTRLEN]; - int ret; - if (!ip) { if (null_any) return NULL; - if (family == AF_INET) + if (NM_IS_IPv4(family)) return g_strdup("0.0.0.0"); - if (family == AF_INET6) - return g_strdup("::"); - g_return_val_if_reached(NULL); + return g_strdup("::"); } - ret = inet_pton(family, ip, addr_bytes); - g_return_val_if_fail(ret == 1, NULL); - - if (null_any) { - if (!memcmp(addr_bytes, &in6addr_any, nm_utils_addr_family_to_size(family))) - return NULL; - } + if (null_any && nm_ip_addr_is_null(family, ip)) + return NULL; - return g_strdup(inet_ntop(family, addr_bytes, addr_str, sizeof(addr_str))); -} - -static char * -canonicalize_ip_binary(int family, gconstpointer ip, gboolean null_any) -{ - char string[NM_UTILS_INET_ADDRSTRLEN]; - - if (!ip) { - if (null_any) - return NULL; - if (family == AF_INET) - return g_strdup("0.0.0.0"); - if (family == AF_INET6) - return g_strdup("::"); - g_return_val_if_reached(NULL); - } - if (null_any) { - if (!memcmp(ip, &in6addr_any, nm_utils_addr_family_to_size(family))) - return NULL; - } - return g_strdup(inet_ntop(family, ip, string, sizeof(string))); + return nm_utils_inet_ntop_dup(family, ip); } static gboolean -valid_ip(int family, const char *ip, GError **error) +valid_ip(int family, const char *ip, NMIPAddr *addr, GError **error) { if (!ip) { g_set_error(error, @@ -112,7 +80,7 @@ valid_ip(int family, const char *ip, GError **error) family == AF_INET ? _("Missing IPv4 address") : _("Missing IPv6 address")); return FALSE; } - if (!nm_utils_ipaddr_is_valid(family, ip)) { + if (!nm_utils_parse_inaddr_bin(family, ip, NULL, addr)) { g_set_error(error, NM_CONNECTION_ERROR, NM_CONNECTION_ERROR_FAILED, @@ -120,8 +88,9 @@ valid_ip(int family, const char *ip, GError **error) : _("Invalid IPv6 address '%s'"), ip); return FALSE; - } else - return TRUE; + } + + return TRUE; } static gboolean @@ -169,9 +138,10 @@ G_DEFINE_BOXED_TYPE(NMIPAddress, nm_ip_address, nm_ip_address_dup, nm_ip_address struct NMIPAddress { guint refcount; - char *address; - int prefix, family; + gint8 family; + guint8 prefix; + char *address; GHashTable *attributes; }; @@ -191,21 +161,23 @@ NMIPAddress * nm_ip_address_new(int family, const char *addr, guint prefix, GError **error) { NMIPAddress *address; + NMIPAddr addr_bin; g_return_val_if_fail(family == AF_INET || family == AF_INET6, NULL); g_return_val_if_fail(addr != NULL, NULL); - if (!valid_ip(family, addr, error)) + if (!valid_ip(family, addr, &addr_bin, error)) return NULL; if (!valid_prefix(family, prefix, error)) return NULL; - address = g_slice_new0(NMIPAddress); - address->refcount = 1; - - address->family = family; - address->address = canonicalize_ip(family, addr, FALSE); - address->prefix = prefix; + address = g_slice_new(NMIPAddress); + *address = (NMIPAddress){ + .refcount = 1, + .family = family, + .address = canonicalize_ip_binary(family, &addr_bin, FALSE), + .prefix = prefix, + }; return address; } @@ -227,7 +199,6 @@ NMIPAddress * nm_ip_address_new_binary(int family, gconstpointer addr, guint prefix, GError **error) { NMIPAddress *address; - char string[NM_UTILS_INET_ADDRSTRLEN]; g_return_val_if_fail(family == AF_INET || family == AF_INET6, NULL); g_return_val_if_fail(addr != NULL, NULL); @@ -235,12 +206,13 @@ nm_ip_address_new_binary(int family, gconstpointer addr, guint prefix, GError ** if (!valid_prefix(family, prefix, error)) return NULL; - address = g_slice_new0(NMIPAddress); - address->refcount = 1; - - address->family = family; - address->address = g_strdup(inet_ntop(family, addr, string, sizeof(string))); - address->prefix = prefix; + address = g_slice_new(NMIPAddress); + *address = (NMIPAddress){ + .refcount = 1, + .family = family, + .address = nm_utils_inet_ntop_dup(family, addr), + .prefix = prefix, + }; return address; } @@ -276,9 +248,8 @@ nm_ip_address_unref(NMIPAddress *address) address->refcount--; if (address->refcount == 0) { g_free(address->address); - if (address->attributes) - g_hash_table_unref(address->attributes); - g_slice_free(NMIPAddress, address); + nm_g_hash_table_unref(address->attributes); + nm_g_slice_free(address); } } @@ -311,8 +282,8 @@ nm_ip_address_cmp_full(const NMIPAddress *a, const NMIPAddress *b, NMIPAddressCm if (NM_FLAGS_HAS(cmp_flags, NM_IP_ADDRESS_CMP_FLAGS_WITH_ATTRS)) { GHashTableIter iter; - const char * key; - GVariant * value, *value2; + const char *key; + GVariant *value, *value2; guint n; n = a->attributes ? g_hash_table_size(a->attributes) : 0u; @@ -382,8 +353,8 @@ nm_ip_address_dup(NMIPAddress *address) copy = nm_ip_address_new(address->family, address->address, address->prefix, NULL); if (address->attributes) { GHashTableIter iter; - const char * key; - GVariant * value; + const char *key; + GVariant *value; g_hash_table_iter_init(&iter, address->attributes); while (g_hash_table_iter_next(&iter, (gpointer *) &key, (gpointer *) &value)) @@ -441,12 +412,18 @@ nm_ip_address_get_address(NMIPAddress *address) void nm_ip_address_set_address(NMIPAddress *address, const char *addr) { + NMIPAddr addr_bin; + g_return_if_fail(address != NULL); - g_return_if_fail(addr != NULL); - g_return_if_fail(nm_utils_ipaddr_is_valid(address->family, addr)); + + if (!valid_ip(address->family, addr, &addr_bin, NULL)) { + g_return_if_fail(addr != NULL); + g_return_if_fail(nm_utils_ipaddr_is_valid(address->family, addr)); + nm_assert_not_reached(); + } g_free(address->address); - address->address = canonicalize_ip(address->family, addr, FALSE); + address->address = canonicalize_ip_binary(address->family, &addr_bin, FALSE); } /** @@ -479,13 +456,11 @@ nm_ip_address_get_address_binary(NMIPAddress *address, gpointer addr) void nm_ip_address_set_address_binary(NMIPAddress *address, gconstpointer addr) { - char string[NM_UTILS_INET_ADDRSTRLEN]; - g_return_if_fail(address != NULL); g_return_if_fail(addr != NULL); g_free(address->address); - address->address = g_strdup(inet_ntop(address->family, addr, string, sizeof(string))); + address->address = nm_utils_inet_ntop_dup(address->family, addr); } /** @@ -608,13 +583,14 @@ G_DEFINE_BOXED_TYPE(NMIPRoute, nm_ip_route, nm_ip_route_dup, nm_ip_route_unref) struct NMIPRoute { guint refcount; - int family; - char * dest; - guint prefix; - char * next_hop; - gint64 metric; + gint8 family; + guint8 prefix; + char *dest; + char *next_hop; GHashTable *attributes; + + gint64 metric; }; /** @@ -637,30 +613,33 @@ nm_ip_route_new(int family, guint prefix, const char *next_hop, gint64 metric, - GError ** error) + GError **error) { NMIPRoute *route; + NMIPAddr dest_bin; + NMIPAddr next_hop_bin; g_return_val_if_fail(family == AF_INET || family == AF_INET6, NULL); g_return_val_if_fail(dest, NULL); - if (!valid_ip(family, dest, error)) + if (!valid_ip(family, dest, &dest_bin, error)) return NULL; if (!valid_prefix(family, prefix, error)) return NULL; - if (next_hop && !valid_ip(family, next_hop, error)) + if (next_hop && !valid_ip(family, next_hop, &next_hop_bin, error)) return NULL; if (!valid_metric(metric, error)) return NULL; - route = g_slice_new0(NMIPRoute); - route->refcount = 1; - - route->family = family; - route->dest = canonicalize_ip(family, dest, FALSE); - route->prefix = prefix; - route->next_hop = canonicalize_ip(family, next_hop, TRUE); - route->metric = metric; + route = g_slice_new(NMIPRoute); + *route = (NMIPRoute){ + .refcount = 1, + .family = family, + .dest = canonicalize_ip_binary(family, &dest_bin, FALSE), + .prefix = prefix, + .next_hop = canonicalize_ip_binary(family, next_hop ? &next_hop_bin : NULL, TRUE), + .metric = metric, + }; return route; } @@ -686,7 +665,7 @@ nm_ip_route_new_binary(int family, guint prefix, gconstpointer next_hop, gint64 metric, - GError ** error) + GError **error) { NMIPRoute *route; @@ -698,14 +677,15 @@ nm_ip_route_new_binary(int family, if (!valid_metric(metric, error)) return NULL; - route = g_slice_new0(NMIPRoute); - route->refcount = 1; - - route->family = family; - route->dest = canonicalize_ip_binary(family, dest, FALSE); - route->prefix = prefix; - route->next_hop = canonicalize_ip_binary(family, next_hop, TRUE); - route->metric = metric; + route = g_slice_new0(NMIPRoute); + *route = (NMIPRoute){ + .refcount = 1, + .family = family, + .dest = canonicalize_ip_binary(family, dest, FALSE), + .prefix = prefix, + .next_hop = canonicalize_ip_binary(family, next_hop, TRUE), + .metric = metric, + }; return route; } @@ -742,9 +722,8 @@ nm_ip_route_unref(NMIPRoute *route) if (route->refcount == 0) { g_free(route->dest); g_free(route->next_hop); - if (route->attributes) - g_hash_table_unref(route->attributes); - g_slice_free(NMIPRoute, route); + nm_g_hash_table_unref(route->attributes); + nm_g_slice_free(route); } } @@ -783,8 +762,8 @@ nm_ip_route_equal_full(NMIPRoute *route, NMIPRoute *other, guint cmp_flags) return FALSE; if (cmp_flags == NM_IP_ROUTE_EQUAL_CMP_FLAGS_WITH_ATTRS) { GHashTableIter iter; - const char * key; - GVariant * value, *value2; + const char *key; + GVariant *value, *value2; guint n; n = route->attributes ? g_hash_table_size(route->attributes) : 0u; @@ -850,8 +829,8 @@ nm_ip_route_dup(NMIPRoute *route) NULL); if (route->attributes) { GHashTableIter iter; - const char * key; - GVariant * value; + const char *key; + GVariant *value; g_hash_table_iter_init(&iter, route->attributes); while (g_hash_table_iter_next(&iter, (gpointer *) &key, (gpointer *) &value)) @@ -909,11 +888,17 @@ nm_ip_route_get_dest(NMIPRoute *route) void nm_ip_route_set_dest(NMIPRoute *route, const char *dest) { + NMIPAddr dest_bin; + g_return_if_fail(route != NULL); - g_return_if_fail(nm_utils_ipaddr_is_valid(route->family, dest)); + + if (!valid_ip(route->family, dest, &dest_bin, NULL)) { + g_return_if_fail(nm_utils_ipaddr_is_valid(route->family, dest)); + nm_assert_not_reached(); + } g_free(route->dest); - route->dest = canonicalize_ip(route->family, dest, FALSE); + route->dest = canonicalize_ip_binary(route->family, &dest_bin, FALSE); } /** @@ -946,13 +931,11 @@ nm_ip_route_get_dest_binary(NMIPRoute *route, gpointer dest) void nm_ip_route_set_dest_binary(NMIPRoute *route, gconstpointer dest) { - char string[NM_UTILS_INET_ADDRSTRLEN]; - g_return_if_fail(route != NULL); g_return_if_fail(dest != NULL); g_free(route->dest); - route->dest = g_strdup(inet_ntop(route->family, dest, string, sizeof(string))); + route->dest = nm_utils_inet_ntop_dup(route->family, dest); } /** @@ -1020,11 +1003,17 @@ nm_ip_route_get_next_hop(NMIPRoute *route) void nm_ip_route_set_next_hop(NMIPRoute *route, const char *next_hop) { + NMIPAddr next_hop_bin; + g_return_if_fail(route != NULL); - g_return_if_fail(!next_hop || nm_utils_ipaddr_is_valid(route->family, next_hop)); + + if (next_hop && !valid_ip(route->family, next_hop, &next_hop_bin, NULL)) { + g_return_if_fail(!next_hop || nm_utils_ipaddr_is_valid(route->family, next_hop)); + nm_assert_not_reached(); + } g_free(route->next_hop); - route->next_hop = canonicalize_ip(route->family, next_hop, TRUE); + route->next_hop = canonicalize_ip_binary(route->family, next_hop ? &next_hop_bin : NULL, TRUE); } /** @@ -1214,8 +1203,8 @@ static const NMVariantAttributeSpec *const ip_route_attribute_spec[] = { .v6 = TRUE, ), NM_VARIANT_ATTRIBUTE_SPEC_DEFINE(NM_IP_ROUTE_ATTRIBUTE_FROM, G_VARIANT_TYPE_STRING, - .v6 = TRUE, - .str_type = 'p', ), + .v6 = TRUE, + .type_detail = 'p', ), NM_VARIANT_ATTRIBUTE_SPEC_DEFINE(NM_IP_ROUTE_ATTRIBUTE_INITCWND, G_VARIANT_TYPE_UINT32, .v4 = TRUE, @@ -1254,12 +1243,13 @@ static const NMVariantAttributeSpec *const ip_route_attribute_spec[] = { .v6 = TRUE, ), NM_VARIANT_ATTRIBUTE_SPEC_DEFINE(NM_IP_ROUTE_ATTRIBUTE_SCOPE, G_VARIANT_TYPE_BYTE, - .v4 = TRUE, ), + .v4 = TRUE, + .type_detail = 's'), NM_VARIANT_ATTRIBUTE_SPEC_DEFINE(NM_IP_ROUTE_ATTRIBUTE_SRC, G_VARIANT_TYPE_STRING, - .v4 = TRUE, - .v6 = TRUE, - .str_type = 'a', ), + .v4 = TRUE, + .v6 = TRUE, + .type_detail = 'a', ), NM_VARIANT_ATTRIBUTE_SPEC_DEFINE(NM_IP_ROUTE_ATTRIBUTE_TABLE, G_VARIANT_TYPE_UINT32, .v4 = TRUE, @@ -1267,9 +1257,9 @@ static const NMVariantAttributeSpec *const ip_route_attribute_spec[] = { NM_VARIANT_ATTRIBUTE_SPEC_DEFINE(NM_IP_ROUTE_ATTRIBUTE_TOS, G_VARIANT_TYPE_BYTE, .v4 = TRUE, ), NM_VARIANT_ATTRIBUTE_SPEC_DEFINE(NM_IP_ROUTE_ATTRIBUTE_TYPE, G_VARIANT_TYPE_STRING, - .v4 = TRUE, - .v6 = TRUE, - .str_type = 'T', ), + .v4 = TRUE, + .v6 = TRUE, + .type_detail = 'T', ), NM_VARIANT_ATTRIBUTE_SPEC_DEFINE(NM_IP_ROUTE_ATTRIBUTE_WINDOW, G_VARIANT_TYPE_UINT32, .v4 = TRUE, @@ -1290,34 +1280,26 @@ nm_ip_route_get_variant_attribute_spec(void) return ip_route_attribute_spec; } -/** - * nm_ip_route_attribute_validate: - * @name: the attribute name - * @value: the attribute value - * @family: IP address family of the route - * @known: (out): on return, whether the attribute name is a known one - * @error: (allow-none): return location for a #GError, or %NULL - * - * Validates a route attribute, i.e. checks that the attribute is a known one - * and the value is of the correct type and well-formed. - * - * Returns: %TRUE if the attribute is valid, %FALSE otherwise - * - * Since: 1.8 - */ -gboolean -nm_ip_route_attribute_validate(const char *name, - GVariant * value, - int family, - gboolean * known, - GError ** error) +typedef struct { + int type; + int scope; +} IPRouteAttrParseData; + +static gboolean +_ip_route_attribute_validate(const char *name, + GVariant *value, + int family, + IPRouteAttrParseData *parse_data, + gboolean *known, + GError **error) { const NMVariantAttributeSpec *spec; + const char *string; - g_return_val_if_fail(name, FALSE); - g_return_val_if_fail(value, FALSE); - g_return_val_if_fail(family == AF_INET || family == AF_INET6, FALSE); - g_return_val_if_fail(!error || !*error, FALSE); + nm_assert(name); + nm_assert(value); + nm_assert(family == AF_INET || family == AF_INET6); + nm_assert(!error || !*error); spec = _nm_variant_attribute_spec_find_binary_search(ip_route_attribute_spec, G_N_ELEMENTS(ip_route_attribute_spec) - 1, @@ -1351,80 +1333,132 @@ nm_ip_route_attribute_validate(const char *name, return FALSE; } - if (g_variant_type_equal(spec->type, G_VARIANT_TYPE_STRING)) { - const char *string = g_variant_get_string(value, NULL); - - switch (spec->str_type) { - case 'a': /* IP address */ - if (!nm_utils_ipaddr_is_valid(family, string)) { - g_set_error(error, - NM_CONNECTION_ERROR, - NM_CONNECTION_ERROR_FAILED, - family == AF_INET ? _("'%s' is not a valid IPv4 address") - : _("'%s' is not a valid IPv6 address"), - string); - return FALSE; - } - break; - case 'p': /* IP address + optional prefix */ - { - gs_free char *addr_free = NULL; - const char * addr = string; - const char * str; - - str = strchr(addr, '/'); - if (str) { - addr = nm_strndup_a(200, addr, str - addr, &addr_free); - str++; - if (_nm_utils_ascii_str_to_int64(str, 10, 0, family == AF_INET ? 32 : 128, -1) - < 0) { - g_set_error(error, - NM_CONNECTION_ERROR, - NM_CONNECTION_ERROR_FAILED, - _("invalid prefix %s"), - str); - return FALSE; - } - } - if (!nm_utils_ipaddr_is_valid(family, addr)) { + switch (spec->type_detail) { + case 'a': /* IP address */ + string = g_variant_get_string(value, NULL); + if (!nm_utils_ipaddr_is_valid(family, string)) { + g_set_error(error, + NM_CONNECTION_ERROR, + NM_CONNECTION_ERROR_FAILED, + family == AF_INET ? _("'%s' is not a valid IPv4 address") + : _("'%s' is not a valid IPv6 address"), + string); + return FALSE; + } + break; + case 'p': /* IP address + optional prefix */ + { + gs_free char *addr_free = NULL; + const char *addr; + const char *str; + + string = g_variant_get_string(value, NULL); + addr = string; + + str = strchr(addr, '/'); + if (str) { + addr = nm_strndup_a(200, addr, str - addr, &addr_free); + str++; + if (_nm_utils_ascii_str_to_int64(str, 10, 0, family == AF_INET ? 32 : 128, -1) < 0) { g_set_error(error, NM_CONNECTION_ERROR, NM_CONNECTION_ERROR_FAILED, - family == AF_INET ? _("'%s' is not a valid IPv4 address") - : _("'%s' is not a valid IPv6 address"), - string); + _("invalid prefix %s"), + str); return FALSE; } - break; } - case 'T': /* route type. */ - if (!NM_IN_SET(nm_net_aux_rtnl_rtntype_a2n(string), RTN_UNICAST, RTN_LOCAL)) { - g_set_error(error, - NM_CONNECTION_ERROR, - NM_CONNECTION_ERROR_INVALID_PROPERTY, - _("%s is not a valid route type"), - string); - return FALSE; - } - break; - default: - break; + if (!nm_utils_ipaddr_is_valid(family, addr)) { + g_set_error(error, + NM_CONNECTION_ERROR, + NM_CONNECTION_ERROR_FAILED, + family == AF_INET ? _("'%s' is not a valid IPv4 address") + : _("'%s' is not a valid IPv6 address"), + string); + return FALSE; } + break; + } + case 'T': /* route type. */ + { + int type; + + string = g_variant_get_string(value, NULL); + type = nm_net_aux_rtnl_rtntype_a2n(string); + if (!NM_IN_SET(type, + RTN_UNICAST, + RTN_LOCAL, + RTN_BLACKHOLE, + RTN_UNREACHABLE, + RTN_PROHIBIT)) { + g_set_error(error, + NM_CONNECTION_ERROR, + NM_CONNECTION_ERROR_INVALID_PROPERTY, + _("%s is not a valid route type"), + string); + return FALSE; + } + + if (parse_data) + parse_data->type = type; + break; + } + case 's': /* scope */ + if (parse_data) + parse_data->scope = g_variant_get_byte(value); + break; + case '\0': + break; + default: + nm_assert_not_reached(); + break; } return TRUE; } +/** + * nm_ip_route_attribute_validate: + * @name: the attribute name + * @value: the attribute value + * @family: IP address family of the route + * @known: (out): on return, whether the attribute name is a known one + * @error: (allow-none): return location for a #GError, or %NULL + * + * Validates a route attribute, i.e. checks that the attribute is a known one + * and the value is of the correct type and well-formed. + * + * Returns: %TRUE if the attribute is valid, %FALSE otherwise + * + * Since: 1.8 + */ +gboolean +nm_ip_route_attribute_validate(const char *name, + GVariant *value, + int family, + gboolean *known, + GError **error) +{ + g_return_val_if_fail(name, FALSE); + g_return_val_if_fail(value, FALSE); + g_return_val_if_fail(family == AF_INET || family == AF_INET6, FALSE); + g_return_val_if_fail(!error || !*error, FALSE); + + return _ip_route_attribute_validate(name, value, family, NULL, known, error); +} + gboolean _nm_ip_route_attribute_validate_all(const NMIPRoute *route, GError **error) { - NMUtilsNamedValue attrs_static[G_N_ELEMENTS(ip_route_attribute_spec)]; + NMUtilsNamedValue attrs_static[G_N_ELEMENTS(ip_route_attribute_spec)]; gs_free NMUtilsNamedValue *attrs_free = NULL; - const NMUtilsNamedValue * attrs; + const NMUtilsNamedValue *attrs; guint attrs_len; - GVariant * val; guint i; - guint8 u8; + IPRouteAttrParseData parse_data = { + .type = RTN_UNICAST, + .scope = -1, + }; g_return_val_if_fail(route, FALSE); g_return_val_if_fail(!error || !*error, FALSE); @@ -1437,34 +1471,38 @@ _nm_ip_route_attribute_validate_all(const NMIPRoute *route, GError **error) attrs_static, &attrs_free); for (i = 0; i < attrs_len; i++) { - const char *key = attrs[i].name; - GVariant * val2 = attrs[i].value_ptr; - - if (!nm_ip_route_attribute_validate(key, val2, route->family, NULL, error)) + if (!_ip_route_attribute_validate(attrs[i].name, + attrs[i].value_ptr, + route->family, + &parse_data, + NULL, + error)) return FALSE; } - if ((val = g_hash_table_lookup(route->attributes, NM_IP_ROUTE_ATTRIBUTE_TYPE))) { - int v_i; - - nm_assert(g_variant_is_of_type(val, G_VARIANT_TYPE_STRING)); - - v_i = nm_net_aux_rtnl_rtntype_a2n(g_variant_get_string(val, NULL)); - nm_assert(v_i >= 0); - - if (v_i == RTN_LOCAL && route->family == AF_INET - && (val = g_hash_table_lookup(route->attributes, NM_IP_ROUTE_ATTRIBUTE_SCOPE))) { - nm_assert(g_variant_is_of_type(val, G_VARIANT_TYPE_BYTE)); - u8 = g_variant_get_byte(val); - - if (!NM_IN_SET(u8, RT_SCOPE_HOST, RT_SCOPE_NOWHERE)) { - g_set_error(error, - NM_CONNECTION_ERROR, - NM_CONNECTION_ERROR_INVALID_PROPERTY, - _("route scope is invalid")); - return FALSE; - } + switch (parse_data.type) { + case RTN_LOCAL: + if (route->family == AF_INET && parse_data.scope >= 0 + && !NM_IN_SET(parse_data.scope, RT_SCOPE_HOST, RT_SCOPE_NOWHERE)) { + g_set_error(error, + NM_CONNECTION_ERROR, + NM_CONNECTION_ERROR_INVALID_PROPERTY, + _("route scope is invalid for local route")); + return FALSE; } + break; + case RTN_BLACKHOLE: + case RTN_UNREACHABLE: + case RTN_PROHIBIT: + if (route->next_hop) { + g_set_error(error, + NM_CONNECTION_ERROR, + NM_CONNECTION_ERROR_INVALID_PROPERTY, + _("a %s route cannot have a next-hop"), + nm_net_aux_rtnl_rtntype_n2a(parse_data.type)); + return FALSE; + } + break; } return TRUE; @@ -1475,10 +1513,10 @@ _nm_ip_route_attribute_validate_all(const NMIPRoute *route, GError **error) struct NMIPRoutingRule { NMIPAddr from_bin; NMIPAddr to_bin; - char * from_str; - char * to_str; - char * iifname; - char * oifname; + char *from_str; + char *to_str; + char *iifname; + char *oifname; guint ref_count; guint32 priority; guint32 table; @@ -1692,7 +1730,7 @@ nm_ip_routing_rule_unref(NMIPRoutingRule *self) g_free(self->iifname); g_free(self->oifname); - g_slice_free(NMIPRoutingRule, self); + nm_g_slice_free(self); } /** @@ -2254,7 +2292,7 @@ nm_ip_routing_rule_get_xifname_bin(const NMIPRoutingRule *self, char out_xifname[static 16 /* IFNAMSIZ */]) { gs_free gpointer bin_to_free = NULL; - const char * xifname; + const char *xifname; gconstpointer bin; gsize len; @@ -2448,8 +2486,8 @@ nm_ip_routing_rule_set_suppress_prefixlength(NMIPRoutingRule *self, gint32 suppr */ gboolean nm_ip_routing_rule_get_uid_range(const NMIPRoutingRule *self, - guint32 * out_range_start, - guint32 * out_range_end) + guint32 *out_range_start, + guint32 *out_range_end) { g_return_val_if_fail(NM_IS_IP_ROUTING_RULE(self, TRUE), -1); @@ -2590,7 +2628,7 @@ _rr_xport_range_parse(char *str, gint64 *out_start, guint16 *out_end) { guint16 start, end; gint64 i64; - char * s; + char *s; s = strchr(str, '-'); if (s) @@ -2823,7 +2861,7 @@ typedef enum { } RRDbusAttr; typedef struct { - const char * name; + const char *name; const GVariantType *dbus_type; } RRDbusData; @@ -2905,16 +2943,16 @@ _rr_variants_free(GVariant *(*p_variants)[]) NMIPRoutingRule * nm_ip_routing_rule_from_dbus(GVariant *variant, gboolean strict, GError **error) { - nm_auto(_rr_variants_free) GVariant *variants[_RR_DBUS_ATTR_NUM] = {}; - nm_auto_unref_ip_routing_rule NMIPRoutingRule *self = NULL; + nm_auto(_rr_variants_free) GVariant *variants[_RR_DBUS_ATTR_NUM] = {}; + nm_auto_unref_ip_routing_rule NMIPRoutingRule *self = NULL; RRDbusAttr attr; GVariantIter iter; - const char * iter_key; - GVariant * iter_val; + const char *iter_key; + GVariant *iter_val; int addr_family; int i; - GVariant * v_start; - GVariant * v_end; + GVariant *v_start; + GVariant *v_end; g_variant_iter_init(&iter, variant); @@ -3216,8 +3254,8 @@ nm_ip_routing_rule_to_dbus(const NMIPRoutingRule *self) static gboolean _rr_string_validate(gboolean for_from /* or else to-string */, NMIPRoutingRuleAsStringFlags to_string_flags, - GHashTable * extra_args, - GError ** error) + GHashTable *extra_args, + GError **error) { if (NM_FLAGS_ANY(to_string_flags, ~(NM_IP_ROUTING_RULE_AS_STRING_FLAGS_AF_INET @@ -3266,21 +3304,21 @@ _rr_string_addr_family_from_flags(NMIPRoutingRuleAsStringFlags to_string_flags) * Since: 1.18 */ NMIPRoutingRule * -nm_ip_routing_rule_from_string(const char * str, +nm_ip_routing_rule_from_string(const char *str, NMIPRoutingRuleAsStringFlags to_string_flags, - GHashTable * extra_args, - GError ** error) + GHashTable *extra_args, + GError **error) { nm_auto_unref_ip_routing_rule NMIPRoutingRule *self = NULL; - gs_free const char ** tokens = NULL; + gs_free const char **tokens = NULL; gsize i_token; gboolean any_words = FALSE; - char * word0 = NULL; - char * word1 = NULL; - char * word_from = NULL; - char * word_to = NULL; - char * word_iifname = NULL; - char * word_oifname = NULL; + char *word0 = NULL; + char *word1 = NULL; + char *word_from = NULL; + char *word_to = NULL; + char *word_iifname = NULL; + char *word_oifname = NULL; gint64 i64_priority = -1; gint64 i64_table = -1; gint64 i64_tos = -1; @@ -3302,7 +3340,7 @@ nm_ip_routing_rule_from_string(const char * str, NMIPAddr val_to = {}; int val_from_len = -1; int val_to_len = -1; - char * s; + char *s; g_return_val_if_fail(str, NULL); @@ -3688,7 +3726,7 @@ next_words_consumed: } static void -_rr_string_append_inet_addr(NMStrBuf * str, +_rr_string_append_inet_addr(NMStrBuf *str, gboolean is_from /* or else is-to */, gboolean required, int addr_family, @@ -3730,10 +3768,10 @@ _rr_string_append_inet_addr(NMStrBuf * str, * Since: 1.18 */ char * -nm_ip_routing_rule_to_string(const NMIPRoutingRule * self, +nm_ip_routing_rule_to_string(const NMIPRoutingRule *self, NMIPRoutingRuleAsStringFlags to_string_flags, - GHashTable * extra_args, - GError ** error) + GHashTable *extra_args, + GError **error) { int addr_family; NMStrBuf str; @@ -4000,25 +4038,31 @@ gboolean nm_setting_ip_config_add_dns(NMSettingIPConfig *setting, const char *dns) { NMSettingIPConfigPrivate *priv; - char * dns_canonical; + int addr_family; + NMIPAddr dns_bin; + char dns_canonical[NM_UTILS_INET_ADDRSTRLEN]; guint i; g_return_val_if_fail(NM_IS_SETTING_IP_CONFIG(setting), FALSE); - g_return_val_if_fail(dns != NULL, FALSE); - g_return_val_if_fail(nm_utils_ipaddr_is_valid(NM_SETTING_IP_CONFIG_GET_FAMILY(setting), dns), - FALSE); + + addr_family = NM_SETTING_IP_CONFIG_GET_FAMILY(setting); + + if (!valid_ip(addr_family, dns, &dns_bin, NULL)) { + g_return_val_if_fail(dns != NULL, FALSE); + g_return_val_if_fail(nm_utils_ipaddr_is_valid(addr_family, dns), FALSE); + nm_assert_not_reached(); + } priv = NM_SETTING_IP_CONFIG_GET_PRIVATE(setting); - dns_canonical = canonicalize_ip(NM_SETTING_IP_CONFIG_GET_FAMILY(setting), dns, FALSE); + nm_utils_inet_ntop(addr_family, &dns_bin, dns_canonical); + for (i = 0; i < priv->dns->len; i++) { - if (!strcmp(dns_canonical, priv->dns->pdata[i])) { - g_free(dns_canonical); + if (nm_streq(dns_canonical, priv->dns->pdata[i])) return FALSE; - } } - g_ptr_array_add(priv->dns, dns_canonical); + g_ptr_array_add(priv->dns, g_strdup(dns_canonical)); _notify(setting, PROP_DNS); return TRUE; } @@ -4057,26 +4101,32 @@ gboolean nm_setting_ip_config_remove_dns_by_value(NMSettingIPConfig *setting, const char *dns) { NMSettingIPConfigPrivate *priv; - char * dns_canonical; + int addr_family; + NMIPAddr dns_bin; + char dns_canonical[NM_UTILS_INET_ADDRSTRLEN]; guint i; g_return_val_if_fail(NM_IS_SETTING_IP_CONFIG(setting), FALSE); - g_return_val_if_fail(dns != NULL, FALSE); - g_return_val_if_fail(nm_utils_ipaddr_is_valid(NM_SETTING_IP_CONFIG_GET_FAMILY(setting), dns), - FALSE); + + addr_family = NM_SETTING_IP_CONFIG_GET_FAMILY(setting); + + if (!valid_ip(addr_family, dns, &dns_bin, NULL)) { + g_return_val_if_fail(dns != NULL, FALSE); + g_return_val_if_fail(nm_utils_ipaddr_is_valid(addr_family, dns), FALSE); + nm_assert_not_reached(); + } priv = NM_SETTING_IP_CONFIG_GET_PRIVATE(setting); - dns_canonical = canonicalize_ip(NM_SETTING_IP_CONFIG_GET_FAMILY(setting), dns, FALSE); + nm_utils_inet_ntop(addr_family, &dns_bin, dns_canonical); + for (i = 0; i < priv->dns->len; i++) { - if (!strcmp(dns_canonical, priv->dns->pdata[i])) { + if (nm_streq(dns_canonical, priv->dns->pdata[i])) { g_ptr_array_remove_index(priv->dns, i); _notify(setting, PROP_DNS); - g_free(dns_canonical); return TRUE; } } - g_free(dns_canonical); return FALSE; } @@ -4951,7 +5001,7 @@ nm_setting_ip_config_clear_routing_rules(NMSettingIPConfig *setting) static GVariant * _routing_rules_dbus_only_synth(_NM_SETT_INFO_PROP_TO_DBUS_FCN_ARGS _nm_nil) { - NMSettingIPConfig * self = NM_SETTING_IP_CONFIG(setting); + NMSettingIPConfig *self = NM_SETTING_IP_CONFIG(setting); NMSettingIPConfigPrivate *priv; GVariantBuilder builder; gboolean any = FALSE; @@ -4983,7 +5033,7 @@ static gboolean _routing_rules_dbus_only_set(_NM_SETT_INFO_PROP_FROM_DBUS_FCN_ARGS _nm_nil) { GVariantIter iter_rules; - GVariant * rule_var; + GVariant *rule_var; guint i_rule; gboolean success = FALSE; gboolean rules_changed = FALSE; @@ -4994,9 +5044,9 @@ _routing_rules_dbus_only_set(_NM_SETT_INFO_PROP_FROM_DBUS_FCN_ARGS _nm_nil) i_rule = 0; while (g_variant_iter_next(&iter_rules, "@a{sv}", &rule_var)) { - _nm_unused gs_unref_variant GVariant *rule_var_unref = rule_var; - nm_auto_unref_ip_routing_rule NMIPRoutingRule *rule = NULL; - gs_free_error GError *local = NULL; + _nm_unused gs_unref_variant GVariant *rule_var_unref = rule_var; + nm_auto_unref_ip_routing_rule NMIPRoutingRule *rule = NULL; + gs_free_error GError *local = NULL; i_rule++; @@ -5322,7 +5372,7 @@ static gboolean verify_label(const char *label) { const char *p; - char * iface; + char *iface; p = strchr(label, ':'); if (!p) @@ -5390,7 +5440,7 @@ verify(NMSetting *setting, NMConnection *connection, GError **error) /* Validate addresses */ for (i = 0; i < priv->addresses->len; i++) { NMIPAddress *addr = (NMIPAddress *) priv->addresses->pdata[i]; - GVariant * label; + GVariant *label; if (nm_ip_address_get_family(addr) != NM_SETTING_IP_CONFIG_GET_FAMILY(setting)) { g_set_error(error, @@ -5465,7 +5515,7 @@ verify(NMSetting *setting, NMConnection *connection, GError **error) /* Validate routes */ for (i = 0; i < priv->routes->len; i++) { gs_free_error GError *local = NULL; - NMIPRoute * route = (NMIPRoute *) priv->routes->pdata[i]; + NMIPRoute *route = (NMIPRoute *) priv->routes->pdata[i]; if (nm_ip_route_get_family(route) != NM_SETTING_IP_CONFIG_GET_FAMILY(setting)) { g_set_error(error, @@ -5496,7 +5546,7 @@ verify(NMSetting *setting, NMConnection *connection, GError **error) if (priv->routing_rules) { for (i = 0; i < priv->routing_rules->len; i++) { - NMIPRoutingRule *rule = priv->routing_rules->pdata[i]; + NMIPRoutingRule *rule = priv->routing_rules->pdata[i]; gs_free_error GError *local = NULL; if (_ip_routing_rule_get_addr_family(rule) @@ -5555,9 +5605,10 @@ verify(NMSetting *setting, NMConnection *connection, GError **error) return FALSE; } - if (!_nm_utils_validate_dhcp_hostname_flags(priv->dhcp_hostname_flags, - NM_SETTING_IP_CONFIG_GET_FAMILY(setting), - error)) { + if (priv->dhcp_hostname_flags != (NMDhcpHostnameFlags) priv->dhcp_hostname_flags + || !_nm_utils_validate_dhcp_hostname_flags(priv->dhcp_hostname_flags, + NM_SETTING_IP_CONFIG_GET_FAMILY(setting), + error)) { g_prefix_error(error, "%s.%s: ", nm_setting_get_name(setting), @@ -5720,14 +5771,14 @@ duplicate_copy_properties(const NMSettInfoSetting *sett_info, NMSetting *src, NM static void enumerate_values(const NMSettInfoProperty *property_info, - NMSetting * setting, + NMSetting *setting, NMSettingValueIterFn func, gpointer user_data) { if (nm_streq(property_info->name, NM_SETTING_IP_CONFIG_ROUTING_RULES)) { - NMSettingIPConfigPrivate * priv = NM_SETTING_IP_CONFIG_GET_PRIVATE(setting); + NMSettingIPConfigPrivate *priv = NM_SETTING_IP_CONFIG_GET_PRIVATE(setting); nm_auto_unset_gvalue GValue value = G_VALUE_INIT; - GPtrArray * ptr = NULL; + GPtrArray *ptr = NULL; guint i; if (priv->routing_rules && priv->routing_rules->len > 0) { @@ -5788,7 +5839,8 @@ _nm_sett_info_property_override_create_array_ip_config(int addr_family) .to_dbus_fcn = _nm_setting_property_to_dbus_fcn_direct, .from_dbus_fcn = _nm_setting_property_from_dbus_fcn_direct_ip_config_gateway), .direct_offset = NM_STRUCT_OFFSET_ENSURE_TYPE(char *, NMSettingIPConfigPrivate, gateway), - .direct_set_string_ip_address_addr_family = addr_family); + .direct_set_string_ip_address_addr_family = addr_family + 1, + .direct_set_string_ip_address_addr_family_map_zero_to_null = TRUE); _nm_properties_override_gobj( properties_override, @@ -5826,6 +5878,20 @@ _nm_sett_info_property_override_create_array_ip_config(int addr_family) _nm_properties_override_gobj( properties_override, + obj_properties[PROP_ROUTE_TABLE], + &nm_sett_info_propert_type_direct_uint32, + .direct_offset = + NM_STRUCT_OFFSET_ENSURE_TYPE(guint32, NMSettingIPConfigPrivate, route_table)); + + _nm_properties_override_gobj( + properties_override, + obj_properties[PROP_ROUTE_METRIC], + &nm_sett_info_propert_type_direct_int64, + .direct_offset = + NM_STRUCT_OFFSET_ENSURE_TYPE(gint64, NMSettingIPConfigPrivate, route_metric)); + + _nm_properties_override_gobj( + properties_override, obj_properties[PROP_IGNORE_AUTO_DNS], &nm_sett_info_propert_type_direct_boolean, .direct_offset = @@ -5833,6 +5899,34 @@ _nm_sett_info_property_override_create_array_ip_config(int addr_family) _nm_properties_override_gobj( properties_override, + obj_properties[PROP_DNS_PRIORITY], + &nm_sett_info_propert_type_direct_int32, + .direct_offset = + NM_STRUCT_OFFSET_ENSURE_TYPE(gint32, NMSettingIPConfigPrivate, dns_priority)); + + _nm_properties_override_gobj( + properties_override, + obj_properties[PROP_DHCP_TIMEOUT], + &nm_sett_info_propert_type_direct_int32, + .direct_offset = + NM_STRUCT_OFFSET_ENSURE_TYPE(gint32, NMSettingIPConfigPrivate, dhcp_timeout)); + + _nm_properties_override_gobj( + properties_override, + obj_properties[PROP_REQUIRED_TIMEOUT], + &nm_sett_info_propert_type_direct_int32, + .direct_offset = + NM_STRUCT_OFFSET_ENSURE_TYPE(gint32, NMSettingIPConfigPrivate, required_timeout)); + + _nm_properties_override_gobj( + properties_override, + obj_properties[PROP_DAD_TIMEOUT], + &nm_sett_info_propert_type_direct_int32, + .direct_offset = + NM_STRUCT_OFFSET_ENSURE_TYPE(gint32, NMSettingIPConfigPrivate, dad_timeout)); + + _nm_properties_override_gobj( + properties_override, obj_properties[PROP_DHCP_SEND_HOSTNAME], &nm_sett_info_propert_type_direct_boolean, .direct_offset = @@ -5840,6 +5934,13 @@ _nm_sett_info_property_override_create_array_ip_config(int addr_family) _nm_properties_override_gobj( properties_override, + obj_properties[PROP_DHCP_HOSTNAME_FLAGS], + &nm_sett_info_propert_type_direct_uint32, + .direct_offset = + NM_STRUCT_OFFSET_ENSURE_TYPE(guint32, NMSettingIPConfigPrivate, dhcp_hostname_flags)); + + _nm_properties_override_gobj( + properties_override, obj_properties[PROP_NEVER_DEFAULT], &nm_sett_info_propert_type_direct_boolean, .direct_offset = @@ -5859,13 +5960,10 @@ _nm_sett_info_property_override_create_array_ip_config(int addr_family) static void get_property(GObject *object, guint prop_id, GValue *value, GParamSpec *pspec) { - NMSettingIPConfig * setting = NM_SETTING_IP_CONFIG(object); + NMSettingIPConfig *setting = NM_SETTING_IP_CONFIG(object); NMSettingIPConfigPrivate *priv = NM_SETTING_IP_CONFIG_GET_PRIVATE(setting); switch (prop_id) { - case PROP_METHOD: - g_value_set_string(value, nm_setting_ip_config_get_method(setting)); - break; case PROP_DNS: g_value_take_boxed(value, _nm_utils_ptrarray_to_strv(priv->dns)); break; @@ -5877,68 +5975,23 @@ get_property(GObject *object, guint prop_id, GValue *value, GParamSpec *pspec) priv->dns_options ? _nm_utils_ptrarray_to_strv(priv->dns_options) : NULL); break; - case PROP_DNS_PRIORITY: - g_value_set_int(value, priv->dns_priority); - break; case PROP_ADDRESSES: g_value_take_boxed(value, _nm_utils_copy_array(priv->addresses, (NMUtilsCopyFunc) nm_ip_address_dup, (GDestroyNotify) nm_ip_address_unref)); break; - case PROP_GATEWAY: - g_value_set_string(value, nm_setting_ip_config_get_gateway(setting)); - break; case PROP_ROUTES: g_value_take_boxed(value, _nm_utils_copy_array(priv->routes, (NMUtilsCopyFunc) nm_ip_route_dup, (GDestroyNotify) nm_ip_route_unref)); break; - case PROP_ROUTE_METRIC: - g_value_set_int64(value, priv->route_metric); - break; - case PROP_ROUTE_TABLE: - g_value_set_uint(value, priv->route_table); - break; - case PROP_IGNORE_AUTO_ROUTES: - g_value_set_boolean(value, nm_setting_ip_config_get_ignore_auto_routes(setting)); - break; - case PROP_IGNORE_AUTO_DNS: - g_value_set_boolean(value, nm_setting_ip_config_get_ignore_auto_dns(setting)); - break; - case PROP_DHCP_HOSTNAME: - g_value_set_string(value, nm_setting_ip_config_get_dhcp_hostname(setting)); - break; - case PROP_DHCP_SEND_HOSTNAME: - g_value_set_boolean(value, nm_setting_ip_config_get_dhcp_send_hostname(setting)); - break; - case PROP_NEVER_DEFAULT: - g_value_set_boolean(value, priv->never_default); - break; - case PROP_MAY_FAIL: - g_value_set_boolean(value, priv->may_fail); - break; - case PROP_DAD_TIMEOUT: - g_value_set_int(value, nm_setting_ip_config_get_dad_timeout(setting)); - break; - case PROP_DHCP_TIMEOUT: - g_value_set_int(value, nm_setting_ip_config_get_dhcp_timeout(setting)); - break; - case PROP_REQUIRED_TIMEOUT: - g_value_set_int(value, nm_setting_ip_config_get_required_timeout(setting)); - break; - case PROP_DHCP_IAID: - g_value_set_string(value, nm_setting_ip_config_get_dhcp_iaid(setting)); - break; - case PROP_DHCP_HOSTNAME_FLAGS: - g_value_set_uint(value, nm_setting_ip_config_get_dhcp_hostname_flags(setting)); - break; case PROP_DHCP_REJECT_SERVERS: g_value_set_boxed(value, nm_strvarray_get_strv_non_empty(priv->dhcp_reject_servers, NULL)); break; default: - G_OBJECT_WARN_INVALID_PROPERTY_ID(object, prop_id, pspec); + _nm_setting_property_get_property_direct(object, prop_id, value, pspec); break; } } @@ -5946,16 +5999,12 @@ 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) { - NMSettingIPConfig * setting = NM_SETTING_IP_CONFIG(object); + NMSettingIPConfig *setting = NM_SETTING_IP_CONFIG(object); NMSettingIPConfigPrivate *priv = NM_SETTING_IP_CONFIG_GET_PRIVATE(setting); - char ** strv; + char **strv; guint i; switch (prop_id) { - case PROP_METHOD: - g_free(priv->method); - priv->method = g_value_dup_string(value); - break; case PROP_DNS: g_ptr_array_unref(priv->dns); priv->dns = nm_strv_to_ptrarray(g_value_get_boxed(value)); @@ -5983,73 +6032,23 @@ set_property(GObject *object, guint prop_id, const GValue *value, GParamSpec *ps } } break; - case PROP_DNS_PRIORITY: - priv->dns_priority = g_value_get_int(value); - break; case PROP_ADDRESSES: g_ptr_array_unref(priv->addresses); priv->addresses = _nm_utils_copy_array(g_value_get_boxed(value), (NMUtilsCopyFunc) nm_ip_address_dup, (GDestroyNotify) nm_ip_address_unref); break; - case PROP_GATEWAY: - g_free(priv->gateway); - priv->gateway = - _nm_utils_ipaddr_canonical_or_invalid(NM_SETTING_IP_CONFIG_GET_FAMILY(setting), - g_value_get_string(value)); - break; case PROP_ROUTES: g_ptr_array_unref(priv->routes); priv->routes = _nm_utils_copy_array(g_value_get_boxed(value), (NMUtilsCopyFunc) nm_ip_route_dup, (GDestroyNotify) nm_ip_route_unref); break; - case PROP_ROUTE_METRIC: - priv->route_metric = g_value_get_int64(value); - break; - case PROP_ROUTE_TABLE: - priv->route_table = g_value_get_uint(value); - break; - case PROP_IGNORE_AUTO_ROUTES: - priv->ignore_auto_routes = g_value_get_boolean(value); - break; - case PROP_IGNORE_AUTO_DNS: - priv->ignore_auto_dns = g_value_get_boolean(value); - break; - case PROP_DHCP_HOSTNAME: - g_free(priv->dhcp_hostname); - priv->dhcp_hostname = g_value_dup_string(value); - break; - case PROP_DHCP_SEND_HOSTNAME: - priv->dhcp_send_hostname = g_value_get_boolean(value); - break; - case PROP_NEVER_DEFAULT: - priv->never_default = g_value_get_boolean(value); - break; - case PROP_MAY_FAIL: - priv->may_fail = g_value_get_boolean(value); - break; - case PROP_DAD_TIMEOUT: - priv->dad_timeout = g_value_get_int(value); - break; - case PROP_DHCP_TIMEOUT: - priv->dhcp_timeout = g_value_get_int(value); - break; - case PROP_REQUIRED_TIMEOUT: - priv->required_timeout = g_value_get_int(value); - break; - case PROP_DHCP_IAID: - g_free(priv->dhcp_iaid); - priv->dhcp_iaid = g_value_dup_string(value); - break; - case PROP_DHCP_HOSTNAME_FLAGS: - priv->dhcp_hostname_flags = g_value_get_uint(value); - break; case PROP_DHCP_REJECT_SERVERS: nm_strvarray_set_strv(&priv->dhcp_reject_servers, g_value_get_boxed(value)); break; default: - G_OBJECT_WARN_INVALID_PROPERTY_ID(object, prop_id, pspec); + _nm_setting_property_set_property_direct(object, prop_id, value, pspec); break; } } @@ -6061,13 +6060,10 @@ _nm_setting_ip_config_private_init(gpointer self, NMSettingIPConfigPrivate *priv { nm_assert(NM_IS_SETTING_IP_CONFIG(self)); - priv->dns = g_ptr_array_new_with_free_func(g_free); - priv->dns_search = g_ptr_array_new_with_free_func(g_free); - priv->addresses = g_ptr_array_new_with_free_func((GDestroyNotify) nm_ip_address_unref); - priv->routes = g_ptr_array_new_with_free_func((GDestroyNotify) nm_ip_route_unref); - priv->route_metric = -1; - priv->dad_timeout = -1; - priv->required_timeout = -1; + priv->dns = g_ptr_array_new_with_free_func(g_free); + priv->dns_search = g_ptr_array_new_with_free_func(g_free); + priv->addresses = g_ptr_array_new_with_free_func((GDestroyNotify) nm_ip_address_unref); + priv->routes = g_ptr_array_new_with_free_func((GDestroyNotify) nm_ip_route_unref); } static void @@ -6079,18 +6075,16 @@ nm_setting_ip_config_init(NMSettingIPConfig *setting) static void finalize(GObject *object) { - NMSettingIPConfig * self = NM_SETTING_IP_CONFIG(object); + NMSettingIPConfig *self = NM_SETTING_IP_CONFIG(object); NMSettingIPConfigPrivate *priv = NM_SETTING_IP_CONFIG_GET_PRIVATE(self); g_ptr_array_unref(priv->dns); g_ptr_array_unref(priv->dns_search); - if (priv->dns_options) - g_ptr_array_unref(priv->dns_options); + nm_g_ptr_array_unref(priv->dns_options); g_ptr_array_unref(priv->addresses); g_ptr_array_unref(priv->routes); - if (priv->routing_rules) - g_ptr_array_unref(priv->routing_rules); - nm_clear_pointer(&priv->dhcp_reject_servers, g_array_unref); + nm_g_ptr_array_unref(priv->routing_rules); + nm_g_array_unref(priv->dhcp_reject_servers); G_OBJECT_CLASS(nm_setting_ip_config_parent_class)->finalize(object); } @@ -6098,7 +6092,7 @@ finalize(GObject *object) static void nm_setting_ip_config_class_init(NMSettingIPConfigClass *klass) { - GObjectClass * object_class = G_OBJECT_CLASS(klass); + GObjectClass *object_class = G_OBJECT_CLASS(klass); NMSettingClass *setting_class = NM_SETTING_CLASS(klass); object_class->get_property = get_property; diff --git a/src/libnm-core-impl/nm-setting-ip-tunnel.c b/src/libnm-core-impl/nm-setting-ip-tunnel.c index 38f9047d..d42e97b9 100644 --- a/src/libnm-core-impl/nm-setting-ip-tunnel.c +++ b/src/libnm-core-impl/nm-setting-ip-tunnel.c @@ -32,19 +32,19 @@ NM_GOBJECT_PROPERTIES_DEFINE_BASE(PROP_PARENT, PROP_FLAGS, ); typedef struct { - char * parent; - char * local; - char * remote; - char * input_key; - char * output_key; - guint ttl; - guint tos; - guint encapsulation_limit; - guint flow_label; - NMIPTunnelMode mode; - guint32 mtu; - guint32 flags; - bool path_mtu_discovery; + char *parent; + char *local; + char *remote; + char *input_key; + char *output_key; + guint32 ttl; + guint32 tos; + guint32 encapsulation_limit; + guint32 flow_label; + guint32 mode; + guint32 mtu; + guint32 flags; + bool path_mtu_discovery; } NMSettingIPTunnelPrivate; /** @@ -503,117 +503,6 @@ verify(NMSetting *setting, NMConnection *connection, GError **error) /*****************************************************************************/ static void -get_property(GObject *object, guint prop_id, GValue *value, GParamSpec *pspec) -{ - NMSettingIPTunnel * setting = NM_SETTING_IP_TUNNEL(object); - NMSettingIPTunnelPrivate *priv = NM_SETTING_IP_TUNNEL_GET_PRIVATE(setting); - - switch (prop_id) { - case PROP_PARENT: - g_value_set_string(value, priv->parent); - break; - case PROP_MODE: - g_value_set_uint(value, priv->mode); - break; - case PROP_LOCAL: - g_value_set_string(value, priv->local); - break; - case PROP_REMOTE: - g_value_set_string(value, priv->remote); - break; - case PROP_TTL: - g_value_set_uint(value, priv->ttl); - break; - case PROP_TOS: - g_value_set_uint(value, priv->tos); - break; - case PROP_PATH_MTU_DISCOVERY: - g_value_set_boolean(value, priv->path_mtu_discovery); - break; - case PROP_INPUT_KEY: - g_value_set_string(value, priv->input_key); - break; - case PROP_OUTPUT_KEY: - g_value_set_string(value, priv->output_key); - break; - case PROP_ENCAPSULATION_LIMIT: - g_value_set_uint(value, priv->encapsulation_limit); - break; - case PROP_FLOW_LABEL: - g_value_set_uint(value, priv->flow_label); - break; - case PROP_MTU: - g_value_set_uint(value, priv->mtu); - break; - case PROP_FLAGS: - g_value_set_uint(value, priv->flags); - break; - default: - G_OBJECT_WARN_INVALID_PROPERTY_ID(object, prop_id, pspec); - break; - } -} - -static void -set_property(GObject *object, guint prop_id, const GValue *value, GParamSpec *pspec) -{ - NMSettingIPTunnel * setting = NM_SETTING_IP_TUNNEL(object); - NMSettingIPTunnelPrivate *priv = NM_SETTING_IP_TUNNEL_GET_PRIVATE(setting); - - switch (prop_id) { - case PROP_PARENT: - g_free(priv->parent); - priv->parent = g_value_dup_string(value); - break; - case PROP_MODE: - priv->mode = g_value_get_uint(value); - break; - case PROP_LOCAL: - g_free(priv->local); - priv->local = g_value_dup_string(value); - break; - case PROP_REMOTE: - g_free(priv->remote); - priv->remote = g_value_dup_string(value); - break; - case PROP_TTL: - priv->ttl = g_value_get_uint(value); - break; - case PROP_TOS: - priv->tos = g_value_get_uint(value); - break; - case PROP_PATH_MTU_DISCOVERY: - priv->path_mtu_discovery = g_value_get_boolean(value); - break; - case PROP_INPUT_KEY: - g_free(priv->input_key); - priv->input_key = g_value_dup_string(value); - break; - case PROP_OUTPUT_KEY: - g_free(priv->output_key); - priv->output_key = g_value_dup_string(value); - break; - case PROP_ENCAPSULATION_LIMIT: - priv->encapsulation_limit = g_value_get_uint(value); - break; - case PROP_FLOW_LABEL: - priv->flow_label = g_value_get_uint(value); - break; - case PROP_MTU: - priv->mtu = g_value_get_uint(value); - break; - case PROP_FLAGS: - priv->flags = g_value_get_uint(value); - break; - default: - G_OBJECT_WARN_INVALID_PROPERTY_ID(object, prop_id, pspec); - break; - } -} - -/*****************************************************************************/ - -static void nm_setting_ip_tunnel_init(NMSettingIPTunnel *self) {} @@ -635,14 +524,14 @@ nm_setting_ip_tunnel_new(void) static void nm_setting_ip_tunnel_class_init(NMSettingIPTunnelClass *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(NMSettingIPTunnelPrivate)); - object_class->get_property = get_property; - object_class->set_property = set_property; + object_class->get_property = _nm_setting_property_get_property_direct; + object_class->set_property = _nm_setting_property_set_property_direct; setting_class->verify = verify; @@ -671,14 +560,16 @@ nm_setting_ip_tunnel_class_init(NMSettingIPTunnelClass *klass) * * Since: 1.2 **/ - obj_properties[PROP_MODE] = - g_param_spec_uint(NM_SETTING_IP_TUNNEL_MODE, - "", - "", - 0, - G_MAXUINT, - 0, - G_PARAM_READWRITE | NM_SETTING_PARAM_INFERRABLE | G_PARAM_STATIC_STRINGS); + _nm_setting_property_define_direct_uint32(properties_override, + obj_properties, + NM_SETTING_IP_TUNNEL_MODE, + PROP_MODE, + 0, + G_MAXUINT32, + NM_IP_TUNNEL_MODE_UNKNOWN, + NM_SETTING_PARAM_INFERRABLE, + NMSettingIPTunnelPrivate, + mode); /** * NMSettingIPTunnel:local: @@ -720,14 +611,16 @@ nm_setting_ip_tunnel_class_init(NMSettingIPTunnelClass *klass) * * Since: 1.2 **/ - obj_properties[PROP_TTL] = - g_param_spec_uint(NM_SETTING_IP_TUNNEL_TTL, - "", - "", - 0, - 255, - 0, - G_PARAM_READWRITE | NM_SETTING_PARAM_INFERRABLE | G_PARAM_STATIC_STRINGS); + _nm_setting_property_define_direct_uint32(properties_override, + obj_properties, + NM_SETTING_IP_TUNNEL_TTL, + PROP_TTL, + 0, + 255, + 0, + NM_SETTING_PARAM_INFERRABLE, + NMSettingIPTunnelPrivate, + ttl); /** * NMSettingIPTunnel:tos @@ -737,14 +630,16 @@ nm_setting_ip_tunnel_class_init(NMSettingIPTunnelClass *klass) * * Since: 1.2 **/ - obj_properties[PROP_TOS] = - g_param_spec_uint(NM_SETTING_IP_TUNNEL_TOS, - "", - "", - 0, - 255, - 0, - G_PARAM_READWRITE | NM_SETTING_PARAM_INFERRABLE | G_PARAM_STATIC_STRINGS); + _nm_setting_property_define_direct_uint32(properties_override, + obj_properties, + NM_SETTING_IP_TUNNEL_TOS, + PROP_TOS, + 0, + 255, + 0, + NM_SETTING_PARAM_INFERRABLE, + NMSettingIPTunnelPrivate, + tos); /** * NMSettingIPTunnel:path-mtu-discovery @@ -802,14 +697,16 @@ nm_setting_ip_tunnel_class_init(NMSettingIPTunnelClass *klass) * * Since: 1.2 **/ - obj_properties[PROP_ENCAPSULATION_LIMIT] = - g_param_spec_uint(NM_SETTING_IP_TUNNEL_ENCAPSULATION_LIMIT, - "", - "", - 0, - 255, - 0, - G_PARAM_READWRITE | NM_SETTING_PARAM_INFERRABLE | G_PARAM_STATIC_STRINGS); + _nm_setting_property_define_direct_uint32(properties_override, + obj_properties, + NM_SETTING_IP_TUNNEL_ENCAPSULATION_LIMIT, + PROP_ENCAPSULATION_LIMIT, + 0, + 255, + 0, + NM_SETTING_PARAM_INFERRABLE, + NMSettingIPTunnelPrivate, + encapsulation_limit); /** * NMSettingIPTunnel:flow-label: @@ -819,14 +716,16 @@ nm_setting_ip_tunnel_class_init(NMSettingIPTunnelClass *klass) * * Since: 1.2 **/ - obj_properties[PROP_FLOW_LABEL] = - g_param_spec_uint(NM_SETTING_IP_TUNNEL_FLOW_LABEL, - "", - "", - 0, - (1 << 20) - 1, - 0, - G_PARAM_READWRITE | NM_SETTING_PARAM_INFERRABLE | G_PARAM_STATIC_STRINGS); + _nm_setting_property_define_direct_uint32(properties_override, + obj_properties, + NM_SETTING_IP_TUNNEL_FLOW_LABEL, + PROP_FLOW_LABEL, + 0, + (1 << 20) - 1, + 0, + NM_SETTING_PARAM_INFERRABLE, + NMSettingIPTunnelPrivate, + flow_label); /** * NMSettingIPTunnel:mtu: @@ -836,14 +735,16 @@ nm_setting_ip_tunnel_class_init(NMSettingIPTunnelClass *klass) * * Since: 1.2 **/ - obj_properties[PROP_MTU] = g_param_spec_uint(NM_SETTING_IP_TUNNEL_MTU, - "", - "", - 0, - G_MAXUINT32, - 0, - G_PARAM_READWRITE | NM_SETTING_PARAM_FUZZY_IGNORE - | G_PARAM_STATIC_STRINGS); + _nm_setting_property_define_direct_uint32(properties_override, + obj_properties, + NM_SETTING_IP_TUNNEL_MTU, + PROP_MTU, + 0, + G_MAXUINT32, + 0, + NM_SETTING_PARAM_FUZZY_IGNORE, + NMSettingIPTunnelPrivate, + mtu); /** * NMSettingIPTunnel:flags: @@ -856,14 +757,16 @@ nm_setting_ip_tunnel_class_init(NMSettingIPTunnelClass *klass) * * Since: 1.12 **/ - obj_properties[PROP_FLAGS] = g_param_spec_uint(NM_SETTING_IP_TUNNEL_FLAGS, - "", - "", - 0, - G_MAXUINT32, - 0, - G_PARAM_READWRITE | NM_SETTING_PARAM_FUZZY_IGNORE - | G_PARAM_STATIC_STRINGS); + _nm_setting_property_define_direct_uint32(properties_override, + obj_properties, + NM_SETTING_IP_TUNNEL_FLAGS, + PROP_FLAGS, + 0, + G_MAXUINT32, + 0, + NM_SETTING_PARAM_FUZZY_IGNORE, + NMSettingIPTunnelPrivate, + flags); g_object_class_install_properties(object_class, _PROPERTY_ENUMS_LAST, obj_properties); diff --git a/src/libnm-core-impl/nm-setting-ip4-config.c b/src/libnm-core-impl/nm-setting-ip4-config.c index a7b3d68b..5b06739c 100644 --- a/src/libnm-core-impl/nm-setting-ip4-config.c +++ b/src/libnm-core-impl/nm-setting-ip4-config.c @@ -131,9 +131,9 @@ static gboolean verify(NMSetting *setting, NMConnection *connection, GError **error) { NMSettingIP4ConfigPrivate *priv = NM_SETTING_IP4_CONFIG_GET_PRIVATE(setting); - NMSettingIPConfig * s_ip = NM_SETTING_IP_CONFIG(setting); + NMSettingIPConfig *s_ip = NM_SETTING_IP_CONFIG(setting); NMSettingVerifyResult ret; - const char * method; + const char *method; ret = NM_SETTING_CLASS(nm_setting_ip4_config_parent_class)->verify(setting, connection, error); if (ret != NM_SETTING_VERIFY_SUCCESS) @@ -344,7 +344,7 @@ static GVariant * ip4_addresses_get(_NM_SETT_INFO_PROP_TO_DBUS_FCN_ARGS _nm_nil) { gs_unref_ptrarray GPtrArray *addrs = NULL; - const char * gateway; + const char *gateway; g_object_get(setting, NM_SETTING_IP_CONFIG_ADDRESSES, &addrs, NULL); gateway = nm_setting_ip_config_get_gateway(NM_SETTING_IP_CONFIG(setting)); @@ -355,8 +355,8 @@ static gboolean ip4_addresses_set(_NM_SETT_INFO_PROP_FROM_DBUS_FCN_ARGS _nm_nil) { GPtrArray *addrs; - GVariant * s_ip4; - char ** labels, *gateway = NULL; + GVariant *s_ip4; + char **labels, *gateway = NULL; int i; /* FIXME: properly handle errors */ @@ -397,8 +397,8 @@ ip4_address_labels_get(_NM_SETT_INFO_PROP_TO_DBUS_FCN_ARGS _nm_nil) { NMSettingIPConfig *s_ip = NM_SETTING_IP_CONFIG(setting); gboolean have_labels = FALSE; - GPtrArray * labels; - GVariant * ret; + GPtrArray *labels; + GVariant *ret; int num_addrs, i; if (!_nm_connection_serialize_non_secret(flags)) @@ -407,7 +407,7 @@ ip4_address_labels_get(_NM_SETT_INFO_PROP_TO_DBUS_FCN_ARGS _nm_nil) num_addrs = nm_setting_ip_config_get_num_addresses(s_ip); for (i = 0; i < num_addrs; i++) { NMIPAddress *addr = nm_setting_ip_config_get_address(s_ip, i); - GVariant * label = nm_ip_address_get_attribute(addr, NM_IP_ADDRESS_ATTRIBUTE_LABEL); + GVariant *label = nm_ip_address_get_attribute(addr, NM_IP_ADDRESS_ATTRIBUTE_LABEL); if (label) { have_labels = TRUE; @@ -420,7 +420,7 @@ ip4_address_labels_get(_NM_SETT_INFO_PROP_TO_DBUS_FCN_ARGS _nm_nil) labels = g_ptr_array_sized_new(num_addrs); for (i = 0; i < num_addrs; i++) { NMIPAddress *addr = nm_setting_ip_config_get_address(s_ip, i); - GVariant * label = nm_ip_address_get_attribute(addr, NM_IP_ADDRESS_ATTRIBUTE_LABEL); + GVariant *label = nm_ip_address_get_attribute(addr, NM_IP_ADDRESS_ATTRIBUTE_LABEL); g_ptr_array_add(labels, (char *) (label ? g_variant_get_string(label, NULL) : "")); } @@ -523,53 +523,6 @@ ip4_route_data_set(_NM_SETT_INFO_PROP_FROM_DBUS_FCN_ARGS _nm_nil) /*****************************************************************************/ static void -get_property(GObject *object, guint prop_id, GValue *value, GParamSpec *pspec) -{ - NMSettingIP4Config *s_ip4 = NM_SETTING_IP4_CONFIG(object); - - switch (prop_id) { - case PROP_DHCP_CLIENT_ID: - g_value_set_string(value, nm_setting_ip4_config_get_dhcp_client_id(s_ip4)); - break; - case PROP_DHCP_FQDN: - g_value_set_string(value, nm_setting_ip4_config_get_dhcp_fqdn(s_ip4)); - break; - case PROP_DHCP_VENDOR_CLASS_IDENTIFIER: - g_value_set_string(value, nm_setting_ip4_config_get_dhcp_vendor_class_identifier(s_ip4)); - break; - default: - G_OBJECT_WARN_INVALID_PROPERTY_ID(object, prop_id, pspec); - break; - } -} - -static void -set_property(GObject *object, guint prop_id, const GValue *value, GParamSpec *pspec) -{ - NMSettingIP4ConfigPrivate *priv = NM_SETTING_IP4_CONFIG_GET_PRIVATE(object); - - switch (prop_id) { - case PROP_DHCP_CLIENT_ID: - g_free(priv->dhcp_client_id); - priv->dhcp_client_id = g_value_dup_string(value); - break; - case PROP_DHCP_FQDN: - g_free(priv->dhcp_fqdn); - priv->dhcp_fqdn = g_value_dup_string(value); - break; - case PROP_DHCP_VENDOR_CLASS_IDENTIFIER: - g_free(priv->dhcp_vendor_class_identifier); - priv->dhcp_vendor_class_identifier = g_value_dup_string(value); - break; - default: - G_OBJECT_WARN_INVALID_PROPERTY_ID(object, prop_id, pspec); - break; - } -} - -/*****************************************************************************/ - -static void nm_setting_ip4_config_init(NMSettingIP4Config *setting) { NMSettingIP4ConfigPrivate *priv = NM_SETTING_IP4_CONFIG_GET_PRIVATE(setting); @@ -593,15 +546,15 @@ nm_setting_ip4_config_new(void) static void nm_setting_ip4_config_class_init(NMSettingIP4ConfigClass *klass) { - GObjectClass * object_class = G_OBJECT_CLASS(klass); - NMSettingClass * setting_class = NM_SETTING_CLASS(klass); + GObjectClass *object_class = G_OBJECT_CLASS(klass); + NMSettingClass *setting_class = NM_SETTING_CLASS(klass); NMSettingIPConfigClass *setting_ip_config_class = NM_SETTING_IP_CONFIG_CLASS(klass); GArray *properties_override = _nm_sett_info_property_override_create_array_ip_config(AF_INET); g_type_class_add_private(klass, sizeof(NMSettingIP4ConfigPrivate)); - object_class->get_property = get_property; - object_class->set_property = set_property; + object_class->get_property = _nm_setting_property_get_property_direct; + object_class->set_property = _nm_setting_property_set_property_direct; setting_class->verify = verify; @@ -996,9 +949,73 @@ nm_setting_ip4_config_class_init(NMSettingIP4ConfigClass *klass) * property: routes * format: a comma separated list of routes * description: A list of IPv4 destination addresses, prefix length, optional IPv4 - * next hop addresses, optional route metric, optional attribute. The valid syntax is: - * "ip[/prefix] [next-hop] [metric] [attribute=val]...[,ip[/prefix]...]". For example - * "192.0.2.0/24 10.1.1.1 77, 198.51.100.0/24". + * next hop addresses, optional route metric, optional attribute. The valid syntax is: + * "ip[/prefix] [next-hop] [metric] [attribute=val]...[,ip[/prefix]...]". For example + * "192.0.2.0/24 10.1.1.1 77, 198.51.100.0/24". + * description-docbook: + * <para> + * A list of IPv4 destination addresses, prefix length, optional IPv4 + * next hop addresses, optional route metric, optional attribute. The valid syntax is: + * "ip[/prefix] [next-hop] [metric] [attribute=val]...[,ip[/prefix]...]". + * For example "192.0.2.0/24 10.1.1.1 77, 198.51.100.0/24". + * </para> + * <para> + * Various attributes are supported: + * <itemizedlist> + * <listitem> + * <para><literal>"cwnd"</literal> - an unsigned 32 bit integer.</para> + * </listitem> + * <listitem> + * <para><literal>"initcwnd"</literal> - an unsigned 32 bit integer.</para> + * </listitem> + * <listitem> + * <para><literal>"initrwnd"</literal> - an unsigned 32 bit integer.</para> + * </listitem> + * <listitem> + * <para><literal>"lock-cwnd"</literal> - a boolean value.</para> + * </listitem> + * <listitem> + * <para><literal>"lock-initcwnd"</literal> - a boolean value.</para> + * </listitem> + * <listitem> + * <para><literal>"lock-initrwnd"</literal> - a boolean value.</para> + * </listitem> + * <listitem> + * <para><literal>"lock-mtu"</literal> - a boolean value.</para> + * </listitem> + * <listitem> + * <para><literal>"lock-window"</literal> - a boolean value.</para> + * </listitem> + * <listitem> + * <para><literal>"mtu"</literal> - an unsigned 32 bit integer.</para> + * </listitem> + * <listitem> + * <para><literal>"onlink"</literal> - a boolean value.</para> + * </listitem> + * <listitem> + * <para><literal>"scope"</literal> - an unsigned 8 bit integer. IPv4 only.</para> + * </listitem> + * <listitem> + * <para><literal>"src"</literal> - an IPv4 address.</para> + * </listitem> + * <listitem> + * <para><literal>"table"</literal> - an unsigned 32 bit integer. The default depends on ipv4.route-table.</para> + * </listitem> + * <listitem> + * <para><literal>"tos"</literal> - an unsigned 8 bit integer. IPv4 only.</para> + * </listitem> + * <listitem> + * <para><literal>"type"</literal> - one of <literal>unicast</literal>, <literal>local</literal>, <literal>blackhole</literal>, + * <literal>unavailable</literal>, <literal>prohibit</literal>. The default is <literal>unicast</literal>.</para> + * </listitem> + * <listitem> + * <para><literal>"window"</literal> - an unsigned 32 bit integer.</para> + * </listitem> + * </itemizedlist> + * </para> + * <para> + * For details see also `man ip-route`. + * </para> * ---end--- */ _nm_properties_override_gobj( @@ -1030,6 +1047,23 @@ nm_setting_ip4_config_class_init(NMSettingIP4ConfigClass *klass) .compare_fcn = _nm_setting_property_compare_fcn_ignore, .from_dbus_fcn = ip4_route_data_set, )); + /* ---nmcli--- + * property: routing-rules + * format: a comma separated list of routing rules + * description: A comma separated list of routing rules for policy routing. + * description-docbook: + * <para> + * A comma separated list of routing rules for policy routing. The format + * is based on <command>ip rule add</command> syntax and mostly compatible. + * One difference is that routing rules in NetworkManager always need a + * fixed priority. + * </para> + * <para> + * Example: <literal>priority 5 from 192.167.4.0/24 table 45</literal> + * </para> + * ---end--- + */ + g_object_class_install_properties(object_class, _PROPERTY_ENUMS_LAST, obj_properties); _nm_setting_class_commit(setting_class, diff --git a/src/libnm-core-impl/nm-setting-ip6-config.c b/src/libnm-core-impl/nm-setting-ip6-config.c index 87b9d958..f4623b28 100644 --- a/src/libnm-core-impl/nm-setting-ip6-config.c +++ b/src/libnm-core-impl/nm-setting-ip6-config.c @@ -48,11 +48,11 @@ NM_GOBJECT_PROPERTIES_DEFINE_BASE(PROP_IP6_PRIVACY, typedef struct { NMSettingIPConfigPrivate parent; - char * token; - char * dhcp_duid; - NMSettingIP6ConfigPrivacy ip6_privacy; - NMSettingIP6ConfigAddrGenMode addr_gen_mode; - gint32 ra_timeout; + char *token; + char *dhcp_duid; + int ip6_privacy; + gint32 addr_gen_mode; + gint32 ra_timeout; } NMSettingIP6ConfigPrivate; /** @@ -175,9 +175,9 @@ static gboolean verify(NMSetting *setting, NMConnection *connection, GError **error) { NMSettingIP6ConfigPrivate *priv = NM_SETTING_IP6_CONFIG_GET_PRIVATE(setting); - NMSettingIPConfig * s_ip = NM_SETTING_IP_CONFIG(setting); + NMSettingIPConfig *s_ip = NM_SETTING_IP_CONFIG(setting); NMSettingVerifyResult ret; - const char * method; + const char *method; gboolean token_needs_normalization = FALSE; ret = NM_SETTING_CLASS(nm_setting_ip6_config_parent_class)->verify(setting, connection, error); @@ -385,7 +385,7 @@ static GVariant * ip6_addresses_get(_NM_SETT_INFO_PROP_TO_DBUS_FCN_ARGS _nm_nil) { gs_unref_ptrarray GPtrArray *addrs = NULL; - const char * gateway; + const char *gateway; g_object_get(setting, NM_SETTING_IP_CONFIG_ADDRESSES, &addrs, NULL); gateway = nm_setting_ip_config_get_gateway(NM_SETTING_IP_CONFIG(setting)); @@ -396,7 +396,7 @@ static gboolean ip6_addresses_set(_NM_SETT_INFO_PROP_FROM_DBUS_FCN_ARGS _nm_nil) { GPtrArray *addrs; - char * gateway = NULL; + char *gateway = NULL; if (!_nm_setting_use_legacy_property(setting, connection_dict, "addresses", "address-data")) { *out_is_modified = FALSE; @@ -502,72 +502,11 @@ ip6_route_data_set(_NM_SETT_INFO_PROP_FROM_DBUS_FCN_ARGS _nm_nil) /*****************************************************************************/ static void -get_property(GObject *object, guint prop_id, GValue *value, GParamSpec *pspec) -{ - NMSettingIP6ConfigPrivate *priv = NM_SETTING_IP6_CONFIG_GET_PRIVATE(object); - - switch (prop_id) { - case PROP_IP6_PRIVACY: - g_value_set_enum(value, priv->ip6_privacy); - break; - case PROP_ADDR_GEN_MODE: - g_value_set_int(value, priv->addr_gen_mode); - break; - case PROP_TOKEN: - g_value_set_string(value, priv->token); - break; - case PROP_DHCP_DUID: - g_value_set_string(value, priv->dhcp_duid); - break; - case PROP_RA_TIMEOUT: - g_value_set_int(value, priv->ra_timeout); - break; - default: - G_OBJECT_WARN_INVALID_PROPERTY_ID(object, prop_id, pspec); - break; - } -} - -static void -set_property(GObject *object, guint prop_id, const GValue *value, GParamSpec *pspec) -{ - NMSettingIP6ConfigPrivate *priv = NM_SETTING_IP6_CONFIG_GET_PRIVATE(object); - - switch (prop_id) { - case PROP_IP6_PRIVACY: - priv->ip6_privacy = g_value_get_enum(value); - break; - case PROP_ADDR_GEN_MODE: - priv->addr_gen_mode = g_value_get_int(value); - break; - case PROP_TOKEN: - g_free(priv->token); - priv->token = g_value_dup_string(value); - break; - case PROP_DHCP_DUID: - g_free(priv->dhcp_duid); - priv->dhcp_duid = g_value_dup_string(value); - break; - case PROP_RA_TIMEOUT: - priv->ra_timeout = g_value_get_int(value); - break; - default: - G_OBJECT_WARN_INVALID_PROPERTY_ID(object, prop_id, pspec); - break; - } -} - -/*****************************************************************************/ - -static void nm_setting_ip6_config_init(NMSettingIP6Config *setting) { NMSettingIP6ConfigPrivate *priv = NM_SETTING_IP6_CONFIG_GET_PRIVATE(setting); _nm_setting_ip_config_private_init(setting, &priv->parent); - - priv->ip6_privacy = NM_SETTING_IP6_CONFIG_PRIVACY_UNKNOWN; - priv->addr_gen_mode = NM_SETTING_IP6_CONFIG_ADDR_GEN_MODE_STABLE_PRIVACY; } /** @@ -586,15 +525,15 @@ nm_setting_ip6_config_new(void) static void nm_setting_ip6_config_class_init(NMSettingIP6ConfigClass *klass) { - GObjectClass * object_class = G_OBJECT_CLASS(klass); - NMSettingClass * setting_class = NM_SETTING_CLASS(klass); + GObjectClass *object_class = G_OBJECT_CLASS(klass); + NMSettingClass *setting_class = NM_SETTING_CLASS(klass); NMSettingIPConfigClass *setting_ip_config_class = NM_SETTING_IP_CONFIG_CLASS(klass); GArray *properties_override = _nm_sett_info_property_override_create_array_ip_config(AF_INET6); g_type_class_add_private(klass, sizeof(NMSettingIP6ConfigPrivate)); - object_class->get_property = get_property; - object_class->set_property = set_property; + object_class->get_property = _nm_setting_property_get_property_direct; + object_class->set_property = _nm_setting_property_set_property_direct; setting_class->verify = verify; @@ -803,13 +742,15 @@ nm_setting_ip6_config_class_init(NMSettingIP6ConfigClass *klass) * example: IPV6_PRIVACY=rfc3041 IPV6_PRIVACY_PREFER_PUBLIC_IP=yes * ---end--- */ - obj_properties[PROP_IP6_PRIVACY] = - g_param_spec_enum(NM_SETTING_IP6_CONFIG_IP6_PRIVACY, - "", - "", - NM_TYPE_SETTING_IP6_CONFIG_PRIVACY, - NM_SETTING_IP6_CONFIG_PRIVACY_UNKNOWN, - G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS); + _nm_setting_property_define_direct_enum(properties_override, + obj_properties, + NM_SETTING_IP6_CONFIG_IP6_PRIVACY, + PROP_IP6_PRIVACY, + NM_TYPE_SETTING_IP6_CONFIG_PRIVACY, + NM_SETTING_IP6_CONFIG_PRIVACY_UNKNOWN, + NM_SETTING_PARAM_NONE, + NMSettingIP6ConfigPrivate, + ip6_privacy); /** * NMSettingIP6Config:addr-gen-mode: @@ -852,14 +793,16 @@ nm_setting_ip6_config_class_init(NMSettingIP6ConfigClass *klass) * example: IPV6_ADDR_GEN_MODE=stable-privacy * ---end--- */ - obj_properties[PROP_ADDR_GEN_MODE] = - g_param_spec_int(NM_SETTING_IP6_CONFIG_ADDR_GEN_MODE, - "", - "", - G_MININT, - G_MAXINT, - NM_SETTING_IP6_CONFIG_ADDR_GEN_MODE_STABLE_PRIVACY, - G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS); + _nm_setting_property_define_direct_int32(properties_override, + obj_properties, + NM_SETTING_IP6_CONFIG_ADDR_GEN_MODE, + PROP_ADDR_GEN_MODE, + G_MININT32, + G_MAXINT32, + NM_SETTING_IP6_CONFIG_ADDR_GEN_MODE_STABLE_PRIVACY, + NM_SETTING_PARAM_NONE, + NMSettingIP6ConfigPrivate, + addr_gen_mode); /** * NMSettingIP6Config:token: @@ -902,15 +845,16 @@ nm_setting_ip6_config_class_init(NMSettingIP6ConfigClass *klass) * example: IPV6_RA_TIMEOUT=10 * ---end--- */ - - obj_properties[PROP_RA_TIMEOUT] = g_param_spec_int( - NM_SETTING_IP6_CONFIG_RA_TIMEOUT, - "", - "", - 0, - G_MAXINT32, - 0, - G_PARAM_READWRITE | NM_SETTING_PARAM_FUZZY_IGNORE | G_PARAM_STATIC_STRINGS); + _nm_setting_property_define_direct_int32(properties_override, + obj_properties, + NM_SETTING_IP6_CONFIG_RA_TIMEOUT, + PROP_RA_TIMEOUT, + 0, + G_MAXINT32, + 0, + NM_SETTING_PARAM_FUZZY_IGNORE, + NMSettingIP6ConfigPrivate, + ra_timeout); /** * NMSettingIP6Config:dhcp-duid: @@ -1045,6 +989,71 @@ nm_setting_ip6_config_class_init(NMSettingIP6ConfigClass *klass) * default metric for the device. * ---end--- */ + /* ---nmcli--- + * property: routes + * format: a comma separated list of routes + * description-docbook: + * <para> + * A list of IPv6 destination addresses, prefix length, optional IPv6 + * next hop addresses, optional route metric, optional attribute. The valid syntax is: + * "ip[/prefix] [next-hop] [metric] [attribute=val]...[,ip[/prefix]...]". + * </para> + * <para> + * Various attributes are supported: + * <itemizedlist> + * <listitem> + * <para><literal>"cwnd"</literal> - an unsigned 32 bit integer.</para> + * </listitem> + * <listitem> + * <para><literal>"from"</literal> - an IPv6 address with optional prefix. IPv6 only.</para> + * </listitem> + * <listitem> + * <para><literal>"initcwnd"</literal> - an unsigned 32 bit integer.</para> + * </listitem> + * <listitem> + * <para><literal>"initrwnd"</literal> - an unsigned 32 bit integer.</para> + * </listitem> + * <listitem> + * <para><literal>"lock-cwnd"</literal> - a boolean value.</para> + * </listitem> + * <listitem> + * <para><literal>"lock-initcwnd"</literal> - a boolean value.</para> + * </listitem> + * <listitem> + * <para><literal>"lock-initrwnd"</literal> - a boolean value.</para> + * </listitem> + * <listitem> + * <para><literal>"lock-mtu"</literal> - a boolean value.</para> + * </listitem> + * <listitem> + * <para><literal>"lock-window"</literal> - a boolean value.</para> + * </listitem> + * <listitem> + * <para><literal>"mtu"</literal> - an unsigned 32 bit integer.</para> + * </listitem> + * <listitem> + * <para><literal>"onlink"</literal> - a boolean value.</para> + * </listitem> + * <listitem> + * <para><literal>"src"</literal> - an IPv6 address.</para> + * </listitem> + * <listitem> + * <para><literal>"table"</literal> - an unsigned 32 bit integer. The default depends on ipv6.route-table.</para> + * </listitem> + * <listitem> + * <para><literal>"type"</literal> - one of <literal>unicast</literal>, <literal>local</literal>, <literal>blackhole</literal>, + * <literal>unavailable</literal>, <literal>prohibit</literal>. The default is <literal>unicast</literal>.</para> + * </listitem> + * <listitem> + * <para><literal>"window"</literal> - an unsigned 32 bit integer.</para> + * </listitem> + * </itemizedlist> + * </para> + * <para> + * For details see also `man ip-route`. + * </para> + * ---end--- + */ _nm_properties_override_gobj( properties_override, g_object_class_find_property(G_OBJECT_CLASS(setting_class), NM_SETTING_IP_CONFIG_ROUTES), @@ -1074,6 +1083,23 @@ nm_setting_ip6_config_class_init(NMSettingIP6ConfigClass *klass) .compare_fcn = _nm_setting_property_compare_fcn_ignore, .from_dbus_fcn = ip6_route_data_set, )); + /* ---nmcli--- + * property: routing-rules + * format: a comma separated list of routing rules + * description: A comma separated list of routing rules for policy routing. + * description-docbook: + * <para> + * A comma separated list of routing rules for policy routing. The format + * is based on <command>ip rule add</command> syntax and mostly compatible. + * One difference is that routing rules in NetworkManager always need a + * fixed priority. + * </para> + * <para> + * Example: <literal>priority 5 from 1:2:3::5/128 table 45</literal> + * </para> + * ---end--- + */ + g_object_class_install_properties(object_class, _PROPERTY_ENUMS_LAST, obj_properties); _nm_setting_class_commit(setting_class, diff --git a/src/libnm-core-impl/nm-setting-macsec.c b/src/libnm-core-impl/nm-setting-macsec.c index 1a9e9bd8..85271214 100644 --- a/src/libnm-core-impl/nm-setting-macsec.c +++ b/src/libnm-core-impl/nm-setting-macsec.c @@ -38,15 +38,15 @@ NM_GOBJECT_PROPERTIES_DEFINE_BASE(PROP_PARENT, PROP_SEND_SCI, ); typedef struct { - char * parent; - char * mka_cak; - char * mka_ckn; - int port; - NMSettingMacsecMode mode; - NMSettingSecretFlags mka_cak_flags; - NMSettingMacsecValidation validation; - bool encrypt; - bool send_sci; + char *parent; + char *mka_cak; + char *mka_ckn; + guint mka_cak_flags; + gint32 mode; + gint32 validation; + gint32 port; + bool encrypt; + bool send_sci; } NMSettingMacsecPrivate; /** @@ -84,6 +84,7 @@ const char * nm_setting_macsec_get_parent(NMSettingMacsec *setting) { g_return_val_if_fail(NM_IS_SETTING_MACSEC(setting), NULL); + return NM_SETTING_MACSEC_GET_PRIVATE(setting)->parent; } @@ -99,6 +100,7 @@ NMSettingMacsecMode nm_setting_macsec_get_mode(NMSettingMacsec *setting) { g_return_val_if_fail(NM_IS_SETTING_MACSEC(setting), NM_SETTING_MACSEC_MODE_PSK); + return NM_SETTING_MACSEC_GET_PRIVATE(setting)->mode; } @@ -129,6 +131,7 @@ const char * nm_setting_macsec_get_mka_cak(NMSettingMacsec *setting) { g_return_val_if_fail(NM_IS_SETTING_MACSEC(setting), NULL); + return NM_SETTING_MACSEC_GET_PRIVATE(setting)->mka_cak; } @@ -160,6 +163,7 @@ const char * nm_setting_macsec_get_mka_ckn(NMSettingMacsec *setting) { g_return_val_if_fail(NM_IS_SETTING_MACSEC(setting), NULL); + return NM_SETTING_MACSEC_GET_PRIVATE(setting)->mka_ckn; } @@ -175,6 +179,7 @@ int nm_setting_macsec_get_port(NMSettingMacsec *setting) { g_return_val_if_fail(NM_IS_SETTING_MACSEC(setting), 1); + return NM_SETTING_MACSEC_GET_PRIVATE(setting)->port; } @@ -190,6 +195,7 @@ NMSettingMacsecValidation nm_setting_macsec_get_validation(NMSettingMacsec *setting) { g_return_val_if_fail(NM_IS_SETTING_MACSEC(setting), NM_SETTING_MACSEC_VALIDATION_DISABLE); + return NM_SETTING_MACSEC_GET_PRIVATE(setting)->validation; } @@ -212,7 +218,7 @@ static GPtrArray * need_secrets(NMSetting *setting) { NMSettingMacsecPrivate *priv = NM_SETTING_MACSEC_GET_PRIVATE(setting); - GPtrArray * secrets = NULL; + GPtrArray *secrets = NULL; if (priv->mode == NM_SETTING_MACSEC_MODE_PSK) { if (!priv->mka_cak @@ -271,9 +277,9 @@ static gboolean verify(NMSetting *setting, NMConnection *connection, GError **error) { NMSettingMacsecPrivate *priv = NM_SETTING_MACSEC_GET_PRIVATE(setting); - NMSettingConnection * s_con = NULL; - NMSettingWired * s_wired = NULL; - NMSetting8021x * s_8021x = NULL; + NMSettingConnection *s_con = NULL; + NMSettingWired *s_wired = NULL; + NMSetting8021x *s_8021x = NULL; if (connection) { s_con = nm_connection_get_setting_connection(connection); @@ -374,15 +380,7 @@ verify(NMSetting *setting, NMConnection *connection, GError **error) return FALSE; } - if (priv->port <= 0 || priv->port > 65534) { - g_set_error(error, - NM_CONNECTION_ERROR, - NM_CONNECTION_ERROR_MISSING_PROPERTY, - _("invalid port %d"), - priv->port); - g_prefix_error(error, "%s.%s: ", NM_SETTING_MACSEC_SETTING_NAME, NM_SETTING_MACSEC_PORT); - return FALSE; - } + nm_assert(priv->port >= 1 && priv->port <= 65534); if (priv->mode != NM_SETTING_MACSEC_MODE_PSK && (priv->mka_cak || priv->mka_ckn)) { g_set_error_literal(error, @@ -402,99 +400,8 @@ verify(NMSetting *setting, NMConnection *connection, GError **error) /*****************************************************************************/ static void -get_property(GObject *object, guint prop_id, GValue *value, GParamSpec *pspec) -{ - NMSettingMacsec * setting = NM_SETTING_MACSEC(object); - NMSettingMacsecPrivate *priv = NM_SETTING_MACSEC_GET_PRIVATE(setting); - - switch (prop_id) { - case PROP_PARENT: - g_value_set_string(value, priv->parent); - break; - case PROP_MODE: - g_value_set_int(value, priv->mode); - break; - case PROP_ENCRYPT: - g_value_set_boolean(value, priv->encrypt); - break; - case PROP_MKA_CAK: - g_value_set_string(value, priv->mka_cak); - break; - case PROP_MKA_CAK_FLAGS: - g_value_set_flags(value, priv->mka_cak_flags); - break; - case PROP_MKA_CKN: - g_value_set_string(value, priv->mka_ckn); - break; - case PROP_PORT: - g_value_set_int(value, priv->port); - break; - case PROP_VALIDATION: - g_value_set_int(value, priv->validation); - break; - case PROP_SEND_SCI: - g_value_set_boolean(value, priv->send_sci); - break; - default: - G_OBJECT_WARN_INVALID_PROPERTY_ID(object, prop_id, pspec); - break; - } -} - -static void -set_property(GObject *object, guint prop_id, const GValue *value, GParamSpec *pspec) -{ - NMSettingMacsec * setting = NM_SETTING_MACSEC(object); - NMSettingMacsecPrivate *priv = NM_SETTING_MACSEC_GET_PRIVATE(setting); - - switch (prop_id) { - case PROP_PARENT: - g_free(priv->parent); - priv->parent = g_value_dup_string(value); - break; - case PROP_MODE: - priv->mode = g_value_get_int(value); - break; - case PROP_ENCRYPT: - priv->encrypt = g_value_get_boolean(value); - break; - case PROP_MKA_CAK: - nm_free_secret(priv->mka_cak); - priv->mka_cak = g_value_dup_string(value); - break; - case PROP_MKA_CAK_FLAGS: - priv->mka_cak_flags = g_value_get_flags(value); - break; - case PROP_MKA_CKN: - g_free(priv->mka_ckn); - priv->mka_ckn = g_value_dup_string(value); - break; - case PROP_PORT: - priv->port = g_value_get_int(value); - break; - case PROP_VALIDATION: - priv->validation = g_value_get_int(value); - break; - case PROP_SEND_SCI: - priv->send_sci = g_value_get_boolean(value); - break; - default: - G_OBJECT_WARN_INVALID_PROPERTY_ID(object, prop_id, pspec); - break; - } -} - -/*****************************************************************************/ - -static void nm_setting_macsec_init(NMSettingMacsec *self) -{ - NMSettingMacsecPrivate *priv = NM_SETTING_MACSEC_GET_PRIVATE(self); - - nm_assert(priv->mode == NM_SETTING_MACSEC_MODE_PSK); - priv->port = 1; - priv->validation = NM_SETTING_MACSEC_VALIDATION_STRICT; -} +{} /** * nm_setting_macsec_new: @@ -512,30 +419,16 @@ nm_setting_macsec_new(void) } static void -finalize(GObject *object) -{ - NMSettingMacsec * setting = NM_SETTING_MACSEC(object); - NMSettingMacsecPrivate *priv = NM_SETTING_MACSEC_GET_PRIVATE(setting); - - g_free(priv->parent); - nm_free_secret(priv->mka_cak); - g_free(priv->mka_ckn); - - G_OBJECT_CLASS(nm_setting_macsec_parent_class)->finalize(object); -} - -static void nm_setting_macsec_class_init(NMSettingMacsecClass *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(NMSettingMacsecPrivate)); - object_class->get_property = get_property; - object_class->set_property = set_property; - object_class->finalize = finalize; + object_class->get_property = _nm_setting_property_get_property_direct; + object_class->set_property = _nm_setting_property_set_property_direct; setting_class->verify = verify; setting_class->need_secrets = need_secrets; @@ -550,12 +443,13 @@ nm_setting_macsec_class_init(NMSettingMacsecClass *klass) * * Since: 1.6 **/ - obj_properties[PROP_PARENT] = g_param_spec_string( - NM_SETTING_MACSEC_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_MACSEC_PARENT, + PROP_PARENT, + NM_SETTING_PARAM_INFERRABLE, + NMSettingMacsecPrivate, + parent); /** * NMSettingMacsec:mode: @@ -565,14 +459,16 @@ nm_setting_macsec_class_init(NMSettingMacsecClass *klass) * * Since: 1.6 **/ - obj_properties[PROP_MODE] = - g_param_spec_int(NM_SETTING_MACSEC_MODE, - "", - "", - G_MININT, - G_MAXINT, - NM_SETTING_MACSEC_MODE_PSK, - G_PARAM_READWRITE | NM_SETTING_PARAM_INFERRABLE | G_PARAM_STATIC_STRINGS); + _nm_setting_property_define_direct_int32(properties_override, + obj_properties, + NM_SETTING_MACSEC_MODE, + PROP_MODE, + G_MININT32, + G_MAXINT32, + NM_SETTING_MACSEC_MODE_PSK, + NM_SETTING_PARAM_INFERRABLE, + NMSettingMacsecPrivate, + mode); /** * NMSettingMacsec:encrypt: @@ -598,12 +494,13 @@ nm_setting_macsec_class_init(NMSettingMacsecClass *klass) * * Since: 1.6 **/ - obj_properties[PROP_MKA_CAK] = - g_param_spec_string(NM_SETTING_MACSEC_MKA_CAK, - "", - "", - NULL, - G_PARAM_READWRITE | NM_SETTING_PARAM_SECRET | G_PARAM_STATIC_STRINGS); + _nm_setting_property_define_direct_string(properties_override, + obj_properties, + NM_SETTING_MACSEC_MKA_CAK, + PROP_MKA_CAK, + NM_SETTING_PARAM_SECRET, + NMSettingMacsecPrivate, + mka_cak); /** * NMSettingMacsec:mka-cak-flags: @@ -613,13 +510,12 @@ nm_setting_macsec_class_init(NMSettingMacsecClass *klass) * * Since: 1.6 **/ - obj_properties[PROP_MKA_CAK_FLAGS] = - g_param_spec_flags(NM_SETTING_MACSEC_MKA_CAK_FLAGS, - "", - "", - NM_TYPE_SETTING_SECRET_FLAGS, - NM_SETTING_SECRET_FLAG_NONE, - G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS); + _nm_setting_property_define_direct_secret_flags(properties_override, + obj_properties, + NM_SETTING_MACSEC_MKA_CAK_FLAGS, + PROP_MKA_CAK_FLAGS, + NMSettingMacsecPrivate, + mka_cak_flags); /** * NMSettingMacsec:mka-ckn: @@ -629,11 +525,13 @@ nm_setting_macsec_class_init(NMSettingMacsecClass *klass) * * Since: 1.6 **/ - obj_properties[PROP_MKA_CKN] = g_param_spec_string(NM_SETTING_MACSEC_MKA_CKN, - "", - "", - NULL, - G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS); + _nm_setting_property_define_direct_string(properties_override, + obj_properties, + NM_SETTING_MACSEC_MKA_CKN, + PROP_MKA_CKN, + NM_SETTING_PARAM_NONE, + NMSettingMacsecPrivate, + mka_ckn); /** * NMSettingMacsec:port: @@ -642,14 +540,16 @@ nm_setting_macsec_class_init(NMSettingMacsecClass *klass) * * Since: 1.6 **/ - obj_properties[PROP_PORT] = - g_param_spec_int(NM_SETTING_MACSEC_PORT, - "", - "", - 1, - 65534, - 1, - G_PARAM_READWRITE | NM_SETTING_PARAM_INFERRABLE | G_PARAM_STATIC_STRINGS); + _nm_setting_property_define_direct_int32(properties_override, + obj_properties, + NM_SETTING_MACSEC_PORT, + PROP_PORT, + 1, + 65534, + 1, + NM_SETTING_PARAM_INFERRABLE, + NMSettingMacsecPrivate, + port); /** * NMSettingMacsec:validation: @@ -658,14 +558,16 @@ nm_setting_macsec_class_init(NMSettingMacsecClass *klass) * * Since: 1.6 **/ - obj_properties[PROP_VALIDATION] = - g_param_spec_int(NM_SETTING_MACSEC_VALIDATION, - "", - "", - G_MININT, - G_MAXINT, - NM_SETTING_MACSEC_VALIDATION_STRICT, - G_PARAM_READWRITE | NM_SETTING_PARAM_INFERRABLE | G_PARAM_STATIC_STRINGS); + _nm_setting_property_define_direct_int32(properties_override, + obj_properties, + NM_SETTING_MACSEC_VALIDATION, + PROP_VALIDATION, + G_MININT32, + G_MAXINT32, + NM_SETTING_MACSEC_VALIDATION_STRICT, + NM_SETTING_PARAM_INFERRABLE, + NMSettingMacsecPrivate, + validation); /** * NMSettingMacsec:send-sci: diff --git a/src/libnm-core-impl/nm-setting-macvlan.c b/src/libnm-core-impl/nm-setting-macvlan.c index 32b30c2c..d26a8086 100644 --- a/src/libnm-core-impl/nm-setting-macvlan.c +++ b/src/libnm-core-impl/nm-setting-macvlan.c @@ -28,10 +28,10 @@ NM_GOBJECT_PROPERTIES_DEFINE_BASE(PROP_PARENT, PROP_MODE, PROP_PROMISCUOUS, PROP_TAP, ); typedef struct { - char * parent; - NMSettingMacvlanMode mode; - bool promiscuous; - bool tap; + char *parent; + guint32 mode; + bool promiscuous; + bool tap; } NMSettingMacvlanPrivate; /** @@ -69,6 +69,7 @@ const char * nm_setting_macvlan_get_parent(NMSettingMacvlan *setting) { g_return_val_if_fail(NM_IS_SETTING_MACVLAN(setting), NULL); + return NM_SETTING_MACVLAN_GET_PRIVATE(setting)->parent; } @@ -84,6 +85,7 @@ NMSettingMacvlanMode nm_setting_macvlan_get_mode(NMSettingMacvlan *setting) { g_return_val_if_fail(NM_IS_SETTING_MACVLAN(setting), NM_SETTING_MACVLAN_MODE_UNKNOWN); + return NM_SETTING_MACVLAN_GET_PRIVATE(setting)->mode; } @@ -123,7 +125,7 @@ static gboolean verify(NMSetting *setting, NMConnection *connection, GError **error) { NMSettingMacvlanPrivate *priv = NM_SETTING_MACVLAN_GET_PRIVATE(setting); - NMSettingWired * s_wired; + NMSettingWired *s_wired; if (connection) s_wired = nm_connection_get_setting_wired(connection); @@ -180,59 +182,6 @@ verify(NMSetting *setting, NMConnection *connection, GError **error) /*****************************************************************************/ static void -get_property(GObject *object, guint prop_id, GValue *value, GParamSpec *pspec) -{ - NMSettingMacvlan * setting = NM_SETTING_MACVLAN(object); - NMSettingMacvlanPrivate *priv = NM_SETTING_MACVLAN_GET_PRIVATE(setting); - - switch (prop_id) { - case PROP_PARENT: - g_value_set_string(value, priv->parent); - break; - case PROP_MODE: - g_value_set_uint(value, priv->mode); - break; - case PROP_PROMISCUOUS: - g_value_set_boolean(value, priv->promiscuous); - break; - case PROP_TAP: - g_value_set_boolean(value, priv->tap); - break; - default: - G_OBJECT_WARN_INVALID_PROPERTY_ID(object, prop_id, pspec); - break; - } -} - -static void -set_property(GObject *object, guint prop_id, const GValue *value, GParamSpec *pspec) -{ - NMSettingMacvlan * setting = NM_SETTING_MACVLAN(object); - NMSettingMacvlanPrivate *priv = NM_SETTING_MACVLAN_GET_PRIVATE(setting); - - switch (prop_id) { - case PROP_PARENT: - g_free(priv->parent); - priv->parent = g_value_dup_string(value); - break; - case PROP_MODE: - priv->mode = g_value_get_uint(value); - break; - case PROP_PROMISCUOUS: - priv->promiscuous = g_value_get_boolean(value); - break; - case PROP_TAP: - priv->tap = g_value_get_boolean(value); - break; - default: - G_OBJECT_WARN_INVALID_PROPERTY_ID(object, prop_id, pspec); - break; - } -} - -/*****************************************************************************/ - -static void nm_setting_macvlan_init(NMSettingMacvlan *self) {} @@ -252,28 +201,16 @@ nm_setting_macvlan_new(void) } static void -finalize(GObject *object) -{ - NMSettingMacvlan * setting = NM_SETTING_MACVLAN(object); - NMSettingMacvlanPrivate *priv = NM_SETTING_MACVLAN_GET_PRIVATE(setting); - - g_free(priv->parent); - - G_OBJECT_CLASS(nm_setting_macvlan_parent_class)->finalize(object); -} - -static void nm_setting_macvlan_class_init(NMSettingMacvlanClass *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(NMSettingMacvlanPrivate)); - object_class->get_property = get_property; - object_class->set_property = set_property; - object_class->finalize = finalize; + object_class->get_property = _nm_setting_property_get_property_direct; + object_class->set_property = _nm_setting_property_set_property_direct; setting_class->verify = verify; @@ -287,12 +224,13 @@ nm_setting_macvlan_class_init(NMSettingMacvlanClass *klass) * * Since: 1.2 **/ - obj_properties[PROP_PARENT] = g_param_spec_string( - NM_SETTING_MACVLAN_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_MACVLAN_PARENT, + PROP_PARENT, + NM_SETTING_PARAM_INFERRABLE, + NMSettingMacvlanPrivate, + parent); /** * NMSettingMacvlan:mode: @@ -302,14 +240,16 @@ nm_setting_macvlan_class_init(NMSettingMacvlanClass *klass) * * Since: 1.2 **/ - obj_properties[PROP_MODE] = - g_param_spec_uint(NM_SETTING_MACVLAN_MODE, - "", - "", - 0, - G_MAXUINT, - 0, - G_PARAM_READWRITE | NM_SETTING_PARAM_INFERRABLE | G_PARAM_STATIC_STRINGS); + _nm_setting_property_define_direct_uint32(properties_override, + obj_properties, + NM_SETTING_MACVLAN_MODE, + PROP_MODE, + 0, + G_MAXUINT32, + NM_SETTING_MACVLAN_MODE_UNKNOWN, + NM_SETTING_PARAM_INFERRABLE, + NMSettingMacvlanPrivate, + mode); /** * NMSettingMacvlan:promiscuous: diff --git a/src/libnm-core-impl/nm-setting-match.c b/src/libnm-core-impl/nm-setting-match.c index 20c6b798..0ddffee5 100644 --- a/src/libnm-core-impl/nm-setting-match.c +++ b/src/libnm-core-impl/nm-setting-match.c @@ -33,10 +33,10 @@ NM_GOBJECT_PROPERTIES_DEFINE(NMSettingMatch, */ struct _NMSettingMatch { NMSetting parent; - GArray * interface_name; - GArray * kernel_command_line; - GArray * driver; - GArray * path; + GArray *interface_name; + GArray *kernel_command_line; + GArray *driver; + GArray *path; }; struct _NMSettingMatchClass { @@ -278,7 +278,7 @@ nm_setting_match_remove_kernel_command_line(NMSettingMatch *setting, guint idx) **/ gboolean nm_setting_match_remove_kernel_command_line_by_value(NMSettingMatch *setting, - const char * kernel_command_line) + const char *kernel_command_line) { g_return_val_if_fail(NM_IS_SETTING_MATCH(setting), FALSE); g_return_val_if_fail(kernel_command_line, FALSE); @@ -781,7 +781,7 @@ finalize(GObject *object) static void nm_setting_match_class_init(NMSettingMatchClass *klass) { - GObjectClass * object_class = G_OBJECT_CLASS(klass); + GObjectClass *object_class = G_OBJECT_CLASS(klass); NMSettingClass *setting_class = NM_SETTING_CLASS(klass); object_class->get_property = get_property; diff --git a/src/libnm-core-impl/nm-setting-olpc-mesh.c b/src/libnm-core-impl/nm-setting-olpc-mesh.c index 0da1d5b4..fe6d3842 100644 --- a/src/libnm-core-impl/nm-setting-olpc-mesh.c +++ b/src/libnm-core-impl/nm-setting-olpc-mesh.c @@ -29,7 +29,7 @@ NM_GOBJECT_PROPERTIES_DEFINE_BASE(PROP_SSID, PROP_CHANNEL, PROP_DHCP_ANYCAST_ADD typedef struct { GBytes *ssid; - char * dhcp_anycast_addr; + char *dhcp_anycast_addr; guint32 channel; } NMSettingOlpcMeshPrivate; @@ -167,9 +167,9 @@ nm_setting_olpc_mesh_new(void) static void nm_setting_olpc_mesh_class_init(NMSettingOlpcMeshClass *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(NMSettingOlpcMeshPrivate)); diff --git a/src/libnm-core-impl/nm-setting-ovs-bridge.c b/src/libnm-core-impl/nm-setting-ovs-bridge.c index 711d5461..b15aab19 100644 --- a/src/libnm-core-impl/nm-setting-ovs-bridge.c +++ b/src/libnm-core-impl/nm-setting-ovs-bridge.c @@ -199,64 +199,6 @@ verify(NMSetting *setting, NMConnection *connection, GError **error) /*****************************************************************************/ static void -get_property(GObject *object, guint prop_id, GValue *value, GParamSpec *pspec) -{ - NMSettingOvsBridge *self = NM_SETTING_OVS_BRIDGE(object); - - switch (prop_id) { - case PROP_FAIL_MODE: - g_value_set_string(value, self->fail_mode); - break; - case PROP_MCAST_SNOOPING_ENABLE: - g_value_set_boolean(value, self->mcast_snooping_enable); - break; - case PROP_RSTP_ENABLE: - g_value_set_boolean(value, self->rstp_enable); - break; - case PROP_STP_ENABLE: - g_value_set_boolean(value, self->stp_enable); - break; - case PROP_DATAPATH_TYPE: - g_value_set_string(value, self->datapath_type); - break; - default: - G_OBJECT_WARN_INVALID_PROPERTY_ID(object, prop_id, pspec); - break; - } -} - -static void -set_property(GObject *object, guint prop_id, const GValue *value, GParamSpec *pspec) -{ - NMSettingOvsBridge *self = NM_SETTING_OVS_BRIDGE(object); - - switch (prop_id) { - case PROP_FAIL_MODE: - g_free(self->fail_mode); - self->fail_mode = g_value_dup_string(value); - break; - case PROP_MCAST_SNOOPING_ENABLE: - self->mcast_snooping_enable = g_value_get_boolean(value); - break; - case PROP_RSTP_ENABLE: - self->rstp_enable = g_value_get_boolean(value); - break; - case PROP_STP_ENABLE: - self->stp_enable = g_value_get_boolean(value); - break; - case PROP_DATAPATH_TYPE: - g_free(self->datapath_type); - self->datapath_type = g_value_dup_string(value); - break; - default: - G_OBJECT_WARN_INVALID_PROPERTY_ID(object, prop_id, pspec); - break; - } -} - -/*****************************************************************************/ - -static void nm_setting_ovs_bridge_init(NMSettingOvsBridge *self) {} @@ -276,26 +218,14 @@ nm_setting_ovs_bridge_new(void) } static void -finalize(GObject *object) -{ - NMSettingOvsBridge *self = NM_SETTING_OVS_BRIDGE(object); - - g_free(self->fail_mode); - g_free(self->datapath_type); - - G_OBJECT_CLASS(nm_setting_ovs_bridge_parent_class)->finalize(object); -} - -static void nm_setting_ovs_bridge_class_init(NMSettingOvsBridgeClass *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(); - object_class->get_property = get_property; - object_class->set_property = set_property; - object_class->finalize = finalize; + object_class->get_property = _nm_setting_property_get_property_direct; + object_class->set_property = _nm_setting_property_set_property_direct; setting_class->verify = verify; @@ -306,12 +236,13 @@ nm_setting_ovs_bridge_class_init(NMSettingOvsBridgeClass *klass) * * Since: 1.10 **/ - obj_properties[PROP_FAIL_MODE] = g_param_spec_string( - NM_SETTING_OVS_BRIDGE_FAIL_MODE, - "", - "", - NULL, - G_PARAM_READWRITE | NM_SETTING_PARAM_INFERRABLE | G_PARAM_STATIC_STRINGS); + _nm_setting_property_define_direct_string(properties_override, + obj_properties, + NM_SETTING_OVS_BRIDGE_FAIL_MODE, + PROP_FAIL_MODE, + NM_SETTING_PARAM_INFERRABLE, + NMSettingOvsBridge, + fail_mode); /** * NMSettingOvsBridge:mcast-snooping-enable: @@ -368,12 +299,13 @@ nm_setting_ovs_bridge_class_init(NMSettingOvsBridgeClass *klass) * * Since: 1.20 **/ - obj_properties[PROP_DATAPATH_TYPE] = g_param_spec_string( - NM_SETTING_OVS_BRIDGE_DATAPATH_TYPE, - "", - "", - NULL, - G_PARAM_READWRITE | NM_SETTING_PARAM_INFERRABLE | G_PARAM_STATIC_STRINGS); + _nm_setting_property_define_direct_string(properties_override, + obj_properties, + NM_SETTING_OVS_BRIDGE_DATAPATH_TYPE, + PROP_DATAPATH_TYPE, + NM_SETTING_PARAM_INFERRABLE, + NMSettingOvsBridge, + datapath_type); g_object_class_install_properties(object_class, _PROPERTY_ENUMS_LAST, obj_properties); diff --git a/src/libnm-core-impl/nm-setting-ovs-dpdk.c b/src/libnm-core-impl/nm-setting-ovs-dpdk.c index 3107531b..e26f918b 100644 --- a/src/libnm-core-impl/nm-setting-ovs-dpdk.c +++ b/src/libnm-core-impl/nm-setting-ovs-dpdk.c @@ -10,6 +10,7 @@ #include "nm-connection-private.h" #include "nm-setting-connection.h" #include "nm-setting-private.h" +#include "nm-utils-private.h" /** * SECTION:nm-setting-ovs-dpdk @@ -21,7 +22,7 @@ /*****************************************************************************/ -NM_GOBJECT_PROPERTIES_DEFINE_BASE(PROP_DEVARGS, ); +NM_GOBJECT_PROPERTIES_DEFINE_BASE(PROP_DEVARGS, PROP_N_RXQ, ); /** * NMSettingOvsDpdk: @@ -31,7 +32,8 @@ NM_GOBJECT_PROPERTIES_DEFINE_BASE(PROP_DEVARGS, ); struct _NMSettingOvsDpdk { NMSetting parent; - char *devargs; + char *devargs; + guint32 n_rxq; }; struct _NMSettingOvsDpdkClass { @@ -58,37 +60,20 @@ nm_setting_ovs_dpdk_get_devargs(NMSettingOvsDpdk *self) return self->devargs; } -/*****************************************************************************/ - -static void -get_property(GObject *object, guint prop_id, GValue *value, GParamSpec *pspec) +/** + * nm_setting_ovs_dpdk_get_n_rxq: + * @self: the #NMSettingOvsDpdk + * + * Returns: the #NMSettingOvsDpdk:n-rxq property of the setting + * + * Since: 1.36 + **/ +guint32 +nm_setting_ovs_dpdk_get_n_rxq(NMSettingOvsDpdk *self) { - NMSettingOvsDpdk *self = NM_SETTING_OVS_DPDK(object); - - switch (prop_id) { - case PROP_DEVARGS: - g_value_set_string(value, self->devargs); - break; - default: - G_OBJECT_WARN_INVALID_PROPERTY_ID(object, prop_id, pspec); - break; - } -} + g_return_val_if_fail(NM_IS_SETTING_OVS_DPDK(self), 0); -static void -set_property(GObject *object, guint prop_id, const GValue *value, GParamSpec *pspec) -{ - NMSettingOvsDpdk *self = NM_SETTING_OVS_DPDK(object); - - switch (prop_id) { - case PROP_DEVARGS: - g_free(self->devargs); - self->devargs = g_value_dup_string(value); - break; - default: - G_OBJECT_WARN_INVALID_PROPERTY_ID(object, prop_id, pspec); - break; - } + return self->n_rxq; } /*****************************************************************************/ @@ -113,24 +98,14 @@ nm_setting_ovs_dpdk_new(void) } static void -finalize(GObject *object) -{ - NMSettingOvsDpdk *self = NM_SETTING_OVS_DPDK(object); - - g_free(self->devargs); - - G_OBJECT_CLASS(nm_setting_ovs_dpdk_parent_class)->finalize(object); -} - -static void nm_setting_ovs_dpdk_class_init(NMSettingOvsDpdkClass *klass) { - GObjectClass * object_class = G_OBJECT_CLASS(klass); - NMSettingClass *setting_class = NM_SETTING_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(); - object_class->set_property = set_property; - object_class->get_property = get_property; - object_class->finalize = finalize; + object_class->get_property = _nm_setting_property_get_property_direct; + object_class->set_property = _nm_setting_property_set_property_direct; /** * NMSettingOvsDpdk:devargs: @@ -139,14 +114,39 @@ nm_setting_ovs_dpdk_class_init(NMSettingOvsDpdkClass *klass) * * Since: 1.20 **/ - obj_properties[PROP_DEVARGS] = g_param_spec_string( - NM_SETTING_OVS_DPDK_DEVARGS, - "", - "", - NULL, - G_PARAM_READWRITE | NM_SETTING_PARAM_INFERRABLE | G_PARAM_STATIC_STRINGS); + _nm_setting_property_define_direct_string(properties_override, + obj_properties, + NM_SETTING_OVS_DPDK_DEVARGS, + PROP_DEVARGS, + NM_SETTING_PARAM_INFERRABLE, + NMSettingOvsDpdk, + devargs); + + /** + * NMSettingOvsDpdk:n-rxq: + * + * Open vSwitch DPDK number of rx queues. + * Defaults to zero which means to leave the parameter in OVS unspecified + * and effectively configures one queue. + * + * Since: 1.36 + **/ + _nm_setting_property_define_direct_uint32(properties_override, + obj_properties, + NM_SETTING_OVS_DPDK_N_RXQ, + PROP_N_RXQ, + 0, + G_MAXUINT32, + 0, + NM_SETTING_PARAM_INFERRABLE, + NMSettingOvsDpdk, + n_rxq); g_object_class_install_properties(object_class, _PROPERTY_ENUMS_LAST, obj_properties); - _nm_setting_class_commit(setting_class, NM_META_SETTING_TYPE_OVS_DPDK, NULL, NULL, 0); + _nm_setting_class_commit(setting_class, + NM_META_SETTING_TYPE_OVS_DPDK, + NULL, + properties_override, + 0); } diff --git a/src/libnm-core-impl/nm-setting-ovs-external-ids.c b/src/libnm-core-impl/nm-setting-ovs-external-ids.c index ea4004f0..6b8d5d37 100644 --- a/src/libnm-core-impl/nm-setting-ovs-external-ids.c +++ b/src/libnm-core-impl/nm-setting-ovs-external-ids.c @@ -28,7 +28,7 @@ NM_GOBJECT_PROPERTIES_DEFINE(NMSettingOvsExternalIDs, PROP_DATA, ); typedef struct { - GHashTable * data; + GHashTable *data; const char **data_keys; } NMSettingOvsExternalIDsPrivate; @@ -199,7 +199,7 @@ _nm_setting_ovs_external_ids_get_data(NMSettingOvsExternalIDs *self) const char *const * nm_setting_ovs_external_ids_get_data_keys(NMSettingOvsExternalIDs *setting, guint *out_len) { - NMSettingOvsExternalIDs * self = setting; + NMSettingOvsExternalIDs *self = setting; NMSettingOvsExternalIDsPrivate *priv; g_return_val_if_fail(NM_IS_SETTING_OVS_EXTERNAL_IDS(self), NULL); @@ -233,7 +233,7 @@ nm_setting_ovs_external_ids_get_data_keys(NMSettingOvsExternalIDs *setting, guin const char * nm_setting_ovs_external_ids_get_data(NMSettingOvsExternalIDs *setting, const char *key) { - NMSettingOvsExternalIDs * self = setting; + NMSettingOvsExternalIDs *self = setting; NMSettingOvsExternalIDsPrivate *priv; g_return_val_if_fail(NM_IS_SETTING_OVS_EXTERNAL_IDS(self), NULL); @@ -257,10 +257,10 @@ nm_setting_ovs_external_ids_get_data(NMSettingOvsExternalIDs *setting, const cha */ void nm_setting_ovs_external_ids_set_data(NMSettingOvsExternalIDs *setting, - const char * key, - const char * val) + const char *key, + const char *val) { - NMSettingOvsExternalIDs * self = setting; + NMSettingOvsExternalIDs *self = setting; NMSettingOvsExternalIDsPrivate *priv; g_return_if_fail(NM_IS_SETTING_OVS_EXTERNAL_IDS(self)); @@ -295,14 +295,14 @@ out_changed: static gboolean verify(NMSetting *setting, NMConnection *connection, GError **error) { - NMSettingOvsExternalIDs * self = NM_SETTING_OVS_EXTERNAL_IDS(setting); + NMSettingOvsExternalIDs *self = NM_SETTING_OVS_EXTERNAL_IDS(setting); NMSettingOvsExternalIDsPrivate *priv = NM_SETTING_OVS_EXTERNAL_IDS_GET_PRIVATE(self); if (priv->data) { gs_free_error GError *local = NULL; GHashTableIter iter; - const char * key; - const char * val; + const char *key; + const char *val; g_hash_table_iter_init(&iter, priv->data); while (g_hash_table_iter_next(&iter, (gpointer *) &key, (gpointer *) &val)) { @@ -346,8 +346,8 @@ verify(NMSetting *setting, NMConnection *connection, GError **error) if (connection) { NMSettingConnection *s_con; - const char * type; - const char * slave_type; + const char *type; + const char *slave_type; type = nm_connection_get_connection_type(connection); if (!type) { @@ -408,12 +408,12 @@ compare_fcn_data(_NM_SETT_INFO_PROP_COMPARE_FCN_ARGS _nm_nil) static void get_property(GObject *object, guint prop_id, GValue *value, GParamSpec *pspec) { - NMSettingOvsExternalIDs * self = NM_SETTING_OVS_EXTERNAL_IDS(object); + NMSettingOvsExternalIDs *self = NM_SETTING_OVS_EXTERNAL_IDS(object); NMSettingOvsExternalIDsPrivate *priv = NM_SETTING_OVS_EXTERNAL_IDS_GET_PRIVATE(self); GHashTableIter iter; - GHashTable * data; - const char * key; - const char * val; + GHashTable *data; + const char *key; + const char *val; switch (prop_id) { case PROP_DATA: @@ -434,7 +434,7 @@ 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) { - NMSettingOvsExternalIDs * self = NM_SETTING_OVS_EXTERNAL_IDS(object); + NMSettingOvsExternalIDs *self = NM_SETTING_OVS_EXTERNAL_IDS(object); NMSettingOvsExternalIDsPrivate *priv = NM_SETTING_OVS_EXTERNAL_IDS_GET_PRIVATE(self); switch (prop_id) { @@ -442,9 +442,9 @@ set_property(GObject *object, guint prop_id, const GValue *value, GParamSpec *ps { gs_unref_hashtable GHashTable *old = NULL; GHashTableIter iter; - GHashTable * data; - const char * key; - const char * val; + GHashTable *data; + const char *key; + const char *val; nm_clear_g_free(&priv->data_keys); @@ -491,7 +491,7 @@ nm_setting_ovs_external_ids_new(void) static void finalize(GObject *object) { - NMSettingOvsExternalIDs * self = NM_SETTING_OVS_EXTERNAL_IDS(object); + NMSettingOvsExternalIDs *self = NM_SETTING_OVS_EXTERNAL_IDS(object); NMSettingOvsExternalIDsPrivate *priv = NM_SETTING_OVS_EXTERNAL_IDS_GET_PRIVATE(self); g_free(priv->data_keys); @@ -504,9 +504,9 @@ finalize(GObject *object) static void nm_setting_ovs_external_ids_class_init(NMSettingOvsExternalIDsClass *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(); object_class->get_property = get_property; object_class->set_property = set_property; @@ -543,5 +543,5 @@ nm_setting_ovs_external_ids_class_init(NMSettingOvsExternalIDsClass *klass) NM_META_SETTING_TYPE_OVS_EXTERNAL_IDS, NULL, properties_override, - G_STRUCT_OFFSET(NMSettingOvsExternalIDs, _priv)); + 0); } diff --git a/src/libnm-core-impl/nm-setting-ovs-interface.c b/src/libnm-core-impl/nm-setting-ovs-interface.c index 58a01fcc..6554f520 100644 --- a/src/libnm-core-impl/nm-setting-ovs-interface.c +++ b/src/libnm-core-impl/nm-setting-ovs-interface.c @@ -62,12 +62,12 @@ nm_setting_ovs_interface_get_interface_type(NMSettingOvsInterface *self) int _nm_setting_ovs_interface_verify_interface_type(NMSettingOvsInterface *self, - const char * type, - NMConnection * connection, + const char *type, + NMConnection *connection, gboolean normalize, - gboolean * out_modified, - const char ** out_normalized_type, - GError ** error) + gboolean *out_modified, + const char **out_normalized_type, + GError **error) { const char *type_from_setting = NULL; const char *type_setting = NULL; @@ -276,7 +276,7 @@ static int verify(NMSetting *setting, NMConnection *connection, GError **error) { NMSettingOvsInterface *self = NM_SETTING_OVS_INTERFACE(setting); - NMSettingConnection * s_con = NULL; + NMSettingConnection *s_con = NULL; if (connection) { const char *slave_type; @@ -334,39 +334,6 @@ verify(NMSetting *setting, NMConnection *connection, GError **error) /*****************************************************************************/ static void -get_property(GObject *object, guint prop_id, GValue *value, GParamSpec *pspec) -{ - NMSettingOvsInterface *self = NM_SETTING_OVS_INTERFACE(object); - - switch (prop_id) { - case PROP_TYPE: - g_value_set_string(value, self->type); - break; - default: - G_OBJECT_WARN_INVALID_PROPERTY_ID(object, prop_id, pspec); - break; - } -} - -static void -set_property(GObject *object, guint prop_id, const GValue *value, GParamSpec *pspec) -{ - NMSettingOvsInterface *self = NM_SETTING_OVS_INTERFACE(object); - - switch (prop_id) { - case PROP_TYPE: - g_free(self->type); - self->type = g_value_dup_string(value); - break; - default: - G_OBJECT_WARN_INVALID_PROPERTY_ID(object, prop_id, pspec); - break; - } -} - -/*****************************************************************************/ - -static void nm_setting_ovs_interface_init(NMSettingOvsInterface *self) {} @@ -386,24 +353,14 @@ nm_setting_ovs_interface_new(void) } static void -finalize(GObject *object) -{ - NMSettingOvsInterface *self = NM_SETTING_OVS_INTERFACE(object); - - g_free(self->type); - - G_OBJECT_CLASS(nm_setting_ovs_interface_parent_class)->finalize(object); -} - -static void nm_setting_ovs_interface_class_init(NMSettingOvsInterfaceClass *klass) { - GObjectClass * object_class = G_OBJECT_CLASS(klass); - NMSettingClass *setting_class = NM_SETTING_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(); - object_class->get_property = get_property; - object_class->set_property = set_property; - object_class->finalize = finalize; + object_class->get_property = _nm_setting_property_get_property_direct; + object_class->set_property = _nm_setting_property_set_property_direct; setting_class->verify = verify; @@ -414,14 +371,19 @@ nm_setting_ovs_interface_class_init(NMSettingOvsInterfaceClass *klass) * * Since: 1.10 **/ - obj_properties[PROP_TYPE] = g_param_spec_string(NM_SETTING_OVS_INTERFACE_TYPE, - "", - "", - NULL, - G_PARAM_READWRITE | NM_SETTING_PARAM_INFERRABLE - | G_PARAM_STATIC_STRINGS); + _nm_setting_property_define_direct_string(properties_override, + obj_properties, + NM_SETTING_OVS_INTERFACE_TYPE, + PROP_TYPE, + NM_SETTING_PARAM_INFERRABLE, + NMSettingOvsInterface, + type); g_object_class_install_properties(object_class, _PROPERTY_ENUMS_LAST, obj_properties); - _nm_setting_class_commit(setting_class, NM_META_SETTING_TYPE_OVS_INTERFACE, NULL, NULL, 0); + _nm_setting_class_commit(setting_class, + NM_META_SETTING_TYPE_OVS_INTERFACE, + NULL, + properties_override, + 0); } diff --git a/src/libnm-core-impl/nm-setting-ovs-patch.c b/src/libnm-core-impl/nm-setting-ovs-patch.c index 578f5ee2..2781d435 100644 --- a/src/libnm-core-impl/nm-setting-ovs-patch.c +++ b/src/libnm-core-impl/nm-setting-ovs-patch.c @@ -94,39 +94,6 @@ verify(NMSetting *setting, NMConnection *connection, GError **error) /*****************************************************************************/ static void -get_property(GObject *object, guint prop_id, GValue *value, GParamSpec *pspec) -{ - NMSettingOvsPatch *self = NM_SETTING_OVS_PATCH(object); - - switch (prop_id) { - case PROP_PEER: - g_value_set_string(value, self->peer); - break; - default: - G_OBJECT_WARN_INVALID_PROPERTY_ID(object, prop_id, pspec); - break; - } -} - -static void -set_property(GObject *object, guint prop_id, const GValue *value, GParamSpec *pspec) -{ - NMSettingOvsPatch *self = NM_SETTING_OVS_PATCH(object); - - switch (prop_id) { - case PROP_PEER: - g_free(self->peer); - self->peer = g_value_dup_string(value); - break; - default: - G_OBJECT_WARN_INVALID_PROPERTY_ID(object, prop_id, pspec); - break; - } -} - -/*****************************************************************************/ - -static void nm_setting_ovs_patch_init(NMSettingOvsPatch *self) {} @@ -146,24 +113,14 @@ nm_setting_ovs_patch_new(void) } static void -finalize(GObject *object) -{ - NMSettingOvsPatch *self = NM_SETTING_OVS_PATCH(object); - - g_free(self->peer); - - G_OBJECT_CLASS(nm_setting_ovs_patch_parent_class)->finalize(object); -} - -static void nm_setting_ovs_patch_class_init(NMSettingOvsPatchClass *klass) { - GObjectClass * object_class = G_OBJECT_CLASS(klass); - NMSettingClass *setting_class = NM_SETTING_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(); - object_class->set_property = set_property; - object_class->get_property = get_property; - object_class->finalize = finalize; + object_class->get_property = _nm_setting_property_get_property_direct; + object_class->set_property = _nm_setting_property_set_property_direct; setting_class->verify = verify; @@ -175,14 +132,19 @@ nm_setting_ovs_patch_class_init(NMSettingOvsPatchClass *klass) * * Since: 1.10 **/ - obj_properties[PROP_PEER] = g_param_spec_string(NM_SETTING_OVS_PATCH_PEER, - "", - "", - NULL, - G_PARAM_READWRITE | NM_SETTING_PARAM_INFERRABLE - | G_PARAM_STATIC_STRINGS); + _nm_setting_property_define_direct_string(properties_override, + obj_properties, + NM_SETTING_OVS_PATCH_PEER, + PROP_PEER, + NM_SETTING_PARAM_INFERRABLE, + NMSettingOvsPatch, + peer); g_object_class_install_properties(object_class, _PROPERTY_ENUMS_LAST, obj_properties); - _nm_setting_class_commit(setting_class, NM_META_SETTING_TYPE_OVS_PATCH, NULL, NULL, 0); + _nm_setting_class_commit(setting_class, + NM_META_SETTING_TYPE_OVS_PATCH, + NULL, + properties_override, + 0); } diff --git a/src/libnm-core-impl/nm-setting-ovs-port.c b/src/libnm-core-impl/nm-setting-ovs-port.c index fc593268..ab9c0a11 100644 --- a/src/libnm-core-impl/nm-setting-ovs-port.c +++ b/src/libnm-core-impl/nm-setting-ovs-port.c @@ -36,9 +36,9 @@ NM_GOBJECT_PROPERTIES_DEFINE_BASE(PROP_VLAN_MODE, struct _NMSettingOvsPort { NMSetting parent; - char * vlan_mode; - char * lacp; - char * bond_mode; + char *vlan_mode; + char *lacp; + char *bond_mode; guint32 tag; guint32 bond_updelay; guint32 bond_downdelay; @@ -160,7 +160,7 @@ verify(NMSetting *setting, NMConnection *connection, GError **error) if (connection) { NMSettingConnection *s_con; - const char * slave_type; + const char *slave_type; s_con = nm_connection_get_setting_connection(connection); if (!s_con) { @@ -284,9 +284,9 @@ nm_setting_ovs_port_new(void) static void nm_setting_ovs_port_class_init(NMSettingOvsPortClass *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(); object_class->get_property = _nm_setting_property_get_property_direct; object_class->set_property = _nm_setting_property_set_property_direct; diff --git a/src/libnm-core-impl/nm-setting-ppp.c b/src/libnm-core-impl/nm-setting-ppp.c index e4e4951e..a9d2b9a2 100644 --- a/src/libnm-core-impl/nm-setting-ppp.c +++ b/src/libnm-core-impl/nm-setting-ppp.c @@ -398,9 +398,9 @@ nm_setting_ppp_new(void) static void nm_setting_ppp_class_init(NMSettingPppClass *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(NMSettingPppPrivate)); diff --git a/src/libnm-core-impl/nm-setting-pppoe.c b/src/libnm-core-impl/nm-setting-pppoe.c index 3ae547a2..c4a9a89c 100644 --- a/src/libnm-core-impl/nm-setting-pppoe.c +++ b/src/libnm-core-impl/nm-setting-pppoe.c @@ -135,8 +135,8 @@ nm_setting_pppoe_get_password_flags(NMSettingPppoe *setting) static gboolean verify(NMSetting *setting, NMConnection *connection, GError **error) { - NMSettingPppoePrivate *priv = NM_SETTING_PPPOE_GET_PRIVATE(setting); - gs_free_error GError *local_error = NULL; + NMSettingPppoePrivate *priv = NM_SETTING_PPPOE_GET_PRIVATE(setting); + gs_free_error GError *local_error = NULL; if (nm_str_is_empty(priv->username)) { if (!priv->username) { @@ -181,7 +181,7 @@ static GPtrArray * need_secrets(NMSetting *setting) { NMSettingPppoePrivate *priv = NM_SETTING_PPPOE_GET_PRIVATE(setting); - GPtrArray * secrets = NULL; + GPtrArray *secrets = NULL; if (priv->password) return NULL; @@ -216,9 +216,9 @@ nm_setting_pppoe_new(void) static void nm_setting_pppoe_class_init(NMSettingPppoeClass *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(NMSettingPppoePrivate)); diff --git a/src/libnm-core-impl/nm-setting-private.h b/src/libnm-core-impl/nm-setting-private.h index 7faf5d1c..7483eaed 100644 --- a/src/libnm-core-impl/nm-setting-private.h +++ b/src/libnm-core-impl/nm-setting-private.h @@ -59,49 +59,49 @@ struct _NMSettingClass { int (*update_one_secret)(NMSetting *setting, const char *key, GVariant *value, GError **error); - gboolean (*get_secret_flags)(NMSetting * setting, - const char * secret_name, + gboolean (*get_secret_flags)(NMSetting *setting, + const char *secret_name, NMSettingSecretFlags *out_flags, - GError ** error); + GError **error); - gboolean (*set_secret_flags)(NMSetting * setting, - const char * secret_name, + gboolean (*set_secret_flags)(NMSetting *setting, + const char *secret_name, NMSettingSecretFlags flags, - GError ** error); + GError **error); gboolean (*clear_secrets)(const struct _NMSettInfoSetting *sett_info, - const NMSettInfoProperty * property_info, - NMSetting * setting, + const NMSettInfoProperty *property_info, + NMSetting *setting, NMSettingClearSecretsWithFlagsFn func, gpointer user_data); void (*padding_1)(void); void (*duplicate_copy_properties)(const struct _NMSettInfoSetting *sett_info, - NMSetting * src, - NMSetting * dst); + NMSetting *src, + NMSetting *dst); void (*enumerate_values)(const struct _NMSettInfoProperty *property_info, - NMSetting * setting, + NMSetting *setting, NMSettingValueIterFn func, gpointer user_data); gboolean (*aggregate)(NMSetting *setting, int type_i, gpointer arg); - void (*for_each_secret)(NMSetting * setting, - const char * secret_name, - GVariant * val, + void (*for_each_secret)(NMSetting *setting, + const char *secret_name, + GVariant *val, gboolean remove_non_secrets, _NMConnectionForEachSecretFunc callback, gpointer callback_data, - GVariantBuilder * setting_builder); + GVariantBuilder *setting_builder); - gboolean (*init_from_dbus)(NMSetting * setting, - GHashTable * keys, - GVariant * setting_dict, - GVariant * connection_dict, + gboolean (*init_from_dbus)(NMSetting *setting, + GHashTable *keys, + GVariant *setting_dict, + GVariant *connection_dict, guint /* NMSettingParseFlags */ parse_flags, - GError ** error); + GError **error); const struct _NMMetaSettingInfo *setting_info; }; @@ -134,18 +134,18 @@ typedef struct { GPtrArray *addresses; /* array of NMIPAddress */ GPtrArray *routes; /* array of NMIPRoute */ GPtrArray *routing_rules; - GArray * dhcp_reject_servers; - char * method; - char * gateway; - char * dhcp_hostname; - char * dhcp_iaid; + GArray *dhcp_reject_servers; + char *method; + char *gateway; + char *dhcp_hostname; + char *dhcp_iaid; gint64 route_metric; - guint dhcp_hostname_flags; - int dns_priority; - int dad_timeout; - int dhcp_timeout; - int required_timeout; + gint32 required_timeout; + gint32 dad_timeout; + gint32 dhcp_timeout; + gint32 dns_priority; guint32 route_table; + guint32 dhcp_hostname_flags; bool ignore_auto_routes; bool ignore_auto_dns; bool dhcp_send_hostname; @@ -226,7 +226,7 @@ typedef enum NMSettingUpdateSecretResult { NMSettingUpdateSecretResult _nm_setting_update_secrets(NMSetting *setting, GVariant *secrets, GError **error); -gboolean _nm_setting_clear_secrets(NMSetting * setting, +gboolean _nm_setting_clear_secrets(NMSetting *setting, NMSettingClearSecretsWithFlagsFn func, gpointer user_data); @@ -236,7 +236,7 @@ gboolean _nm_setting_clear_secrets(NMSetting * setting, /* The property of the #NMSetting should be considered during comparisons that * use the %NM_SETTING_COMPARE_FLAG_INFERRABLE flag. Properties that don't have - * this flag, are ignored when doing an infrerrable comparison. This flag should + * this flag, are ignored when doing an inferrable comparison. This flag should * be set on all properties that are read from the kernel or the system when a * connection is generated. eg, IP addresses/routes can be read from the * kernel, but the 'autoconnect' property cannot, so @@ -270,12 +270,10 @@ extern const NMSettInfoPropertType nm_sett_info_propert_type_deprecated_interfac 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_plain_i; -extern const NMSettInfoPropertType nm_sett_info_propert_type_plain_u; - extern const NMSettInfoPropertType nm_sett_info_propert_type_direct_boolean; extern const NMSettInfoPropertType nm_sett_info_propert_type_direct_int32; extern const NMSettInfoPropertType nm_sett_info_propert_type_direct_uint32; +extern const NMSettInfoPropertType nm_sett_info_propert_type_direct_int64; extern const NMSettInfoPropertType nm_sett_info_propert_type_direct_uint64; extern const NMSettInfoPropertType nm_sett_info_propert_type_direct_string; extern const NMSettInfoPropertType nm_sett_info_propert_type_direct_bytes; @@ -289,16 +287,16 @@ _nm_setting_verify(NMSetting *setting, NMConnection *connection, GError **error) gboolean _nm_setting_verify_secret_string(const char *str, const char *setting_name, const char *property, - GError ** error); + GError **error); gboolean _nm_setting_aggregate(NMSetting *setting, NMConnectionAggregateType type, gpointer arg); gboolean _nm_setting_slave_type_is_valid(const char *slave_type, const char **out_port_type); -gboolean _nm_setting_compare_flags_check(const GParamSpec * param_spec, +gboolean _nm_setting_compare_flags_check(const GParamSpec *param_spec, NMSettingCompareFlags flags, - NMSetting * set_a, - NMSetting * set_b); + NMSetting *set_a, + NMSetting *set_b); NMTernary _nm_setting_property_compare_fcn_ignore(_NM_SETT_INFO_PROP_COMPARE_FCN_ARGS _nm_nil); @@ -306,15 +304,15 @@ NMTernary _nm_setting_property_compare_fcn_direct(_NM_SETT_INFO_PROP_COMPARE_FCN NMTernary _nm_setting_property_compare_fcn_default(_NM_SETT_INFO_PROP_COMPARE_FCN_ARGS _nm_nil); -void _nm_setting_property_get_property_direct(GObject * object, +void _nm_setting_property_get_property_direct(GObject *object, guint prop_id, - GValue * value, + GValue *value, GParamSpec *pspec); -void _nm_setting_property_set_property_direct(GObject * object, +void _nm_setting_property_set_property_direct(GObject *object, guint prop_id, const GValue *value, - GParamSpec * pspec); + GParamSpec *pspec); GVariant *_nm_setting_property_to_dbus_fcn_ignore(_NM_SETT_INFO_PROP_TO_DBUS_FCN_ARGS _nm_nil); @@ -337,26 +335,26 @@ gboolean _nm_setting_property_from_dbus_fcn_direct(_NM_SETT_INFO_PROP_FROM_DBUS_ gboolean _nm_setting_property_from_dbus_fcn_gprop(_NM_SETT_INFO_PROP_FROM_DBUS_FCN_ARGS _nm_nil); -GVariant *_nm_setting_to_dbus(NMSetting * setting, - NMConnection * connection, +GVariant *_nm_setting_to_dbus(NMSetting *setting, + NMConnection *connection, NMConnectionSerializationFlags flags, const NMConnectionSerializationOptions *options); NMSetting *_nm_setting_new_from_dbus(GType setting_type, - GVariant * setting_dict, - GVariant * connection_dict, + GVariant *setting_dict, + GVariant *connection_dict, NMSettingParseFlags parse_flags, - GError ** error); + GError **error); gboolean _nm_setting_property_is_regular_secret(NMSetting *setting, const char *secret_name); -gboolean _nm_setting_property_is_regular_secret_flags(NMSetting * setting, +gboolean _nm_setting_property_is_regular_secret_flags(NMSetting *setting, const char *secret_flags_name); /*****************************************************************************/ const NMSettInfoProperty * _nm_sett_info_property_lookup_by_param_spec(const NMSettInfoSetting *sett_info, - const GParamSpec * param_spec); + const GParamSpec *param_spec); static inline GArray * _nm_sett_info_property_override_create_array_sized(guint reserved_size) @@ -375,10 +373,10 @@ _nm_sett_info_property_override_create_array(void) GArray *_nm_sett_info_property_override_create_array_ip_config(int addr_family); -void _nm_setting_class_commit(NMSettingClass * setting_class, +void _nm_setting_class_commit(NMSettingClass *setting_class, NMMetaSettingType meta_type, const NMSettInfoSettDetail *detail, - GArray * properties_override, + GArray *properties_override, gint16 private_offset); #define NM_SETT_INFO_SETT_GENDATA(...) \ @@ -464,7 +462,7 @@ _nm_properties_override(GArray *properties_override, const NMSettInfoProperty *p G_STMT_START \ { \ const gboolean _default_value = (default_value); \ - GParamSpec * _param_spec; \ + GParamSpec *_param_spec; \ \ G_STATIC_ASSERT( \ !NM_FLAGS_ANY((param_flags), \ @@ -585,6 +583,52 @@ _nm_properties_override(GArray *properties_override, const NMSettInfoProperty *p /*****************************************************************************/ +#define _nm_setting_property_define_direct_int64(properties_override, \ + obj_properties, \ + prop_name, \ + prop_id, \ + min_value, \ + max_value, \ + default_value, \ + param_flags, \ + private_struct_type, \ + private_struct_field, \ + ... /* extra NMSettInfoProperty fields */) \ + G_STMT_START \ + { \ + GParamSpec *_param_spec; \ + \ + G_STATIC_ASSERT( \ + !NM_FLAGS_ANY((param_flags), \ + ~(NM_SETTING_PARAM_FUZZY_IGNORE | NM_SETTING_PARAM_INFERRABLE))); \ + G_STATIC_ASSERT((min_value) >= G_MININT64); \ + G_STATIC_ASSERT((min_value) <= (default_value)); \ + G_STATIC_ASSERT((default_value) <= (max_value)); \ + G_STATIC_ASSERT((max_value) <= G_MAXINT64); \ + \ + _param_spec = \ + g_param_spec_int64("" prop_name "", \ + "", \ + "", \ + (min_value), \ + (max_value), \ + (default_value), \ + 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_direct_int64, \ + .direct_offset = \ + NM_STRUCT_OFFSET_ENSURE_TYPE(gint64, private_struct_type, private_struct_field), \ + __VA_ARGS__); \ + } \ + G_STMT_END + +/*****************************************************************************/ + #define _nm_setting_property_define_direct_uint64(properties_override, \ obj_properties, \ prop_name, \ @@ -641,12 +685,12 @@ _nm_properties_override(GArray *properties_override, const NMSettInfoProperty *p ... /* extra NMSettInfoProperty fields */) \ G_STMT_START \ { \ - GParamSpec * _param_spec; \ + GParamSpec *_param_spec; \ const NMSettInfoPropertType *_property_type = (property_type); \ \ G_STATIC_ASSERT(!NM_FLAGS_ANY((param_flags), \ ~(NM_SETTING_PARAM_SECRET | NM_SETTING_PARAM_FUZZY_IGNORE \ - | NM_SETTING_PARAM_INFERRABLE \ + | NM_SETTING_PARAM_INFERRABLE | NM_SETTING_PARAM_REQUIRED \ | NM_SETTING_PARAM_REAPPLY_IMMEDIATELY))); \ \ nm_assert(_property_type); \ @@ -890,16 +934,16 @@ _nm_properties_override(GArray *properties_override, const NMSettInfoProperty *p /*****************************************************************************/ -gboolean _nm_setting_use_legacy_property(NMSetting * setting, - GVariant * connection_dict, +gboolean _nm_setting_use_legacy_property(NMSetting *setting, + GVariant *connection_dict, const char *legacy_property, const char *new_property); GPtrArray *_nm_setting_need_secrets(NMSetting *setting); -gboolean _nm_setting_should_compare_secret_property(NMSetting * setting, - NMSetting * other, - const char * secret_name, +gboolean _nm_setting_should_compare_secret_property(NMSetting *setting, + NMSetting *other, + const char *secret_name, NMSettingCompareFlags flags); NMBridgeVlan *_nm_bridge_vlan_dup(const NMBridgeVlan *vlan); diff --git a/src/libnm-core-impl/nm-setting-proxy.c b/src/libnm-core-impl/nm-setting-proxy.c index 0425ec45..4b9a2970 100644 --- a/src/libnm-core-impl/nm-setting-proxy.c +++ b/src/libnm-core-impl/nm-setting-proxy.c @@ -29,8 +29,8 @@ NM_GOBJECT_PROPERTIES_DEFINE_BASE(PROP_METHOD, PROP_BROWSER_ONLY, PROP_PAC_URL, PROP_PAC_SCRIPT, ); typedef struct { - char * pac_url; - char * pac_script; + char *pac_url; + char *pac_script; gint32 method; bool browser_only; } NMSettingProxyPrivate; @@ -229,9 +229,9 @@ nm_setting_proxy_new(void) static void nm_setting_proxy_class_init(NMSettingProxyClass *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(NMSettingProxyPrivate)); diff --git a/src/libnm-core-impl/nm-setting-serial.c b/src/libnm-core-impl/nm-setting-serial.c index 3ebcf062..a8201876 100644 --- a/src/libnm-core-impl/nm-setting-serial.c +++ b/src/libnm-core-impl/nm-setting-serial.c @@ -222,9 +222,9 @@ nm_setting_serial_new(void) static void nm_setting_serial_class_init(NMSettingSerialClass *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(NMSettingSerialPrivate)); diff --git a/src/libnm-core-impl/nm-setting-sriov.c b/src/libnm-core-impl/nm-setting-sriov.c index a024dba6..30dd8f54 100644 --- a/src/libnm-core-impl/nm-setting-sriov.c +++ b/src/libnm-core-impl/nm-setting-sriov.c @@ -30,8 +30,8 @@ NM_GOBJECT_PROPERTIES_DEFINE(NMSettingSriov, PROP_TOTAL_VFS, PROP_VFS, PROP_AUTO struct _NMSettingSriov { NMSetting parent; GPtrArray *vfs; - guint total_vfs; - NMTernary autoprobe_drivers; + int autoprobe_drivers; + guint32 total_vfs; }; struct _NMSettingSriovClass { @@ -49,7 +49,7 @@ struct _NMSriovVF { guint index; GHashTable *attributes; GHashTable *vlans; - guint * vlan_ids; + guint *vlan_ids; }; typedef struct { @@ -163,9 +163,9 @@ gboolean nm_sriov_vf_equal(const NMSriovVF *vf, const NMSriovVF *other) { GHashTableIter iter; - const char * key; - GVariant * value, *value2; - VFVlan * vlan, *vlan2; + const char *key; + GVariant *value, *value2; + VFVlan *vlan, *vlan2; guint n_vlans; g_return_val_if_fail(vf, FALSE); @@ -239,11 +239,11 @@ vf_add_vlan(NMSriovVF *vf, guint vlan_id, guint qos, NMSriovVFVlanProtocol proto NMSriovVF * nm_sriov_vf_dup(const NMSriovVF *vf) { - NMSriovVF * copy; + NMSriovVF *copy; GHashTableIter iter; - const char * name; - GVariant * variant; - VFVlan * vlan; + const char *name; + GVariant *variant; + VFVlan *vlan; g_return_val_if_fail(vf, NULL); g_return_val_if_fail(vf->refcount > 0, NULL); @@ -350,13 +350,13 @@ nm_sriov_vf_get_attribute(const NMSriovVF *vf, const char *name) const NMVariantAttributeSpec *const _nm_sriov_vf_attribute_spec[] = { NM_VARIANT_ATTRIBUTE_SPEC_DEFINE(NM_SRIOV_VF_ATTRIBUTE_MAC, G_VARIANT_TYPE_STRING, - .str_type = 'm', ), + .type_detail = 'm', ), NM_VARIANT_ATTRIBUTE_SPEC_DEFINE(NM_SRIOV_VF_ATTRIBUTE_SPOOF_CHECK, G_VARIANT_TYPE_BOOLEAN, ), NM_VARIANT_ATTRIBUTE_SPEC_DEFINE(NM_SRIOV_VF_ATTRIBUTE_TRUST, G_VARIANT_TYPE_BOOLEAN, ), NM_VARIANT_ATTRIBUTE_SPEC_DEFINE(NM_SRIOV_VF_ATTRIBUTE_MIN_TX_RATE, G_VARIANT_TYPE_UINT32, ), NM_VARIANT_ATTRIBUTE_SPEC_DEFINE(NM_SRIOV_VF_ATTRIBUTE_MAX_TX_RATE, G_VARIANT_TYPE_UINT32, ), /* D-Bus only, synthetic attributes */ - NM_VARIANT_ATTRIBUTE_SPEC_DEFINE("vlans", G_VARIANT_TYPE_STRING, .str_type = 'd', ), + NM_VARIANT_ATTRIBUTE_SPEC_DEFINE("vlans", G_VARIANT_TYPE_STRING, .type_detail = 'd', ), NULL, }; @@ -378,7 +378,8 @@ gboolean nm_sriov_vf_attribute_validate(const char *name, GVariant *value, gboolean *known, GError **error) { const NMVariantAttributeSpec *const *iter; - const NMVariantAttributeSpec * spec = NULL; + const NMVariantAttributeSpec *spec = NULL; + const char *string; g_return_val_if_fail(name, FALSE); g_return_val_if_fail(value, FALSE); @@ -391,7 +392,7 @@ nm_sriov_vf_attribute_validate(const char *name, GVariant *value, gboolean *know } } - if (!spec || spec->str_type == 'd') { + if (!spec || spec->type_detail == 'd') { NM_SET_OUT(known, FALSE); g_set_error_literal(error, NM_CONNECTION_ERROR, @@ -411,24 +412,23 @@ nm_sriov_vf_attribute_validate(const char *name, GVariant *value, gboolean *know return FALSE; } - if (g_variant_type_equal(spec->type, G_VARIANT_TYPE_STRING)) { - const char *string; - - switch (spec->str_type) { - case 'm': /* MAC address */ - string = g_variant_get_string(value, NULL); - if (!nm_utils_hwaddr_valid(string, -1)) { - g_set_error(error, - NM_CONNECTION_ERROR, - NM_CONNECTION_ERROR_FAILED, - _("'%s' is not a valid MAC address"), - string); - return FALSE; - } - break; - default: - break; + switch (spec->type_detail) { + case 'm': /* MAC address */ + string = g_variant_get_string(value, NULL); + if (!nm_utils_hwaddr_valid(string, -1)) { + g_set_error(error, + NM_CONNECTION_ERROR, + NM_CONNECTION_ERROR_FAILED, + _("'%s' is not a valid MAC address"), + string); + return FALSE; } + break; + case '\0': + break; + default: + nm_assert_not_reached(); + break; } return TRUE; @@ -438,9 +438,9 @@ gboolean _nm_sriov_vf_attribute_validate_all(const NMSriovVF *vf, GError **error) { GHashTableIter iter; - const char * name; - GVariant * variant; - GVariant * min, *max; + const char *name; + GVariant *variant; + GVariant *min, *max; g_return_val_if_fail(vf, FALSE); g_return_val_if_fail(vf->refcount > 0, FALSE); @@ -546,7 +546,7 @@ const guint * nm_sriov_vf_get_vlan_ids(const NMSriovVF *vf, guint *length) { GHashTableIter iter; - VFVlan * vlan; + VFVlan *vlan; guint num, i; g_return_val_if_fail(vf, NULL); @@ -888,10 +888,10 @@ vfs_to_dbus(_NM_SETT_INFO_PROP_TO_DBUS_FCN_ARGS _nm_nil) if (vfs) { for (i = 0; i < vfs->len; i++) { gs_free const char **attr_names = NULL; - NMSriovVF * vf = vfs->pdata[i]; + NMSriovVF *vf = vfs->pdata[i]; GVariantBuilder vf_builder; - const guint * vlan_ids; - const char ** name; + const guint *vlan_ids; + const char **name; guint num_vlans = 0; g_variant_builder_init(&vf_builder, G_VARIANT_TYPE_VARDICT); @@ -954,20 +954,20 @@ vfs_to_dbus(_NM_SETT_INFO_PROP_TO_DBUS_FCN_ARGS _nm_nil) static gboolean vfs_from_dbus(_NM_SETT_INFO_PROP_FROM_DBUS_FCN_ARGS _nm_nil) { - GPtrArray * vfs; + GPtrArray *vfs; GVariantIter vf_iter; - GVariant * vf_var; + GVariant *vf_var; g_return_val_if_fail(g_variant_is_of_type(value, G_VARIANT_TYPE("aa{sv}")), FALSE); vfs = g_ptr_array_new_with_free_func((GDestroyNotify) nm_sriov_vf_unref); g_variant_iter_init(&vf_iter, value); while (g_variant_iter_next(&vf_iter, "@a{sv}", &vf_var)) { - NMSriovVF * vf; + NMSriovVF *vf; guint32 index; GVariantIter attr_iter; - const char * attr_name; - GVariant * attr_var, *vlans_var; + const char *attr_name; + GVariant *attr_var, *vlans_var; if (!g_variant_lookup(vf_var, "index", "u", &index)) goto next; @@ -983,7 +983,7 @@ vfs_from_dbus(_NM_SETT_INFO_PROP_FROM_DBUS_FCN_ARGS _nm_nil) if (g_variant_lookup(vf_var, "vlans", "@aa{sv}", &vlans_var)) { GVariantIter vlan_iter; - GVariant * vlan_var; + GVariant *vlan_var; g_variant_iter_init(&vlan_iter, vlans_var); while (g_variant_iter_next(&vlan_iter, "@a{sv}", &vlan_var)) { @@ -1035,7 +1035,7 @@ verify(NMSetting *setting, NMConnection *connection, GError **error) h = g_hash_table_new(nm_direct_hash, NULL); for (i = 0; i < self->vfs->len; i++) { - NMSriovVF * vf = self->vfs->pdata[i]; + NMSriovVF *vf = self->vfs->pdata[i]; gs_free_error GError *local = NULL; if (vf->index >= self->total_vfs) { @@ -1138,20 +1138,14 @@ get_property(GObject *object, guint prop_id, GValue *value, GParamSpec *pspec) NMSettingSriov *self = NM_SETTING_SRIOV(object); switch (prop_id) { - case PROP_TOTAL_VFS: - g_value_set_uint(value, self->total_vfs); - break; case PROP_VFS: g_value_take_boxed(value, _nm_utils_copy_array(self->vfs, (NMUtilsCopyFunc) nm_sriov_vf_dup, (GDestroyNotify) nm_sriov_vf_unref)); break; - case PROP_AUTOPROBE_DRIVERS: - g_value_set_enum(value, self->autoprobe_drivers); - break; default: - G_OBJECT_WARN_INVALID_PROPERTY_ID(object, prop_id, pspec); + _nm_setting_property_get_property_direct(object, prop_id, value, pspec); break; } } @@ -1162,20 +1156,14 @@ set_property(GObject *object, guint prop_id, const GValue *value, GParamSpec *ps NMSettingSriov *self = NM_SETTING_SRIOV(object); switch (prop_id) { - case PROP_TOTAL_VFS: - self->total_vfs = g_value_get_uint(value); - break; case PROP_VFS: g_ptr_array_unref(self->vfs); self->vfs = _nm_utils_copy_array(g_value_get_boxed(value), (NMUtilsCopyFunc) nm_sriov_vf_dup, (GDestroyNotify) nm_sriov_vf_unref); break; - case PROP_AUTOPROBE_DRIVERS: - self->autoprobe_drivers = g_value_get_enum(value); - break; default: - G_OBJECT_WARN_INVALID_PROPERTY_ID(object, prop_id, pspec); + _nm_setting_property_set_property_direct(object, prop_id, value, pspec); break; } } @@ -1186,8 +1174,6 @@ static void nm_setting_sriov_init(NMSettingSriov *setting) { setting->vfs = g_ptr_array_new_with_free_func((GDestroyNotify) nm_sriov_vf_unref); - - setting->autoprobe_drivers = NM_TERNARY_DEFAULT; } /** @@ -1218,9 +1204,9 @@ finalize(GObject *object) static void nm_setting_sriov_class_init(NMSettingSriovClass *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(); object_class->get_property = get_property; object_class->set_property = set_property; @@ -1248,14 +1234,16 @@ nm_setting_sriov_class_init(NMSettingSriovClass *klass) * example: SRIOV_TOTAL_VFS=16 * ---end--- */ - obj_properties[PROP_TOTAL_VFS] = g_param_spec_uint( - NM_SETTING_SRIOV_TOTAL_VFS, - "", - "", - 0, - G_MAXUINT32, - 0, - NM_SETTING_PARAM_FUZZY_IGNORE | G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS); + _nm_setting_property_define_direct_uint32(properties_override, + obj_properties, + NM_SETTING_SRIOV_TOTAL_VFS, + PROP_TOTAL_VFS, + 0, + G_MAXUINT32, + 0, + NM_SETTING_PARAM_FUZZY_IGNORE, + NMSettingSriov, + total_vfs); /** * NMSettingSriov:vfs: (type GPtrArray(NMSriovVF)) @@ -1335,13 +1323,13 @@ nm_setting_sriov_class_init(NMSettingSriovClass *klass) * example: SRIOV_AUTOPROBE_DRIVERS=0,1 * ---end--- */ - obj_properties[PROP_AUTOPROBE_DRIVERS] = g_param_spec_enum( - NM_SETTING_SRIOV_AUTOPROBE_DRIVERS, - "", - "", - NM_TYPE_TERNARY, - NM_TERNARY_DEFAULT, - NM_SETTING_PARAM_FUZZY_IGNORE | G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS); + _nm_setting_property_define_direct_ternary_enum(properties_override, + obj_properties, + NM_SETTING_SRIOV_AUTOPROBE_DRIVERS, + PROP_AUTOPROBE_DRIVERS, + NM_SETTING_PARAM_FUZZY_IGNORE, + NMSettingSriov, + autoprobe_drivers); g_object_class_install_properties(object_class, _PROPERTY_ENUMS_LAST, obj_properties); diff --git a/src/libnm-core-impl/nm-setting-tc-config.c b/src/libnm-core-impl/nm-setting-tc-config.c index cd13709a..08a7f94d 100644 --- a/src/libnm-core-impl/nm-setting-tc-config.c +++ b/src/libnm-core-impl/nm-setting-tc-config.c @@ -24,7 +24,7 @@ G_DEFINE_BOXED_TYPE(NMTCQdisc, nm_tc_qdisc, nm_tc_qdisc_dup, nm_tc_qdisc_unref) struct NMTCQdisc { guint refcount; - char * kind; + char *kind; guint32 handle; guint32 parent; GHashTable *attributes; @@ -138,8 +138,8 @@ gboolean nm_tc_qdisc_equal(NMTCQdisc *qdisc, NMTCQdisc *other) { GHashTableIter iter; - const char * key; - GVariant * value, *value2; + const char *key; + GVariant *value, *value2; guint n; g_return_val_if_fail(qdisc != NULL, FALSE); @@ -172,9 +172,9 @@ nm_tc_qdisc_equal(NMTCQdisc *qdisc, NMTCQdisc *other) static guint _nm_tc_qdisc_hash(NMTCQdisc *qdisc) { - NMUtilsNamedValue attrs_static[30]; + NMUtilsNamedValue attrs_static[30]; gs_free NMUtilsNamedValue *attrs_free = NULL; - const NMUtilsNamedValue * attrs; + const NMUtilsNamedValue *attrs; NMHashState h; guint length; guint i; @@ -186,8 +186,8 @@ _nm_tc_qdisc_hash(NMTCQdisc *qdisc) nm_hash_update_vals(&h, qdisc->handle, qdisc->parent, length); nm_hash_update_str0(&h, qdisc->kind); for (i = 0; i < length; i++) { - const char * key = attrs[i].name; - GVariant * variant = attrs[i].value_ptr; + const char *key = attrs[i].name; + GVariant *variant = attrs[i].value_ptr; const GVariantType *vtype; vtype = g_variant_get_type(variant); @@ -224,8 +224,8 @@ nm_tc_qdisc_dup(NMTCQdisc *qdisc) if (qdisc->attributes) { GHashTableIter iter; - const char * key; - GVariant * value; + const char *key; + GVariant *value; g_hash_table_iter_init(&iter, qdisc->attributes); while (g_hash_table_iter_next(&iter, (gpointer *) &key, (gpointer *) &value)) @@ -495,8 +495,8 @@ gboolean nm_tc_action_equal(NMTCAction *action, NMTCAction *other) { GHashTableIter iter; - const char * key; - GVariant * value, *value2; + const char *key; + GVariant *value, *value2; guint n; g_return_val_if_fail(!action || action->refcount > 0, FALSE); @@ -549,8 +549,8 @@ nm_tc_action_dup(NMTCAction *action) if (action->attributes) { GHashTableIter iter; - const char * key; - GVariant * value; + const char *key; + GVariant *value; g_hash_table_iter_init(&iter, action->attributes); while (g_hash_table_iter_next(&iter, (gpointer *) &key, (gpointer *) &value)) @@ -667,7 +667,7 @@ G_DEFINE_BOXED_TYPE(NMTCTfilter, nm_tc_tfilter, nm_tc_tfilter_dup, nm_tc_tfilter struct NMTCTfilter { guint refcount; - char * kind; + char *kind; guint32 handle; guint32 parent; NMTCAction *action; @@ -806,7 +806,7 @@ _nm_tc_tfilter_hash(NMTCTfilter *tfilter) if (tfilter->action) { gs_free NMUtilsNamedValue *attrs_free = NULL; NMUtilsNamedValue attrs_static[30]; - const NMUtilsNamedValue * attrs; + const NMUtilsNamedValue *attrs; guint length; guint i; @@ -1370,10 +1370,10 @@ _qdiscs_to_variant(GPtrArray *qdiscs) if (qdiscs) { for (i = 0; i < qdiscs->len; i++) { - NMUtilsNamedValue attrs_static[30]; + NMUtilsNamedValue attrs_static[30]; gs_free NMUtilsNamedValue *attrs_free = NULL; - const NMUtilsNamedValue * attrs; - NMTCQdisc * qdisc = qdiscs->pdata[i]; + const NMUtilsNamedValue *attrs; + NMTCQdisc *qdisc = qdiscs->pdata[i]; guint length; GVariantBuilder qdisc_builder; guint y; @@ -1423,10 +1423,10 @@ _qdiscs_to_variant(GPtrArray *qdiscs) static GPtrArray * _qdiscs_from_variant(GVariant *value) { - GPtrArray * qdiscs; - GVariant * qdisc_var; + GPtrArray *qdiscs; + GVariant *qdisc_var; GVariantIter iter; - GError * error = NULL; + GError *error = NULL; g_return_val_if_fail(g_variant_is_of_type(value, G_VARIANT_TYPE("aa{sv}")), NULL); @@ -1434,12 +1434,12 @@ _qdiscs_from_variant(GVariant *value) qdiscs = g_ptr_array_new_with_free_func((GDestroyNotify) nm_tc_qdisc_unref); while (g_variant_iter_next(&iter, "@a{sv}", &qdisc_var)) { - const char * kind; + const char *kind; guint32 parent; - NMTCQdisc * qdisc; + NMTCQdisc *qdisc; GVariantIter qdisc_iter; - const char * key; - GVariant * attr_value; + const char *key; + GVariant *attr_value; if (!g_variant_lookup(qdisc_var, "kind", "&s", &kind) || !g_variant_lookup(qdisc_var, "parent", "u", &parent)) { @@ -1537,8 +1537,8 @@ _tfilters_to_variant(GPtrArray *tfilters) if (tfilters) { for (i = 0; i < tfilters->len; i++) { - NMTCTfilter * tfilter = tfilters->pdata[i]; - NMTCAction * action = nm_tc_tfilter_get_action(tfilter); + NMTCTfilter *tfilter = tfilters->pdata[i]; + NMTCAction *action = nm_tc_tfilter_get_action(tfilter); GVariantBuilder tfilter_builder; g_variant_builder_init(&tfilter_builder, G_VARIANT_TYPE("a{sv}")); @@ -1583,10 +1583,10 @@ _tfilters_to_variant(GPtrArray *tfilters) static GPtrArray * _tfilters_from_variant(GVariant *value) { - GPtrArray * tfilters; - GVariant * tfilter_var; + GPtrArray *tfilters; + GVariant *tfilter_var; GVariantIter iter; - GError * error = NULL; + GError *error = NULL; g_return_val_if_fail(g_variant_is_of_type(value, G_VARIANT_TYPE("aa{sv}")), NULL); @@ -1595,15 +1595,15 @@ _tfilters_from_variant(GVariant *value) while (g_variant_iter_next(&iter, "@a{sv}", &tfilter_var)) { NMTCTfilter *tfilter = NULL; - const char * kind; + const char *kind; guint32 handle; guint32 parent; - NMTCAction * action; - const char * action_kind = NULL; - char * action_key; + NMTCAction *action; + const char *action_kind = NULL; + char *action_key; GVariantIter action_iter; - GVariant * action_var = NULL; - GVariant * action_val; + GVariant *action_var = NULL; + GVariant *action_val; if (!g_variant_lookup(tfilter_var, "kind", "&s", &kind) || !g_variant_lookup(tfilter_var, "parent", "u", &parent)) { @@ -1767,9 +1767,9 @@ finalize(GObject *object) static void nm_setting_tc_config_class_init(NMSettingTCConfigClass *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(); object_class->get_property = get_property; object_class->set_property = set_property; diff --git a/src/libnm-core-impl/nm-setting-team-port.c b/src/libnm-core-impl/nm-setting-team-port.c index 5e5f8910..816d85d9 100644 --- a/src/libnm-core-impl/nm-setting-team-port.c +++ b/src/libnm-core-impl/nm-setting-team-port.c @@ -313,7 +313,7 @@ verify(NMSetting *setting, NMConnection *connection, GError **error) if (connection) { NMSettingConnection *s_con; - const char * slave_type; + const char *slave_type; s_con = nm_connection_get_setting_connection(connection); if (!s_con) { @@ -400,12 +400,12 @@ duplicate_copy_properties(const NMSettInfoSetting *sett_info, NMSetting *src, NM } static gboolean -init_from_dbus(NMSetting * setting, - GHashTable * keys, - GVariant * setting_dict, - GVariant * connection_dict, +init_from_dbus(NMSetting *setting, + GHashTable *keys, + GVariant *setting_dict, + GVariant *connection_dict, guint /* NMSettingParseFlags */ parse_flags, - GError ** error) + GError **error) { guint32 changed = 0; gboolean success; @@ -426,7 +426,7 @@ init_from_dbus(NMSetting * setting, static void get_property(GObject *object, guint prop_id, GValue *value, GParamSpec *pspec) { - NMSettingTeamPort * setting = NM_SETTING_TEAM_PORT(object); + NMSettingTeamPort *setting = NM_SETTING_TEAM_PORT(object); NMSettingTeamPortPrivate *priv = NM_SETTING_TEAM_PORT_GET_PRIVATE(setting); switch (prop_id) { @@ -457,10 +457,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) { - NMSettingTeamPort * setting = NM_SETTING_TEAM_PORT(object); + NMSettingTeamPort *setting = NM_SETTING_TEAM_PORT(object); NMSettingTeamPortPrivate *priv = NM_SETTING_TEAM_PORT_GET_PRIVATE(setting); guint32 changed; - const GPtrArray * v_ptrarr; + const GPtrArray *v_ptrarr; switch (prop_id) { case NM_TEAM_ATTRIBUTE_CONFIG: @@ -528,9 +528,9 @@ finalize(GObject *object) static void nm_setting_team_port_class_init(NMSettingTeamPortClass *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(NMSettingTeamPortPrivate)); diff --git a/src/libnm-core-impl/nm-setting-team.c b/src/libnm-core-impl/nm-setting-team.c index 1a11b043..3eeeb2c3 100644 --- a/src/libnm-core-impl/nm-setting-team.c +++ b/src/libnm-core-impl/nm-setting-team.c @@ -60,8 +60,8 @@ struct NMTeamLinkWatcher { int missed_max; } nsna_ping; struct { - const char * target_host; - const char * source_host; + const char *target_host; + const char *source_host; int init_wait; int interval; int missed_max; @@ -106,7 +106,7 @@ NMTeamLinkWatcher * nm_team_link_watcher_new_ethtool(int delay_up, int delay_down, GError **error) { NMTeamLinkWatcher *watcher; - const char * val_fail = NULL; + const char *val_fail = NULL; if (delay_up < 0 || !_NM_INT_LE_MAXINT32(delay_up)) val_fail = "delay-up"; @@ -156,11 +156,11 @@ nm_team_link_watcher_new_nsna_ping(int init_wait, int interval, int missed_max, const char *target_host, - GError ** error) + GError **error) { NMTeamLinkWatcher *watcher; - const char * val_fail = NULL; - char * str; + const char *val_fail = NULL; + char *str; gsize l_target_host; if (!target_host) { @@ -235,10 +235,10 @@ NMTeamLinkWatcher * nm_team_link_watcher_new_arp_ping(int init_wait, int interval, int missed_max, - const char * target_host, - const char * source_host, + const char *target_host, + const char *source_host, NMTeamLinkWatcherArpPingFlags flags, - GError ** error) + GError **error) { return nm_team_link_watcher_new_arp_ping2(init_wait, interval, @@ -274,14 +274,14 @@ nm_team_link_watcher_new_arp_ping2(int init_wait, int interval, int missed_max, int vlanid, - const char * target_host, - const char * source_host, + const char *target_host, + const char *source_host, NMTeamLinkWatcherArpPingFlags flags, - GError ** error) + GError **error) { NMTeamLinkWatcher *watcher; - const char * val_fail = NULL; - char * str; + const char *val_fail = NULL; + char *str; gsize l_target_host; gsize l_source_host; @@ -1016,7 +1016,7 @@ gboolean nm_setting_team_remove_runner_tx_hash_by_value(NMSettingTeam *setting, const char *txhash) { NMSettingTeamPrivate *priv = NM_SETTING_TEAM_GET_PRIVATE(setting); - const GPtrArray * arr; + const GPtrArray *arr; guint i; g_return_val_if_fail(NM_IS_SETTING_TEAM(setting), FALSE); @@ -1228,7 +1228,7 @@ nm_setting_team_remove_link_watcher(NMSettingTeam *setting, guint idx) * Since: 1.12 **/ gboolean -nm_setting_team_remove_link_watcher_by_value(NMSettingTeam * setting, +nm_setting_team_remove_link_watcher_by_value(NMSettingTeam *setting, NMTeamLinkWatcher *link_watcher) { g_return_val_if_fail(NM_IS_SETTING_TEAM(setting), FALSE); @@ -1325,12 +1325,12 @@ duplicate_copy_properties(const NMSettInfoSetting *sett_info, NMSetting *src, NM } static gboolean -init_from_dbus(NMSetting * setting, - GHashTable * keys, - GVariant * setting_dict, - GVariant * connection_dict, +init_from_dbus(NMSetting *setting, + GHashTable *keys, + GVariant *setting_dict, + GVariant *connection_dict, guint /* NMSettingParseFlags */ parse_flags, - GError ** error) + GError **error) { guint32 changed = 0; gboolean success; @@ -1353,9 +1353,9 @@ init_from_dbus(NMSetting * setting, static void get_property(GObject *object, guint prop_id, GValue *value, GParamSpec *pspec) { - NMSettingTeam * setting = NM_SETTING_TEAM(object); + NMSettingTeam *setting = NM_SETTING_TEAM(object); NMSettingTeamPrivate *priv = NM_SETTING_TEAM_GET_PRIVATE(setting); - const GPtrArray * v_ptrarr; + const GPtrArray *v_ptrarr; switch (prop_id) { case NM_TEAM_ATTRIBUTE_CONFIG: @@ -1400,10 +1400,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) { - NMSettingTeam * setting = NM_SETTING_TEAM(object); + NMSettingTeam *setting = NM_SETTING_TEAM(object); NMSettingTeamPrivate *priv = NM_SETTING_TEAM_GET_PRIVATE(object); guint32 changed; - const GPtrArray * v_ptrarr; + const GPtrArray *v_ptrarr; switch (prop_id) { case NM_TEAM_ATTRIBUTE_CONFIG: @@ -1490,9 +1490,9 @@ finalize(GObject *object) static void nm_setting_team_class_init(NMSettingTeamClass *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(NMSettingTeamPrivate)); diff --git a/src/libnm-core-impl/nm-setting-tun.c b/src/libnm-core-impl/nm-setting-tun.c index c2694847..ec095155 100644 --- a/src/libnm-core-impl/nm-setting-tun.c +++ b/src/libnm-core-impl/nm-setting-tun.c @@ -32,8 +32,8 @@ NM_GOBJECT_PROPERTIES_DEFINE_BASE(PROP_MODE, PROP_MULTI_QUEUE, ); typedef struct { - char * owner; - char * group; + char *owner; + char *group; guint32 mode; bool pi; bool vnet_hdr; @@ -219,9 +219,9 @@ nm_setting_tun_new(void) static void nm_setting_tun_class_init(NMSettingTunClass *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(NMSettingTunPrivate)); diff --git a/src/libnm-core-impl/nm-setting-user.c b/src/libnm-core-impl/nm-setting-user.c index 4068f337..0e95d38b 100644 --- a/src/libnm-core-impl/nm-setting-user.c +++ b/src/libnm-core-impl/nm-setting-user.c @@ -26,8 +26,8 @@ NM_GOBJECT_PROPERTIES_DEFINE(NMSettingUser, PROP_DATA, ); typedef struct { - GHashTable * data; - GHashTable * data_invalid; + GHashTable *data; + GHashTable *data_invalid; const char **keys; } NMSettingUserPrivate; @@ -220,7 +220,7 @@ _create_data_hash(void) const char *const * nm_setting_user_get_keys(NMSettingUser *setting, guint *out_len) { - NMSettingUser * self = setting; + NMSettingUser *self = setting; NMSettingUserPrivate *priv; g_return_val_if_fail(NM_IS_SETTING_USER(self), NULL); @@ -276,7 +276,7 @@ nm_setting_user_get_data(NMSettingUser *setting, const char *key) gboolean nm_setting_user_set_data(NMSettingUser *setting, const char *key, const char *val, GError **error) { - NMSettingUser * self = setting; + NMSettingUser *self = setting; NMSettingUserPrivate *priv; gboolean changed = FALSE; @@ -340,12 +340,12 @@ out: static gboolean verify(NMSetting *setting, NMConnection *connection, GError **error) { - NMSettingUser * self = NM_SETTING_USER(setting); + NMSettingUser *self = NM_SETTING_USER(setting); NMSettingUserPrivate *priv = NM_SETTING_USER_GET_PRIVATE(self); if (priv->data_invalid) { - const char * key, *val; - GHashTableIter iter; + const char *key, *val; + GHashTableIter iter; gs_free_error GError *local = NULL; g_hash_table_iter_init(&iter, priv->data_invalid); @@ -411,11 +411,11 @@ compare_fcn_data(_NM_SETT_INFO_PROP_COMPARE_FCN_ARGS _nm_nil) static void get_property(GObject *object, guint prop_id, GValue *value, GParamSpec *pspec) { - NMSettingUser * self = NM_SETTING_USER(object); + NMSettingUser *self = NM_SETTING_USER(object); NMSettingUserPrivate *priv = NM_SETTING_USER_GET_PRIVATE(self); GHashTableIter iter; - GHashTable * data; - const char * key, *val; + GHashTable *data; + const char *key, *val; switch (prop_id) { case PROP_DATA: @@ -441,11 +441,11 @@ 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) { - NMSettingUser * self = NM_SETTING_USER(object); + NMSettingUser *self = NM_SETTING_USER(object); NMSettingUserPrivate *priv = NM_SETTING_USER_GET_PRIVATE(self); GHashTableIter iter; - GHashTable * data; - const char * key, *val; + GHashTable *data; + const char *key, *val; switch (prop_id) { case PROP_DATA: @@ -508,7 +508,7 @@ nm_setting_user_new(void) static void finalize(GObject *object) { - NMSettingUser * self = NM_SETTING_USER(object); + NMSettingUser *self = NM_SETTING_USER(object); NMSettingUserPrivate *priv = NM_SETTING_USER_GET_PRIVATE(self); g_free(priv->keys); @@ -523,9 +523,9 @@ finalize(GObject *object) static void nm_setting_user_class_init(NMSettingUserClass *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(); object_class->get_property = get_property; object_class->set_property = set_property; @@ -576,5 +576,5 @@ nm_setting_user_class_init(NMSettingUserClass *klass) NM_META_SETTING_TYPE_USER, NULL, properties_override, - G_STRUCT_OFFSET(NMSettingUser, _priv)); + 0); } diff --git a/src/libnm-core-impl/nm-setting-veth.c b/src/libnm-core-impl/nm-setting-veth.c index 43d8da4f..40e3c961 100644 --- a/src/libnm-core-impl/nm-setting-veth.c +++ b/src/libnm-core-impl/nm-setting-veth.c @@ -63,6 +63,7 @@ const char * nm_setting_veth_get_peer(NMSettingVeth *setting) { g_return_val_if_fail(NM_IS_SETTING_VETH(setting), NULL); + return NM_SETTING_VETH_GET_PRIVATE(setting)->peer; } @@ -101,35 +102,6 @@ verify(NMSetting *setting, NMConnection *connection, GError **error) /*****************************************************************************/ static void -get_property(GObject *object, guint prop_id, GValue *value, GParamSpec *pspec) -{ - NMSettingVeth * setting = NM_SETTING_VETH(object); - NMSettingVethPrivate *priv = NM_SETTING_VETH_GET_PRIVATE(setting); - - switch (prop_id) { - case PROP_PEER: - g_value_set_string(value, priv->peer); - break; - } -} - -static void -set_property(GObject *object, guint prop_id, const GValue *value, GParamSpec *pspec) -{ - NMSettingVeth * setting = NM_SETTING_VETH(object); - NMSettingVethPrivate *priv = NM_SETTING_VETH_GET_PRIVATE(setting); - - switch (prop_id) { - case PROP_PEER: - g_free(priv->peer); - priv->peer = g_value_dup_string(value); - break; - } -} - -/*****************************************************************************/ - -static void nm_setting_veth_init(NMSettingVeth *setting) {} @@ -149,27 +121,14 @@ nm_setting_veth_new(void) } static void -finalize(GObject *object) -{ - NMSettingVeth * setting = NM_SETTING_VETH(object); - NMSettingVethPrivate *priv = NM_SETTING_VETH_GET_PRIVATE(setting); - - g_free(priv->peer); - - G_OBJECT_CLASS(nm_setting_veth_parent_class)->finalize(object); -} - -static void nm_setting_veth_class_init(NMSettingVethClass *klass) { - GObjectClass * object_class = G_OBJECT_CLASS(klass); - NMSettingClass *setting_class = NM_SETTING_CLASS(klass); - - g_type_class_add_private(klass, sizeof(NMSettingVethPrivate)); + GObjectClass *object_class = G_OBJECT_CLASS(klass); + NMSettingClass *setting_class = NM_SETTING_CLASS(klass); + GArray *properties_override = _nm_sett_info_property_override_create_array(); - object_class->get_property = get_property; - object_class->set_property = set_property; - object_class->finalize = finalize; + object_class->get_property = _nm_setting_property_get_property_direct; + object_class->set_property = _nm_setting_property_set_property_direct; setting_class->verify = verify; @@ -181,14 +140,19 @@ nm_setting_veth_class_init(NMSettingVethClass *klass) * * Since: 1.30 **/ - obj_properties[PROP_PEER] = g_param_spec_string(NM_SETTING_VETH_PEER, - "", - "", - NULL, - G_PARAM_READWRITE | NM_SETTING_PARAM_INFERRABLE - | G_PARAM_STATIC_STRINGS); + _nm_setting_property_define_direct_string(properties_override, + obj_properties, + NM_SETTING_VETH_PEER, + PROP_PEER, + NM_SETTING_PARAM_INFERRABLE, + NMSettingVeth, + _priv.peer); g_object_class_install_properties(object_class, _PROPERTY_ENUMS_LAST, obj_properties); - _nm_setting_class_commit(setting_class, NM_META_SETTING_TYPE_VETH, NULL, NULL, 0); + _nm_setting_class_commit(setting_class, + NM_META_SETTING_TYPE_VETH, + NULL, + properties_override, + 0); } 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: diff --git a/src/libnm-core-impl/nm-setting-vpn.c b/src/libnm-core-impl/nm-setting-vpn.c index a543051b..42f75fa2 100644 --- a/src/libnm-core-impl/nm-setting-vpn.c +++ b/src/libnm-core-impl/nm-setting-vpn.c @@ -65,7 +65,6 @@ typedef struct { */ GHashTable *secrets; - /* Timeout for the VPN service to establish the connection */ guint32 timeout; /* Whether the VPN stays up across link changes, until the user @@ -272,7 +271,7 @@ static void foreach_item_helper(NMSettingVpn *self, GHashTable **p_hash, NMVpnIterFunc func, gpointer user_data) { gs_unref_object NMSettingVpn *self_keep_alive = NULL; - gs_strfreev char ** keys = NULL; + gs_strfreev char **keys = NULL; guint i, len; nm_assert(NM_IS_SETTING_VPN(self)); @@ -457,10 +456,10 @@ nm_setting_vpn_foreach_secret(NMSettingVpn *setting, NMVpnIterFunc func, gpointe static gboolean aggregate(NMSetting *setting, int type_i, gpointer arg) { - NMSettingVpnPrivate * priv = NM_SETTING_VPN_GET_PRIVATE(setting); + NMSettingVpnPrivate *priv = NM_SETTING_VPN_GET_PRIVATE(setting); NMConnectionAggregateType type = type_i; NMSettingSecretFlags secret_flags; - const char * key_name; + const char *key_name; GHashTableIter iter; switch (type) { @@ -597,9 +596,9 @@ update_secret_string(NMSetting *setting, const char *key, const char *value, GEr static NMSettingUpdateSecretResult update_secret_dict(NMSetting *setting, GVariant *secrets, GError **error) { - NMSettingVpnPrivate * priv = NM_SETTING_VPN_GET_PRIVATE(setting); + NMSettingVpnPrivate *priv = NM_SETTING_VPN_GET_PRIVATE(setting); GVariantIter iter; - const char * name, *value; + const char *name, *value; NMSettingUpdateSecretResult result = NM_SETTING_UPDATE_SECRET_SUCCESS_UNCHANGED; g_return_val_if_fail(secrets != NULL, NM_SETTING_UPDATE_SECRET_ERROR); @@ -669,18 +668,18 @@ update_one_secret(NMSetting *setting, const char *key, GVariant *value, GError * } static void -for_each_secret(NMSetting * setting, - const char * secret_name, - GVariant * val, +for_each_secret(NMSetting *setting, + const char *secret_name, + GVariant *val, gboolean remove_non_secrets, _NMConnectionForEachSecretFunc callback, gpointer callback_data, - GVariantBuilder * setting_builder) + GVariantBuilder *setting_builder) { GVariantBuilder vpn_secrets_builder; GVariantIter vpn_secrets_iter; - const char * vpn_secret_name; - const char * secret; + const char *vpn_secret_name; + const char *secret; if (!nm_streq(secret_name, NM_SETTING_VPN_SECRETS)) { NM_SETTING_CLASS(nm_setting_vpn_parent_class) @@ -723,15 +722,15 @@ for_each_secret(NMSetting * setting, } static gboolean -get_secret_flags(NMSetting * setting, - const char * secret_name, +get_secret_flags(NMSetting *setting, + const char *secret_name, NMSettingSecretFlags *out_flags, - GError ** error) + GError **error) { NMSettingVpnPrivate *priv = NM_SETTING_VPN_GET_PRIVATE(setting); - gs_free char * flags_key_free = NULL; - const char * flags_key; - const char * flags_val; + gs_free char *flags_key_free = NULL; + const char *flags_key; + const char *flags_val; gint64 i64; nm_assert(secret_name); @@ -779,10 +778,10 @@ get_secret_flags(NMSetting * setting, } static gboolean -set_secret_flags(NMSetting * setting, - const char * secret_name, +set_secret_flags(NMSetting *setting, + const char *secret_name, NMSettingSecretFlags flags, - GError ** error) + GError **error) { nm_assert(secret_name); @@ -812,7 +811,7 @@ static NMTernary compare_property_secrets(NMSettingVpn *a, NMSettingVpn *b, NMSettingCompareFlags flags) { GHashTableIter iter; - const char * key, *val; + const char *key, *val; int run; if (NM_FLAGS_HAS(flags, NM_SETTING_COMPARE_FLAG_FUZZY)) @@ -824,8 +823,8 @@ compare_property_secrets(NMSettingVpn *a, NMSettingVpn *b, NMSettingCompareFlags return TRUE; for (run = 0; run < 2; run++) { - NMSettingVpn * current_a = (run == 0) ? a : b; - NMSettingVpn * current_b = (run == 0) ? b : a; + NMSettingVpn *current_a = (run == 0) ? a : b; + NMSettingVpn *current_b = (run == 0) ? b : a; NMSettingVpnPrivate *priv_a = NM_SETTING_VPN_GET_PRIVATE(current_a); if (!priv_a->secrets) @@ -857,15 +856,15 @@ compare_fcn_secrets(_NM_SETT_INFO_PROP_COMPARE_FCN_ARGS _nm_nil) } static gboolean -clear_secrets(const NMSettInfoSetting * sett_info, - const NMSettInfoProperty * property_info, - NMSetting * setting, +clear_secrets(const NMSettInfoSetting *sett_info, + const NMSettInfoProperty *property_info, + NMSetting *setting, NMSettingClearSecretsWithFlagsFn func, gpointer user_data) { NMSettingVpnPrivate *priv = NM_SETTING_VPN_GET_PRIVATE(setting); GHashTableIter iter; - const char * secret; + const char *secret; gboolean changed = TRUE; if (!property_info->param_spec @@ -903,12 +902,12 @@ clear_secrets(const NMSettInfoSetting * sett_info, static gboolean vpn_secrets_from_dbus(_NM_SETT_INFO_PROP_FROM_DBUS_FCN_ARGS _nm_nil) { - NMSettingVpn * self = NM_SETTING_VPN(setting); - NMSettingVpnPrivate *priv = NM_SETTING_VPN_GET_PRIVATE(self); + NMSettingVpn *self = NM_SETTING_VPN(setting); + NMSettingVpnPrivate *priv = NM_SETTING_VPN_GET_PRIVATE(self); gs_unref_hashtable GHashTable *hash_free = NULL; GVariantIter iter; - const char * key; - const char * val; + const char *key; + const char *val; hash_free = g_steal_pointer(&priv->secrets); @@ -943,7 +942,7 @@ vpn_secrets_to_dbus(_NM_SETT_INFO_PROP_TO_DBUS_FCN_ARGS _nm_nil) keys = nm_strdict_get_keys(priv->secrets, TRUE, &len); for (i = 0; i < len; i++) { - const char * key = keys[i]; + const char *key = keys[i]; NMSettingSecretFlags secret_flags = NM_SETTING_SECRET_FLAG_NONE; if (NM_FLAGS_ANY(flags, @@ -966,30 +965,18 @@ vpn_secrets_to_dbus(_NM_SETT_INFO_PROP_TO_DBUS_FCN_ARGS _nm_nil) static void get_property(GObject *object, guint prop_id, GValue *value, GParamSpec *pspec) { - NMSettingVpn * setting = NM_SETTING_VPN(object); + NMSettingVpn *setting = NM_SETTING_VPN(object); NMSettingVpnPrivate *priv = NM_SETTING_VPN_GET_PRIVATE(setting); switch (prop_id) { - case PROP_SERVICE_TYPE: - g_value_set_string(value, nm_setting_vpn_get_service_type(setting)); - break; - case PROP_USER_NAME: - g_value_set_string(value, nm_setting_vpn_get_user_name(setting)); - break; - case PROP_PERSISTENT: - g_value_set_boolean(value, priv->persistent); - break; case PROP_DATA: g_value_take_boxed(value, _nm_utils_copy_strdict(priv->data)); break; case PROP_SECRETS: g_value_take_boxed(value, _nm_utils_copy_strdict(priv->secrets)); break; - case PROP_TIMEOUT: - g_value_set_uint(value, nm_setting_vpn_get_timeout(setting)); - break; default: - G_OBJECT_WARN_INVALID_PROPERTY_ID(object, prop_id, pspec); + _nm_setting_property_get_property_direct(object, prop_id, value, pspec); break; } } @@ -1000,23 +987,12 @@ set_property(GObject *object, guint prop_id, const GValue *value, GParamSpec *ps NMSettingVpnPrivate *priv = NM_SETTING_VPN_GET_PRIVATE(object); switch (prop_id) { - case PROP_SERVICE_TYPE: - g_free(priv->service_type); - priv->service_type = g_value_dup_string(value); - break; - case PROP_USER_NAME: - g_free(priv->user_name); - priv->user_name = g_value_dup_string(value); - break; - case PROP_PERSISTENT: - priv->persistent = g_value_get_boolean(value); - break; case PROP_DATA: case PROP_SECRETS: { gs_unref_hashtable GHashTable *hash_free = NULL; - GHashTable * src_hash = g_value_get_boxed(value); - GHashTable ** p_hash; + GHashTable *src_hash = g_value_get_boxed(value); + GHashTable **p_hash; const gboolean is_secrets = (prop_id == PROP_SECRETS); if (is_secrets) @@ -1028,8 +1004,8 @@ set_property(GObject *object, guint prop_id, const GValue *value, GParamSpec *ps if (src_hash && g_hash_table_size(src_hash) > 0) { GHashTableIter iter; - const char * key; - const char * val; + const char *key; + const char *val; g_hash_table_iter_init(&iter, src_hash); while (g_hash_table_iter_next(&iter, (gpointer *) &key, (gpointer *) &val)) { @@ -1046,11 +1022,8 @@ set_property(GObject *object, guint prop_id, const GValue *value, GParamSpec *ps } } } break; - case PROP_TIMEOUT: - priv->timeout = g_value_get_uint(value); - break; default: - G_OBJECT_WARN_INVALID_PROPERTY_ID(object, prop_id, pspec); + _nm_setting_property_set_property_direct(object, prop_id, value, pspec); break; } } @@ -1079,12 +1052,8 @@ finalize(GObject *object) { NMSettingVpnPrivate *priv = NM_SETTING_VPN_GET_PRIVATE(object); - g_free(priv->service_type); - g_free(priv->user_name); - if (priv->data) - g_hash_table_unref(priv->data); - if (priv->secrets) - g_hash_table_unref(priv->secrets); + nm_g_hash_table_unref(priv->data); + nm_g_hash_table_unref(priv->secrets); G_OBJECT_CLASS(nm_setting_vpn_parent_class)->finalize(object); } @@ -1092,9 +1061,9 @@ finalize(GObject *object) static void nm_setting_vpn_class_init(NMSettingVpnClass *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(NMSettingVpnPrivate)); @@ -1118,12 +1087,13 @@ nm_setting_vpn_class_init(NMSettingVpnClass *klass) * its network. i.e. org.freedesktop.NetworkManager.vpnc for the vpnc * plugin. **/ - obj_properties[PROP_SERVICE_TYPE] = - g_param_spec_string(NM_SETTING_VPN_SERVICE_TYPE, - "", - "", - NULL, - G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS); + _nm_setting_property_define_direct_string(properties_override, + obj_properties, + NM_SETTING_VPN_SERVICE_TYPE, + PROP_SERVICE_TYPE, + NM_SETTING_PARAM_NONE, + NMSettingVpnPrivate, + service_type); /** * NMSettingVpn:user-name: @@ -1135,12 +1105,13 @@ nm_setting_vpn_class_init(NMSettingVpnClass *klass) * will automatically supply the username of the user which requested the * VPN connection. **/ - obj_properties[PROP_USER_NAME] = - g_param_spec_string(NM_SETTING_VPN_USER_NAME, - "", - "", - NULL, - G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS); + _nm_setting_property_define_direct_string(properties_override, + obj_properties, + NM_SETTING_VPN_USER_NAME, + PROP_USER_NAME, + NM_SETTING_PARAM_NONE, + NMSettingVpnPrivate, + user_name); /** * NMSettingVpn:persistent: @@ -1221,13 +1192,16 @@ nm_setting_vpn_class_init(NMSettingVpnClass *klass) * * Since: 1.2 **/ - obj_properties[PROP_TIMEOUT] = g_param_spec_uint(NM_SETTING_VPN_TIMEOUT, - "", - "", - 0, - G_MAXUINT32, - 0, - G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS); + _nm_setting_property_define_direct_uint32(properties_override, + obj_properties, + NM_SETTING_VPN_TIMEOUT, + PROP_TIMEOUT, + 0, + G_MAXUINT32, + 0, + NM_SETTING_PARAM_NONE, + NMSettingVpnPrivate, + timeout); g_object_class_install_properties(object_class, _PROPERTY_ENUMS_LAST, obj_properties); diff --git a/src/libnm-core-impl/nm-setting-vrf.c b/src/libnm-core-impl/nm-setting-vrf.c index f998a7dd..4588149f 100644 --- a/src/libnm-core-impl/nm-setting-vrf.c +++ b/src/libnm-core-impl/nm-setting-vrf.c @@ -102,9 +102,9 @@ nm_setting_vrf_new(void) static void nm_setting_vrf_class_init(NMSettingVrfClass *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(); object_class->get_property = _nm_setting_property_get_property_direct; object_class->set_property = _nm_setting_property_set_property_direct; diff --git a/src/libnm-core-impl/nm-setting-vxlan.c b/src/libnm-core-impl/nm-setting-vxlan.c index c2d23a7f..f617a073 100644 --- a/src/libnm-core-impl/nm-setting-vxlan.c +++ b/src/libnm-core-impl/nm-setting-vxlan.c @@ -42,22 +42,22 @@ NM_GOBJECT_PROPERTIES_DEFINE_BASE(PROP_PARENT, PROP_L3_MISS, ); typedef struct { - char *parent; - char *local; - char *remote; - guint id; - guint source_port_min; - guint source_port_max; - guint destination_port; - guint tos; - guint ttl; - guint ageing; - guint limit; - bool proxy; - bool learning; - bool rsc; - bool l2_miss; - bool l3_miss; + char *parent; + char *local; + char *remote; + guint32 id; + guint32 source_port_min; + guint32 source_port_max; + guint32 destination_port; + guint32 tos; + guint32 ttl; + guint32 ageing; + guint32 limit; + bool proxy; + bool learning; + bool rsc; + bool l2_miss; + bool l3_miss; } NMSettingVxlanPrivate; /** @@ -95,6 +95,7 @@ const char * nm_setting_vxlan_get_parent(NMSettingVxlan *setting) { g_return_val_if_fail(NM_IS_SETTING_VXLAN(setting), NULL); + return NM_SETTING_VXLAN_GET_PRIVATE(setting)->parent; } @@ -110,6 +111,7 @@ guint nm_setting_vxlan_get_id(NMSettingVxlan *setting) { g_return_val_if_fail(NM_IS_SETTING_VXLAN(setting), 0); + return NM_SETTING_VXLAN_GET_PRIVATE(setting)->id; } @@ -125,6 +127,7 @@ const char * nm_setting_vxlan_get_local(NMSettingVxlan *setting) { g_return_val_if_fail(NM_IS_SETTING_VXLAN(setting), NULL); + return NM_SETTING_VXLAN_GET_PRIVATE(setting)->local; } @@ -140,6 +143,7 @@ const char * nm_setting_vxlan_get_remote(NMSettingVxlan *setting) { g_return_val_if_fail(NM_IS_SETTING_VXLAN(setting), NULL); + return NM_SETTING_VXLAN_GET_PRIVATE(setting)->remote; } @@ -155,6 +159,7 @@ guint nm_setting_vxlan_get_source_port_min(NMSettingVxlan *setting) { g_return_val_if_fail(NM_IS_SETTING_VXLAN(setting), 0); + return NM_SETTING_VXLAN_GET_PRIVATE(setting)->source_port_min; } @@ -170,6 +175,7 @@ guint nm_setting_vxlan_get_source_port_max(NMSettingVxlan *setting) { g_return_val_if_fail(NM_IS_SETTING_VXLAN(setting), 0); + return NM_SETTING_VXLAN_GET_PRIVATE(setting)->source_port_max; } @@ -185,6 +191,7 @@ guint nm_setting_vxlan_get_destination_port(NMSettingVxlan *setting) { g_return_val_if_fail(NM_IS_SETTING_VXLAN(setting), DST_PORT_DEFAULT); + return NM_SETTING_VXLAN_GET_PRIVATE(setting)->destination_port; } @@ -215,6 +222,7 @@ guint nm_setting_vxlan_get_ageing(NMSettingVxlan *setting) { g_return_val_if_fail(NM_IS_SETTING_VXLAN(setting), 0); + return NM_SETTING_VXLAN_GET_PRIVATE(setting)->ageing; } @@ -230,6 +238,7 @@ guint nm_setting_vxlan_get_limit(NMSettingVxlan *setting) { g_return_val_if_fail(NM_IS_SETTING_VXLAN(setting), 0); + return NM_SETTING_VXLAN_GET_PRIVATE(setting)->limit; } @@ -245,6 +254,7 @@ guint nm_setting_vxlan_get_tos(NMSettingVxlan *setting) { g_return_val_if_fail(NM_IS_SETTING_VXLAN(setting), 0); + return NM_SETTING_VXLAN_GET_PRIVATE(setting)->tos; } @@ -260,6 +270,7 @@ guint nm_setting_vxlan_get_ttl(NMSettingVxlan *setting) { g_return_val_if_fail(NM_IS_SETTING_VXLAN(setting), 0); + return NM_SETTING_VXLAN_GET_PRIVATE(setting)->ttl; } @@ -392,151 +403,8 @@ verify(NMSetting *setting, NMConnection *connection, GError **error) /*****************************************************************************/ static void -_addrstr_set(char **dst, const char *src) -{ - gs_free char *old = NULL; - - old = *dst; - if (!src) - *dst = NULL; - else if (!nm_utils_parse_inaddr(AF_UNSPEC, src, dst)) - *dst = g_strdup(src); -} -/*****************************************************************************/ - -static void -get_property(GObject *object, guint prop_id, GValue *value, GParamSpec *pspec) -{ - NMSettingVxlan * setting = NM_SETTING_VXLAN(object); - NMSettingVxlanPrivate *priv = NM_SETTING_VXLAN_GET_PRIVATE(setting); - - switch (prop_id) { - case PROP_PARENT: - g_value_set_string(value, priv->parent); - break; - case PROP_ID: - g_value_set_uint(value, priv->id); - break; - case PROP_LOCAL: - g_value_set_string(value, priv->local); - break; - case PROP_REMOTE: - g_value_set_string(value, priv->remote); - break; - case PROP_SOURCE_PORT_MIN: - g_value_set_uint(value, priv->source_port_min); - break; - case PROP_SOURCE_PORT_MAX: - g_value_set_uint(value, priv->source_port_max); - break; - case PROP_DESTINATION_PORT: - g_value_set_uint(value, priv->destination_port); - break; - case PROP_TOS: - g_value_set_uint(value, priv->tos); - break; - case PROP_AGEING: - g_value_set_uint(value, priv->ageing); - break; - case PROP_LIMIT: - g_value_set_uint(value, priv->limit); - break; - case PROP_PROXY: - g_value_set_boolean(value, priv->proxy); - break; - case PROP_TTL: - g_value_set_uint(value, priv->ttl); - break; - case PROP_LEARNING: - g_value_set_boolean(value, priv->learning); - break; - case PROP_RSC: - g_value_set_boolean(value, priv->rsc); - break; - case PROP_L2_MISS: - g_value_set_boolean(value, priv->l2_miss); - break; - case PROP_L3_MISS: - g_value_set_boolean(value, priv->l3_miss); - break; - default: - G_OBJECT_WARN_INVALID_PROPERTY_ID(object, prop_id, pspec); - break; - } -} - -static void -set_property(GObject *object, guint prop_id, const GValue *value, GParamSpec *pspec) -{ - NMSettingVxlan * setting = NM_SETTING_VXLAN(object); - NMSettingVxlanPrivate *priv = NM_SETTING_VXLAN_GET_PRIVATE(setting); - - switch (prop_id) { - case PROP_PARENT: - g_free(priv->parent); - priv->parent = g_value_dup_string(value); - break; - case PROP_ID: - priv->id = g_value_get_uint(value); - break; - case PROP_LOCAL: - _addrstr_set(&priv->local, g_value_get_string(value)); - break; - case PROP_REMOTE: - _addrstr_set(&priv->remote, g_value_get_string(value)); - break; - case PROP_SOURCE_PORT_MIN: - priv->source_port_min = g_value_get_uint(value); - break; - case PROP_SOURCE_PORT_MAX: - priv->source_port_max = g_value_get_uint(value); - break; - case PROP_DESTINATION_PORT: - priv->destination_port = g_value_get_uint(value); - break; - case PROP_TOS: - priv->tos = g_value_get_uint(value); - break; - case PROP_AGEING: - priv->ageing = g_value_get_uint(value); - break; - case PROP_LIMIT: - priv->limit = g_value_get_uint(value); - break; - case PROP_PROXY: - priv->proxy = g_value_get_boolean(value); - break; - case PROP_TTL: - priv->ttl = g_value_get_uint(value); - break; - case PROP_LEARNING: - priv->learning = g_value_get_boolean(value); - break; - case PROP_RSC: - priv->rsc = g_value_get_boolean(value); - break; - case PROP_L2_MISS: - priv->l2_miss = g_value_get_boolean(value); - break; - case PROP_L3_MISS: - priv->l3_miss = g_value_get_boolean(value); - break; - default: - G_OBJECT_WARN_INVALID_PROPERTY_ID(object, prop_id, pspec); - break; - } -} - -/*****************************************************************************/ - -static void nm_setting_vxlan_init(NMSettingVxlan *self) -{ - NMSettingVxlanPrivate *priv = NM_SETTING_VXLAN_GET_PRIVATE(self); - - priv->destination_port = DST_PORT_DEFAULT; - priv->ageing = 300; -} +{} /** * nm_setting_vxlan_new: @@ -554,30 +422,16 @@ nm_setting_vxlan_new(void) } static void -finalize(GObject *object) -{ - NMSettingVxlan * setting = NM_SETTING_VXLAN(object); - NMSettingVxlanPrivate *priv = NM_SETTING_VXLAN_GET_PRIVATE(setting); - - g_free(priv->parent); - g_free(priv->local); - g_free(priv->remote); - - G_OBJECT_CLASS(nm_setting_vxlan_parent_class)->finalize(object); -} - -static void nm_setting_vxlan_class_init(NMSettingVxlanClass *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(NMSettingVxlanPrivate)); - object_class->get_property = get_property; - object_class->set_property = set_property; - object_class->finalize = finalize; + object_class->get_property = _nm_setting_property_get_property_direct; + object_class->set_property = _nm_setting_property_set_property_direct; setting_class->verify = verify; @@ -588,12 +442,13 @@ nm_setting_vxlan_class_init(NMSettingVxlanClass *klass) * * Since: 1.2 **/ - obj_properties[PROP_PARENT] = g_param_spec_string( - NM_SETTING_VXLAN_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_VXLAN_PARENT, + PROP_PARENT, + NM_SETTING_PARAM_INFERRABLE, + NMSettingVxlanPrivate, + parent); /** * NMSettingVxlan:id: @@ -603,14 +458,16 @@ nm_setting_vxlan_class_init(NMSettingVxlanClass *klass) * * Since: 1.2 **/ - obj_properties[PROP_ID] = - g_param_spec_uint(NM_SETTING_VXLAN_ID, - "", - "", - 0, - (1 << 24) - 1, - 0, - G_PARAM_READWRITE | NM_SETTING_PARAM_INFERRABLE | G_PARAM_STATIC_STRINGS); + _nm_setting_property_define_direct_uint32(properties_override, + obj_properties, + NM_SETTING_VXLAN_ID, + PROP_ID, + 0, + (1 << 24) - 1, + 0, + NM_SETTING_PARAM_INFERRABLE, + NMSettingVxlanPrivate, + id); /** * NMSettingVxlan:local: @@ -619,12 +476,15 @@ nm_setting_vxlan_class_init(NMSettingVxlanClass *klass) * * Since: 1.2 **/ - obj_properties[PROP_LOCAL] = g_param_spec_string(NM_SETTING_VXLAN_LOCAL, - "", - "", - NULL, - G_PARAM_READWRITE | NM_SETTING_PARAM_INFERRABLE - | G_PARAM_STATIC_STRINGS); + _nm_setting_property_define_direct_string(properties_override, + obj_properties, + NM_SETTING_VXLAN_LOCAL, + PROP_LOCAL, + NM_SETTING_PARAM_INFERRABLE, + NMSettingVxlanPrivate, + local, + .direct_set_string_ip_address_addr_family = + AF_UNSPEC + 1); /** * NMSettingVxlan:remote: @@ -635,12 +495,15 @@ nm_setting_vxlan_class_init(NMSettingVxlanClass *klass) * * Since: 1.2 **/ - obj_properties[PROP_REMOTE] = g_param_spec_string( - NM_SETTING_VXLAN_REMOTE, - "", - "", - NULL, - G_PARAM_READWRITE | NM_SETTING_PARAM_INFERRABLE | G_PARAM_STATIC_STRINGS); + _nm_setting_property_define_direct_string(properties_override, + obj_properties, + NM_SETTING_VXLAN_REMOTE, + PROP_REMOTE, + NM_SETTING_PARAM_INFERRABLE, + NMSettingVxlanPrivate, + remote, + .direct_set_string_ip_address_addr_family = + AF_UNSPEC + 1); /** * NMSettingVxlan:source-port-min: @@ -650,14 +513,16 @@ nm_setting_vxlan_class_init(NMSettingVxlanClass *klass) * * Since: 1.2 **/ - obj_properties[PROP_SOURCE_PORT_MIN] = - g_param_spec_uint(NM_SETTING_VXLAN_SOURCE_PORT_MIN, - "", - "", - 0, - G_MAXUINT16, - 0, - G_PARAM_READWRITE | NM_SETTING_PARAM_INFERRABLE | G_PARAM_STATIC_STRINGS); + _nm_setting_property_define_direct_uint32(properties_override, + obj_properties, + NM_SETTING_VXLAN_SOURCE_PORT_MIN, + PROP_SOURCE_PORT_MIN, + 0, + G_MAXUINT16, + 0, + NM_SETTING_PARAM_INFERRABLE, + NMSettingVxlanPrivate, + source_port_min); /** * NMSettingVxlan:source-port-max: @@ -667,14 +532,16 @@ nm_setting_vxlan_class_init(NMSettingVxlanClass *klass) * * Since: 1.2 **/ - obj_properties[PROP_SOURCE_PORT_MAX] = - g_param_spec_uint(NM_SETTING_VXLAN_SOURCE_PORT_MAX, - "", - "", - 0, - G_MAXUINT16, - 0, - G_PARAM_READWRITE | NM_SETTING_PARAM_INFERRABLE | G_PARAM_STATIC_STRINGS); + _nm_setting_property_define_direct_uint32(properties_override, + obj_properties, + NM_SETTING_VXLAN_SOURCE_PORT_MAX, + PROP_SOURCE_PORT_MAX, + 0, + G_MAXUINT16, + 0, + NM_SETTING_PARAM_INFERRABLE, + NMSettingVxlanPrivate, + source_port_max); /** * NMSettingVxlan:destination-port: @@ -684,14 +551,16 @@ nm_setting_vxlan_class_init(NMSettingVxlanClass *klass) * * Since: 1.2 **/ - obj_properties[PROP_DESTINATION_PORT] = - g_param_spec_uint(NM_SETTING_VXLAN_DESTINATION_PORT, - "", - "", - 0, - G_MAXUINT16, - DST_PORT_DEFAULT, - G_PARAM_READWRITE | NM_SETTING_PARAM_INFERRABLE | G_PARAM_STATIC_STRINGS); + _nm_setting_property_define_direct_uint32(properties_override, + obj_properties, + NM_SETTING_VXLAN_DESTINATION_PORT, + PROP_DESTINATION_PORT, + 0, + G_MAXUINT16, + DST_PORT_DEFAULT, + NM_SETTING_PARAM_INFERRABLE, + NMSettingVxlanPrivate, + destination_port); /** * NMSettingVxlan:ageing: @@ -700,14 +569,16 @@ nm_setting_vxlan_class_init(NMSettingVxlanClass *klass) * * Since: 1.2 **/ - obj_properties[PROP_AGEING] = - g_param_spec_uint(NM_SETTING_VXLAN_AGEING, - "", - "", - 0, - G_MAXUINT32, - 300, - G_PARAM_READWRITE | NM_SETTING_PARAM_INFERRABLE | G_PARAM_STATIC_STRINGS); + _nm_setting_property_define_direct_uint32(properties_override, + obj_properties, + NM_SETTING_VXLAN_AGEING, + PROP_AGEING, + 0, + G_MAXUINT32, + 300, + NM_SETTING_PARAM_INFERRABLE, + NMSettingVxlanPrivate, + ageing); /** * NMSettingVxlan:limit: @@ -717,14 +588,16 @@ nm_setting_vxlan_class_init(NMSettingVxlanClass *klass) * * Since: 1.2 **/ - obj_properties[PROP_LIMIT] = - g_param_spec_uint(NM_SETTING_VXLAN_LIMIT, - "", - "", - 0, - G_MAXUINT32, - 0, - G_PARAM_READWRITE | NM_SETTING_PARAM_INFERRABLE | G_PARAM_STATIC_STRINGS); + _nm_setting_property_define_direct_uint32(properties_override, + obj_properties, + NM_SETTING_VXLAN_LIMIT, + PROP_LIMIT, + 0, + G_MAXUINT32, + 0, + NM_SETTING_PARAM_INFERRABLE, + NMSettingVxlanPrivate, + limit); /** * NMSettingVxlan:tos: @@ -733,14 +606,16 @@ nm_setting_vxlan_class_init(NMSettingVxlanClass *klass) * * Since: 1.2 **/ - obj_properties[PROP_TOS] = - g_param_spec_uint(NM_SETTING_VXLAN_TOS, - "", - "", - 0, - 255, - 0, - G_PARAM_READWRITE | NM_SETTING_PARAM_INFERRABLE | G_PARAM_STATIC_STRINGS); + _nm_setting_property_define_direct_uint32(properties_override, + obj_properties, + NM_SETTING_VXLAN_TOS, + PROP_TOS, + 0, + 255, + 0, + NM_SETTING_PARAM_INFERRABLE, + NMSettingVxlanPrivate, + tos); /** * NMSettingVxlan:ttl: @@ -749,14 +624,16 @@ nm_setting_vxlan_class_init(NMSettingVxlanClass *klass) * * Since: 1.2 **/ - obj_properties[PROP_TTL] = - g_param_spec_uint(NM_SETTING_VXLAN_TTL, - "", - "", - 0, - 255, - 0, - G_PARAM_READWRITE | NM_SETTING_PARAM_INFERRABLE | G_PARAM_STATIC_STRINGS); + _nm_setting_property_define_direct_uint32(properties_override, + obj_properties, + NM_SETTING_VXLAN_TTL, + PROP_TTL, + 0, + 255, + 0, + NM_SETTING_PARAM_INFERRABLE, + NMSettingVxlanPrivate, + ttl); /** * NMSettingVxlan:proxy: diff --git a/src/libnm-core-impl/nm-setting-wifi-p2p.c b/src/libnm-core-impl/nm-setting-wifi-p2p.c index 06d450fc..e8ce4bdc 100644 --- a/src/libnm-core-impl/nm-setting-wifi-p2p.c +++ b/src/libnm-core-impl/nm-setting-wifi-p2p.c @@ -35,7 +35,7 @@ NM_GOBJECT_PROPERTIES_DEFINE_BASE(PROP_PEER, PROP_WPS_METHOD, PROP_WFD_IES, ); typedef struct { - char * peer; + char *peer; GBytes *wfd_ies; guint32 wps_method; } NMSettingWifiP2PPrivate; @@ -170,9 +170,9 @@ nm_setting_wifi_p2p_new(void) static void nm_setting_wifi_p2p_class_init(NMSettingWifiP2PClass *setting_wifi_p2p_class) { - GObjectClass * object_class = G_OBJECT_CLASS(setting_wifi_p2p_class); + GObjectClass *object_class = G_OBJECT_CLASS(setting_wifi_p2p_class); NMSettingClass *setting_class = NM_SETTING_CLASS(setting_wifi_p2p_class); - GArray * properties_override = _nm_sett_info_property_override_create_array(); + GArray *properties_override = _nm_sett_info_property_override_create_array(); object_class->get_property = _nm_setting_property_get_property_direct; object_class->set_property = _nm_setting_property_set_property_direct; diff --git a/src/libnm-core-impl/nm-setting-wimax.c b/src/libnm-core-impl/nm-setting-wimax.c index f7fed08e..1e2b51c3 100644 --- a/src/libnm-core-impl/nm-setting-wimax.c +++ b/src/libnm-core-impl/nm-setting-wimax.c @@ -101,23 +101,12 @@ verify(NMSetting *setting, NMConnection *connection, GError **error) { NMSettingWimaxPrivate *priv = NM_SETTING_WIMAX_GET_PRIVATE(setting); - if (!priv->network_name) { + if (nm_str_is_empty(priv->network_name)) { g_set_error_literal(error, NM_CONNECTION_ERROR, NM_CONNECTION_ERROR_MISSING_PROPERTY, - _("property is missing")); - g_prefix_error(error, - "%s.%s: ", - NM_SETTING_WIMAX_SETTING_NAME, - NM_SETTING_WIMAX_NETWORK_NAME); - return FALSE; - } - - if (!strlen(priv->network_name)) { - g_set_error_literal(error, - NM_CONNECTION_ERROR, - NM_CONNECTION_ERROR_INVALID_PROPERTY, - _("property is empty")); + !priv->network_name ? _("property is missing") + : _("property is empty")); g_prefix_error(error, "%s.%s: ", NM_SETTING_WIMAX_SETTING_NAME, @@ -143,47 +132,6 @@ verify(NMSetting *setting, NMConnection *connection, GError **error) /*****************************************************************************/ static void -get_property(GObject *object, guint prop_id, GValue *value, GParamSpec *pspec) -{ - NMSettingWimax *setting = NM_SETTING_WIMAX(object); - - switch (prop_id) { - case PROP_NETWORK_NAME: - g_value_set_string(value, nm_setting_wimax_get_network_name(setting)); - break; - case PROP_MAC_ADDRESS: - g_value_set_string(value, nm_setting_wimax_get_mac_address(setting)); - break; - default: - G_OBJECT_WARN_INVALID_PROPERTY_ID(object, prop_id, pspec); - break; - } -} - -static void -set_property(GObject *object, guint prop_id, const GValue *value, GParamSpec *pspec) -{ - NMSettingWimaxPrivate *priv = NM_SETTING_WIMAX_GET_PRIVATE(object); - - switch (prop_id) { - case PROP_NETWORK_NAME: - g_free(priv->network_name); - priv->network_name = g_value_dup_string(value); - break; - case PROP_MAC_ADDRESS: - g_free(priv->mac_address); - priv->mac_address = - _nm_utils_hwaddr_canonical_or_invalid(g_value_get_string(value), ETH_ALEN); - break; - default: - G_OBJECT_WARN_INVALID_PROPERTY_ID(object, prop_id, pspec); - break; - } -} - -/*****************************************************************************/ - -static void nm_setting_wimax_init(NMSettingWimax *setting) {} @@ -203,27 +151,16 @@ nm_setting_wimax_new(void) } static void -finalize(GObject *object) -{ - NMSettingWimaxPrivate *priv = NM_SETTING_WIMAX_GET_PRIVATE(object); - - g_free(priv->network_name); - - G_OBJECT_CLASS(nm_setting_wimax_parent_class)->finalize(object); -} - -static void nm_setting_wimax_class_init(NMSettingWimaxClass *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(NMSettingWimaxPrivate)); - object_class->get_property = get_property; - object_class->set_property = set_property; - object_class->finalize = finalize; + object_class->get_property = _nm_setting_property_get_property_direct; + object_class->set_property = _nm_setting_property_set_property_direct; setting_class->verify = verify; @@ -235,12 +172,13 @@ nm_setting_wimax_class_init(NMSettingWimaxClass *klass) * * Deprecated: 1.2: WiMAX is no longer supported. **/ - obj_properties[PROP_NETWORK_NAME] = - g_param_spec_string(NM_SETTING_WIMAX_NETWORK_NAME, - "", - "", - NULL, - G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS); + _nm_setting_property_define_direct_string(properties_override, + obj_properties, + NM_SETTING_WIMAX_NETWORK_NAME, + PROP_NETWORK_NAME, + NM_SETTING_PARAM_NONE, + NMSettingWimaxPrivate, + network_name); /** * NMSettingWimax:mac-address: diff --git a/src/libnm-core-impl/nm-setting-wired.c b/src/libnm-core-impl/nm-setting-wired.c index 8c9bdcd4..830b2c73 100644 --- a/src/libnm-core-impl/nm-setting-wired.c +++ b/src/libnm-core-impl/nm-setting-wired.c @@ -53,20 +53,20 @@ typedef struct { guint len; guint n_alloc; } s390_options; - GArray * mac_address_blacklist; - char ** s390_subchannels; - char * port; - char * duplex; - char * device_mac_address; - char * cloned_mac_address; - char * generate_mac_address_mask; - char * s390_nettype; - char * wol_password; - NMSettingWiredWakeOnLan wol; - NMTernary accept_all_mac_addresses; - guint32 speed; - guint32 mtu; - bool auto_negotiate; + GArray *mac_address_blacklist; + char **s390_subchannels; + char *port; + char *duplex; + char *device_mac_address; + char *cloned_mac_address; + char *generate_mac_address_mask; + char *s390_nettype; + char *wol_password; + int accept_all_mac_addresses; + guint32 wake_on_lan; + guint32 speed; + guint32 mtu; + bool auto_negotiate; } NMSettingWiredPrivate; /** @@ -344,7 +344,7 @@ gboolean nm_setting_wired_add_mac_blacklist_item(NMSettingWired *setting, const char *mac) { NMSettingWiredPrivate *priv; - const char * candidate; + const char *candidate; int i; g_return_val_if_fail(NM_IS_SETTING_WIRED(setting), FALSE); @@ -401,7 +401,7 @@ gboolean nm_setting_wired_remove_mac_blacklist_item_by_value(NMSettingWired *setting, const char *mac) { NMSettingWiredPrivate *priv; - const char * candidate; + const char *candidate; int i; g_return_val_if_fail(NM_IS_SETTING_WIRED(setting), FALSE); @@ -526,8 +526,8 @@ nm_setting_wired_get_num_s390_options(NMSettingWired *setting) gboolean nm_setting_wired_get_s390_option(NMSettingWired *setting, guint32 idx, - const char ** out_key, - const char ** out_value) + const char **out_key, + const char **out_value) { NMSettingWiredPrivate *priv; @@ -731,7 +731,7 @@ nm_setting_wired_get_wake_on_lan(NMSettingWired *setting) { g_return_val_if_fail(NM_IS_SETTING_WIRED(setting), NM_SETTING_WIRED_WAKE_ON_LAN_NONE); - return NM_SETTING_WIRED_GET_PRIVATE(setting)->wol; + return NM_SETTING_WIRED_GET_PRIVATE(setting)->wake_on_lan; } /** @@ -773,7 +773,7 @@ static gboolean verify(NMSetting *setting, NMConnection *connection, GError **error) { NMSettingWiredPrivate *priv = NM_SETTING_WIRED_GET_PRIVATE(setting); - GError * local = NULL; + GError *local = NULL; guint i; if (!NM_IN_STRSET(priv->port, NULL, "tp", "aui", "bnc", "mii")) { @@ -919,8 +919,8 @@ verify(NMSetting *setting, NMConnection *connection, GError **error) return FALSE; } - if (NM_FLAGS_ANY(priv->wol, NM_SETTING_WIRED_WAKE_ON_LAN_EXCLUSIVE_FLAGS) - && !nm_utils_is_power_of_two(priv->wol)) { + if (NM_FLAGS_ANY(priv->wake_on_lan, NM_SETTING_WIRED_WAKE_ON_LAN_EXCLUSIVE_FLAGS) + && !nm_utils_is_power_of_two(priv->wake_on_lan)) { g_set_error_literal(error, NM_CONNECTION_ERROR, NM_CONNECTION_ERROR_INVALID_PROPERTY, @@ -932,7 +932,8 @@ verify(NMSetting *setting, NMConnection *connection, GError **error) return FALSE; } - if (priv->wol_password && !NM_FLAGS_HAS(priv->wol, NM_SETTING_WIRED_WAKE_ON_LAN_MAGIC)) { + if (priv->wol_password + && !NM_FLAGS_HAS(priv->wake_on_lan, NM_SETTING_WIRED_WAKE_ON_LAN_MAGIC)) { g_set_error_literal(error, NM_CONNECTION_ERROR, NM_CONNECTION_ERROR_INVALID_PROPERTY, @@ -996,45 +997,21 @@ clear_blacklist_item(char **item_p) static void get_property(GObject *object, guint prop_id, GValue *value, GParamSpec *pspec) { - NMSettingWired * setting = NM_SETTING_WIRED(object); + NMSettingWired *setting = NM_SETTING_WIRED(object); NMSettingWiredPrivate *priv = NM_SETTING_WIRED_GET_PRIVATE(setting); - GHashTable * hash; + GHashTable *hash; guint i; switch (prop_id) { - case PROP_PORT: - g_value_set_string(value, nm_setting_wired_get_port(setting)); - break; - case PROP_SPEED: - g_value_set_uint(value, nm_setting_wired_get_speed(setting)); - break; - case PROP_DUPLEX: - g_value_set_string(value, nm_setting_wired_get_duplex(setting)); - break; - case PROP_AUTO_NEGOTIATE: - g_value_set_boolean(value, nm_setting_wired_get_auto_negotiate(setting)); - break; - case PROP_MAC_ADDRESS: - g_value_set_string(value, nm_setting_wired_get_mac_address(setting)); - break; case PROP_CLONED_MAC_ADDRESS: g_value_set_string(value, nm_setting_wired_get_cloned_mac_address(setting)); break; - case PROP_GENERATE_MAC_ADDRESS_MASK: - g_value_set_string(value, nm_setting_wired_get_generate_mac_address_mask(setting)); - break; case PROP_MAC_ADDRESS_BLACKLIST: g_value_set_boxed(value, (char **) priv->mac_address_blacklist->data); break; - case PROP_MTU: - g_value_set_uint(value, nm_setting_wired_get_mtu(setting)); - break; case PROP_S390_SUBCHANNELS: g_value_set_boxed(value, priv->s390_subchannels); break; - case PROP_S390_NETTYPE: - g_value_set_string(value, nm_setting_wired_get_s390_nettype(setting)); - break; case PROP_S390_OPTIONS: hash = g_hash_table_new_full(nm_str_hash, g_str_equal, g_free, g_free); for (i = 0; i < priv->s390_options.len; i++) { @@ -1044,17 +1021,8 @@ get_property(GObject *object, guint prop_id, GValue *value, GParamSpec *pspec) } g_value_take_boxed(value, hash); break; - case PROP_WAKE_ON_LAN: - g_value_set_uint(value, priv->wol); - break; - case PROP_WAKE_ON_LAN_PASSWORD: - g_value_set_string(value, priv->wol_password); - break; - case PROP_ACCEPT_ALL_MAC_ADDRESSES: - g_value_set_enum(value, priv->accept_all_mac_addresses); - break; default: - G_OBJECT_WARN_INVALID_PROPERTY_ID(object, prop_id, pspec); + _nm_setting_property_get_property_direct(object, prop_id, value, pspec); break; } } @@ -1063,38 +1031,15 @@ static void set_property(GObject *object, guint prop_id, const GValue *value, GParamSpec *pspec) { NMSettingWiredPrivate *priv = NM_SETTING_WIRED_GET_PRIVATE(object); - const char *const * blacklist; - const char * mac; + const char *const *blacklist; + const char *mac; switch (prop_id) { - case PROP_PORT: - g_free(priv->port); - priv->port = g_value_dup_string(value); - break; - case PROP_SPEED: - priv->speed = g_value_get_uint(value); - break; - case PROP_DUPLEX: - g_free(priv->duplex); - priv->duplex = g_value_dup_string(value); - break; - case PROP_AUTO_NEGOTIATE: - priv->auto_negotiate = g_value_get_boolean(value); - break; - case PROP_MAC_ADDRESS: - g_free(priv->device_mac_address); - priv->device_mac_address = - _nm_utils_hwaddr_canonical_or_invalid(g_value_get_string(value), ETH_ALEN); - break; case PROP_CLONED_MAC_ADDRESS: g_free(priv->cloned_mac_address); priv->cloned_mac_address = _nm_utils_hwaddr_canonical_or_invalid(g_value_get_string(value), ETH_ALEN); break; - case PROP_GENERATE_MAC_ADDRESS_MASK: - g_free(priv->generate_mac_address_mask); - priv->generate_mac_address_mask = g_value_dup_string(value); - break; case PROP_MAC_ADDRESS_BLACKLIST: blacklist = g_value_get_boxed(value); g_array_set_size(priv->mac_address_blacklist, 0); @@ -1107,18 +1052,11 @@ set_property(GObject *object, guint prop_id, const GValue *value, GParamSpec *ps } } break; - case PROP_MTU: - priv->mtu = g_value_get_uint(value); - break; case PROP_S390_SUBCHANNELS: if (priv->s390_subchannels) g_strfreev(priv->s390_subchannels); priv->s390_subchannels = g_value_dup_boxed(value); break; - case PROP_S390_NETTYPE: - g_free(priv->s390_nettype); - priv->s390_nettype = g_value_dup_string(value); - break; case PROP_S390_OPTIONS: { GHashTable *hash; @@ -1132,8 +1070,8 @@ set_property(GObject *object, guint prop_id, const GValue *value, GParamSpec *ps if (priv->s390_options.n_alloc > 0u) { gboolean invalid_content = FALSE; GHashTableIter iter; - const char * key; - const char * val; + const char *key; + const char *val; guint j; guint i; @@ -1181,18 +1119,8 @@ set_property(GObject *object, guint prop_id, const GValue *value, GParamSpec *ps g_return_if_fail(!invalid_content); } } break; - case PROP_WAKE_ON_LAN: - priv->wol = g_value_get_uint(value); - break; - case PROP_WAKE_ON_LAN_PASSWORD: - g_free(priv->wol_password); - priv->wol_password = g_value_dup_string(value); - break; - case PROP_ACCEPT_ALL_MAC_ADDRESSES: - priv->accept_all_mac_addresses = g_value_get_enum(value); - break; default: - G_OBJECT_WARN_INVALID_PROPERTY_ID(object, prop_id, pspec); + _nm_setting_property_set_property_direct(object, prop_id, value, pspec); break; } } @@ -1207,9 +1135,6 @@ nm_setting_wired_init(NMSettingWired *setting) /* We use GArray rather than GPtrArray so it will automatically be NULL-terminated */ priv->mac_address_blacklist = g_array_new(TRUE, FALSE, sizeof(char *)); g_array_set_clear_func(priv->mac_address_blacklist, (GDestroyNotify) clear_blacklist_item); - - priv->wol = NM_SETTING_WIRED_WAKE_ON_LAN_DEFAULT; - priv->accept_all_mac_addresses = NM_TERNARY_DEFAULT; } /** @@ -1234,9 +1159,7 @@ finalize(GObject *object) g_free(priv->cloned_mac_address); g_array_unref(priv->mac_address_blacklist); - - if (priv->s390_subchannels) - g_strfreev(priv->s390_subchannels); + g_strfreev(priv->s390_subchannels); G_OBJECT_CLASS(nm_setting_wired_parent_class)->finalize(object); } @@ -1244,9 +1167,9 @@ finalize(GObject *object) static void nm_setting_wired_class_init(NMSettingWiredClass *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(NMSettingWiredPrivate)); @@ -1302,13 +1225,16 @@ nm_setting_wired_class_init(NMSettingWiredClass *klass) * parameter in the ETHTOOL_OPTS variable. * ---end--- */ - obj_properties[PROP_SPEED] = g_param_spec_uint(NM_SETTING_WIRED_SPEED, - "", - "", - 0, - G_MAXUINT32, - 0, - G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS); + _nm_setting_property_define_direct_uint32(properties_override, + obj_properties, + NM_SETTING_WIRED_SPEED, + PROP_SPEED, + 0, + G_MAXUINT32, + 0, + NM_SETTING_PARAM_NONE, + NMSettingWiredPrivate, + speed); /** * NMSettingWired:duplex: @@ -1566,14 +1492,16 @@ nm_setting_wired_class_init(NMSettingWiredClass *klass) * description: MTU of the interface. * ---end--- */ - obj_properties[PROP_MTU] = g_param_spec_uint(NM_SETTING_WIRED_MTU, - "", - "", - 0, - G_MAXUINT32, - 0, - G_PARAM_READWRITE | NM_SETTING_PARAM_FUZZY_IGNORE - | G_PARAM_STATIC_STRINGS); + _nm_setting_property_define_direct_uint32(properties_override, + obj_properties, + NM_SETTING_WIRED_MTU, + PROP_MTU, + 0, + G_MAXUINT32, + 0, + NM_SETTING_PARAM_FUZZY_IGNORE, + NMSettingWiredPrivate, + mtu); /** * NMSettingWired:s390-subchannels: @@ -1674,14 +1602,16 @@ nm_setting_wired_class_init(NMSettingWiredClass *klass) * in the ethtool manual page. * ---end--- */ - obj_properties[PROP_WAKE_ON_LAN] = - g_param_spec_uint(NM_SETTING_WIRED_WAKE_ON_LAN, - "", - "", - 0, - G_MAXUINT32, - NM_SETTING_WIRED_WAKE_ON_LAN_DEFAULT, - G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS); + _nm_setting_property_define_direct_uint32(properties_override, + obj_properties, + NM_SETTING_WIRED_WAKE_ON_LAN, + PROP_WAKE_ON_LAN, + 0, + G_MAXUINT32, + NM_SETTING_WIRED_WAKE_ON_LAN_DEFAULT, + NM_SETTING_PARAM_NONE, + NMSettingWiredPrivate, + wake_on_lan); /** * NMSettingWired:wake-on-lan-password: @@ -1724,13 +1654,13 @@ nm_setting_wired_class_init(NMSettingWiredClass *klass) * description: Enforce the interface to accept all the packets. * ---end--- */ - obj_properties[PROP_ACCEPT_ALL_MAC_ADDRESSES] = - g_param_spec_enum(NM_SETTING_WIRED_ACCEPT_ALL_MAC_ADDRESSES, - "", - "", - NM_TYPE_TERNARY, - NM_TERNARY_DEFAULT, - G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS); + _nm_setting_property_define_direct_ternary_enum(properties_override, + obj_properties, + NM_SETTING_WIRED_ACCEPT_ALL_MAC_ADDRESSES, + PROP_ACCEPT_ALL_MAC_ADDRESSES, + NM_SETTING_PARAM_NONE, + NMSettingWiredPrivate, + accept_all_mac_addresses); g_object_class_install_properties(object_class, _PROPERTY_ENUMS_LAST, obj_properties); diff --git a/src/libnm-core-impl/nm-setting-wireguard.c b/src/libnm-core-impl/nm-setting-wireguard.c index 27b81488..d713b6a5 100644 --- a/src/libnm-core-impl/nm-setting-wireguard.c +++ b/src/libnm-core-impl/nm-setting-wireguard.c @@ -46,10 +46,10 @@ G_DEFINE_BOXED_TYPE(NMWireGuardPeer, * Since: 1.16 */ struct _NMWireGuardPeer { - NMSockAddrEndpoint * endpoint; - char * public_key; - char * preshared_key; - GPtrArray * allowed_ips; + NMSockAddrEndpoint *endpoint; + char *public_key; + char *preshared_key; + GPtrArray *allowed_ips; guint refcount; NMSettingSecretFlags preshared_key_flags; guint16 persistent_keepalive; @@ -278,10 +278,10 @@ nm_wireguard_peer_get_public_key(const NMWireGuardPeer *self) */ gboolean nm_wireguard_peer_set_public_key(NMWireGuardPeer *self, - const char * public_key, + const char *public_key, gboolean accept_invalid) { - char * public_key_normalized = NULL; + char *public_key_normalized = NULL; gboolean is_valid; g_return_val_if_fail(NM_IS_WIREGUARD_PEER(self, FALSE), FALSE); @@ -365,10 +365,10 @@ nm_wireguard_peer_get_preshared_key(const NMWireGuardPeer *self) */ gboolean nm_wireguard_peer_set_preshared_key(NMWireGuardPeer *self, - const char * preshared_key, + const char *preshared_key, gboolean accept_invalid) { - char * preshared_key_normalized = NULL; + char *preshared_key_normalized = NULL; gboolean is_valid; g_return_val_if_fail(NM_IS_WIREGUARD_PEER(self, FALSE), FALSE); @@ -418,7 +418,7 @@ nm_wireguard_peer_get_preshared_key_flags(const NMWireGuardPeer *self) * Since: 1.16 */ void -nm_wireguard_peer_set_preshared_key_flags(NMWireGuardPeer * self, +nm_wireguard_peer_set_preshared_key_flags(NMWireGuardPeer *self, NMSettingSecretFlags preshared_key_flags) { g_return_if_fail(NM_IS_WIREGUARD_PEER(self, FALSE)); @@ -620,7 +620,7 @@ _peer_append_allowed_ip(NMWireGuardPeer *self, const char *allowed_ip, gboolean int addr_family; int prefix; NMIPAddr addrbin; - char * str; + char *str; gboolean is_valid = TRUE; nm_assert(NM_IS_WIREGUARD_PEER(self, FALSE)); @@ -677,7 +677,7 @@ _peer_append_allowed_ip(NMWireGuardPeer *self, const char *allowed_ip, gboolean */ gboolean nm_wireguard_peer_append_allowed_ip(NMWireGuardPeer *self, - const char * allowed_ip, + const char *allowed_ip, gboolean accept_invalid) { g_return_val_if_fail(NM_IS_WIREGUARD_PEER(self, FALSE), FALSE); @@ -733,7 +733,7 @@ gboolean nm_wireguard_peer_is_valid(const NMWireGuardPeer *self, gboolean check_non_secrets, gboolean check_secrets, - GError ** error) + GError **error) { guint i; @@ -876,7 +876,7 @@ nm_wireguard_peer_cmp(const NMWireGuardPeer *a, /*****************************************************************************/ typedef struct { - const char * public_key; + const char *public_key; NMWireGuardPeer *peer; guint idx; } PeerData; @@ -893,17 +893,17 @@ NM_GOBJECT_PROPERTIES_DEFINE_BASE(PROP_FWMARK, PROP_PRIVATE_KEY_FLAGS, ); typedef struct { - char * private_key; - GPtrArray * peers_arr; - GHashTable * peers_hash; - NMSettingSecretFlags private_key_flags; - NMTernary ip4_auto_default_route; - NMTernary ip6_auto_default_route; - guint32 fwmark; - guint32 mtu; - guint16 listen_port; - bool peer_routes; - bool private_key_valid : 1; + char *private_key; + GPtrArray *peers_arr; + GHashTable *peers_hash; + guint private_key_flags; + int ip4_auto_default_route; + int ip6_auto_default_route; + guint32 fwmark; + guint32 mtu; + guint32 listen_port; + bool peer_routes; + bool private_key_valid : 1; } NMSettingWireGuardPrivate; /** @@ -941,7 +941,7 @@ G_DEFINE_TYPE(NMSettingWireGuard, nm_setting_wireguard, NM_TYPE_SETTING) #define peers_psk_get_secret_parse_a(secret_public_key, public_key_free) \ ({ \ const char *_secret_public_key = (secret_public_key); \ - char ** _public_key_free = (public_key_free); \ + char **_public_key_free = (public_key_free); \ const char *_public_key = NULL; \ \ nm_assert(_public_key_free && !*_public_key_free); \ @@ -1132,11 +1132,11 @@ _peers_get(NMSettingWireGuardPrivate *priv, guint idx) static PeerData * _peers_get_by_public_key(NMSettingWireGuardPrivate *priv, - const char * public_key, + const char *public_key, gboolean try_with_normalized_key) { gs_free char *public_key_normalized = NULL; - PeerData * pd; + PeerData *pd; again: nm_assert(priv); @@ -1233,11 +1233,11 @@ nm_setting_wireguard_get_peer(NMSettingWireGuard *self, guint idx) */ NMWireGuardPeer * nm_setting_wireguard_get_peer_by_public_key(NMSettingWireGuard *self, - const char * public_key, - guint * out_idx) + const char *public_key, + guint *out_idx) { NMSettingWireGuardPrivate *priv; - PeerData * pd; + PeerData *pd; g_return_val_if_fail(NM_IS_SETTING_WIREGUARD(self), NULL); g_return_val_if_fail(public_key, NULL); @@ -1255,12 +1255,12 @@ nm_setting_wireguard_get_peer_by_public_key(NMSettingWireGuard *self, static gboolean _peers_set(NMSettingWireGuardPrivate *priv, - NMWireGuardPeer * peer, + NMWireGuardPeer *peer, guint idx, gboolean check_same_key) { - PeerData * pd_same_key = NULL; - PeerData * pd_idx = NULL; + PeerData *pd_same_key = NULL; + PeerData *pd_idx = NULL; const char *public_key; nm_assert(idx <= priv->peers_arr->len); @@ -1462,7 +1462,7 @@ nm_setting_wireguard_clear_peers(NMSettingWireGuard *self) static GVariant * _peers_dbus_only_synth(_NM_SETT_INFO_PROP_TO_DBUS_FCN_ARGS _nm_nil) { - NMSettingWireGuard * self = NM_SETTING_WIREGUARD(setting); + NMSettingWireGuard *self = NM_SETTING_WIREGUARD(setting); NMSettingWireGuardPrivate *priv; gboolean any_peers = FALSE; GVariantBuilder peers_builder; @@ -1518,7 +1518,7 @@ _peers_dbus_only_synth(_NM_SETT_INFO_PROP_TO_DBUS_FCN_ARGS _nm_nil) if (_nm_connection_serialize_non_secret(flags) && peer->allowed_ips && peer->allowed_ips->len > 0) { - const char *const * strv = (const char *const *) peer->allowed_ips->pdata; + const char *const *strv = (const char *const *) peer->allowed_ips->pdata; gs_free const char **strv_fixed = NULL; for (i = 0; i < peer->allowed_ips->len; i++) { @@ -1561,7 +1561,7 @@ static gboolean _peers_dbus_only_set(_NM_SETT_INFO_PROP_FROM_DBUS_FCN_ARGS _nm_nil) { GVariantIter iter_peers; - GVariant * peer_var; + GVariant *peer_var; guint i_peer; gboolean success = FALSE; gboolean peers_changed = FALSE; @@ -1574,9 +1574,9 @@ _peers_dbus_only_set(_NM_SETT_INFO_PROP_FROM_DBUS_FCN_ARGS _nm_nil) while (g_variant_iter_next(&iter_peers, "@a{sv}", &peer_var)) { _nm_unused gs_unref_variant GVariant *peer_var_unref = peer_var; nm_auto_unref_wgpeer NMWireGuardPeer *peer = NULL; - const char * cstr; + const char *cstr; guint32 u32; - GVariant * var; + GVariant *var; i_peer++; @@ -1633,7 +1633,7 @@ _peers_dbus_only_set(_NM_SETT_INFO_PROP_FROM_DBUS_FCN_ARGS _nm_nil) if (g_variant_lookup(peer_var, NM_WIREGUARD_PEER_ATTR_ALLOWED_IPS, "@as", &var)) { _nm_unused gs_unref_variant GVariant *var_free = var; - gs_free const char ** allowed_ips = NULL; + gs_free const char **allowed_ips = NULL; gsize i, l; allowed_ips = g_variant_get_strv(var, &l); @@ -1688,7 +1688,7 @@ out: static gboolean verify(NMSetting *setting, NMConnection *connection, GError **error) { - NMSettingWireGuard * s_wg = NM_SETTING_WIREGUARD(setting); + NMSettingWireGuard *s_wg = NM_SETTING_WIREGUARD(setting); NMSettingWireGuardPrivate *priv = NM_SETTING_WIREGUARD_GET_PRIVATE(setting); guint i; @@ -1718,7 +1718,7 @@ verify(NMSetting *setting, NMConnection *connection, GError **error) if (connection) { NMSettingIPConfig *s_ip4; NMSettingIPConfig *s_ip6; - const char * method; + const char *method; /* WireGuard is Layer 3 only. For the moment, we only support a restricted set of * IP methods. We may relax that later, once we fix the implementations so they @@ -1803,10 +1803,10 @@ static GPtrArray * need_secrets(NMSetting *setting) { NMSettingWireGuardPrivate *priv = NM_SETTING_WIREGUARD_GET_PRIVATE(setting); - GPtrArray * secrets = NULL; + GPtrArray *secrets = NULL; guint i; - if (!priv->private_key || !priv->private_key_valid) { + if (!priv->private_key_valid) { secrets = g_ptr_array_new_full(1, g_free); g_ptr_array_add(secrets, g_strdup(NM_SETTING_WIREGUARD_PRIVATE_KEY)); } @@ -1832,9 +1832,9 @@ need_secrets(NMSetting *setting) } static gboolean -clear_secrets(const NMSettInfoSetting * sett_info, - const NMSettInfoProperty * property_info, - NMSetting * setting, +clear_secrets(const NMSettInfoSetting *sett_info, + const NMSettInfoProperty *property_info, + NMSetting *setting, NMSettingClearSecretsWithFlagsFn func, gpointer user_data) { @@ -1852,7 +1852,7 @@ clear_secrets(const NMSettInfoSetting * sett_info, if (func) { gs_free char *name_free = NULL; - const char * name; + const char *name; if (j++ < 5) { /* we use alloca() inside a loop here, but it is guarded to happen at most @@ -1891,12 +1891,12 @@ clear_secrets(const NMSettInfoSetting * sett_info, static int update_one_secret(NMSetting *setting, const char *key, GVariant *value, GError **error) { - NMSettingWireGuard * self = NM_SETTING_WIREGUARD(setting); + NMSettingWireGuard *self = NM_SETTING_WIREGUARD(setting); NMSettingWireGuardPrivate *priv; gboolean has_changes = FALSE; gboolean has_error = FALSE; GVariantIter iter_peers; - GVariant * peer_var; + GVariant *peer_var; guint i_peer; if (!nm_streq(key, NM_SETTING_WIREGUARD_PEERS)) { @@ -1924,8 +1924,8 @@ update_one_secret(NMSetting *setting, const char *key, GVariant *value, GError * while (g_variant_iter_next(&iter_peers, "@a{sv}", &peer_var)) { _nm_unused gs_unref_variant GVariant *peer_var_unref = peer_var; nm_auto_unref_wgpeer NMWireGuardPeer *peer = NULL; - PeerData * pd; - const char * cstr; + PeerData *pd; + const char *cstr; i_peer++; @@ -2041,14 +2041,14 @@ duplicate_copy_properties(const NMSettInfoSetting *sett_info, NMSetting *src, NM static void enumerate_values(const NMSettInfoProperty *property_info, - NMSetting * setting, + NMSetting *setting, NMSettingValueIterFn func, gpointer user_data) { if (nm_streq(property_info->name, NM_SETTING_WIREGUARD_PEERS)) { - NMSettingWireGuardPrivate * priv = NM_SETTING_WIREGUARD_GET_PRIVATE(setting); + NMSettingWireGuardPrivate *priv = NM_SETTING_WIREGUARD_GET_PRIVATE(setting); nm_auto_unset_gvalue GValue value = G_VALUE_INIT; - GPtrArray * ptr = NULL; + GPtrArray *ptr = NULL; guint i; if (priv->peers_arr && priv->peers_arr->len > 0) { @@ -2115,16 +2115,16 @@ out_done: } static gboolean -get_secret_flags(NMSetting * setting, - const char * secret_name, +get_secret_flags(NMSetting *setting, + const char *secret_name, NMSettingSecretFlags *out_flags, - GError ** error) + GError **error) { if (NM_STR_HAS_PREFIX(secret_name, NM_SETTING_WIREGUARD_PEERS ".")) { NMSettingWireGuardPrivate *priv = NM_SETTING_WIREGUARD_GET_PRIVATE(setting); - gs_free char * public_key_free = NULL; - const char * public_key; - PeerData * pd; + gs_free char *public_key_free = NULL; + const char *public_key; + PeerData *pd; public_key = peers_psk_get_secret_parse_a(secret_name, &public_key_free); if (public_key && (pd = _peers_get_by_public_key(priv, public_key, FALSE))) { @@ -2138,17 +2138,17 @@ get_secret_flags(NMSetting * setting, } static gboolean -set_secret_flags(NMSetting * setting, - const char * secret_name, +set_secret_flags(NMSetting *setting, + const char *secret_name, NMSettingSecretFlags flags, - GError ** error) + GError **error) { if (NM_STR_HAS_PREFIX(secret_name, NM_SETTING_WIREGUARD_PEERS ".")) { - NMSettingWireGuard * self = NM_SETTING_WIREGUARD(setting); + NMSettingWireGuard *self = NM_SETTING_WIREGUARD(setting); NMSettingWireGuardPrivate *priv = NM_SETTING_WIREGUARD_GET_PRIVATE(self); - gs_free char * public_key_free = NULL; - const char * public_key; - PeerData * pd; + gs_free char *public_key_free = NULL; + const char *public_key; + PeerData *pd; public_key = peers_psk_get_secret_parse_a(secret_name, &public_key_free); if (public_key && (pd = _peers_get_by_public_key(priv, public_key, FALSE))) { @@ -2170,20 +2170,20 @@ set_secret_flags(NMSetting * setting, } static void -for_each_secret(NMSetting * setting, - const char * data_key, - GVariant * data_val, +for_each_secret(NMSetting *setting, + const char *data_key, + GVariant *data_val, gboolean remove_non_secrets, _NMConnectionForEachSecretFunc callback, gpointer callback_data, - GVariantBuilder * setting_builder) + GVariantBuilder *setting_builder) { - NMSettingWireGuard * s_wg; + NMSettingWireGuard *s_wg; NMSettingWireGuardPrivate *priv; GVariantBuilder peers_builder; - GVariantIter * peer_iter; + GVariantIter *peer_iter; GVariantIter data_iter; - const char * key; + const char *key; if (!nm_streq(data_key, NM_SETTING_WIREGUARD_PEERS)) { NM_SETTING_CLASS(nm_setting_wireguard_parent_class) @@ -2210,11 +2210,11 @@ for_each_secret(NMSetting * setting, g_variant_iter_init(&data_iter, data_val); while (g_variant_iter_next(&data_iter, "a{sv}", &peer_iter)) { _nm_unused nm_auto_free_variant_iter GVariantIter *peer_iter_free = peer_iter; - gs_unref_variant GVariant *preshared_key = NULL; - PeerData * pd = NULL; - NMSettingSecretFlags secret_flags; - GVariant * val; - GVariantBuilder peer_builder; + gs_unref_variant GVariant *preshared_key = NULL; + PeerData *pd = NULL; + NMSettingSecretFlags secret_flags; + GVariant *val; + GVariantBuilder peer_builder; g_variant_builder_init(&peer_builder, G_VARIANT_TYPE("a{sv}")); @@ -2258,89 +2258,35 @@ for_each_secret(NMSetting * setting, /*****************************************************************************/ -static void -get_property(GObject *object, guint prop_id, GValue *value, GParamSpec *pspec) +static gboolean +_set_string_fcn_public_key(const NMSettInfoSetting *sett_info, + const NMSettInfoProperty *property_info, + NMSetting *setting, + const char *str) { - NMSettingWireGuard * setting = NM_SETTING_WIREGUARD(object); - NMSettingWireGuardPrivate *priv = NM_SETTING_WIREGUARD_GET_PRIVATE(setting); - - switch (prop_id) { - case PROP_FWMARK: - g_value_set_uint(value, priv->fwmark); - break; - case PROP_IP4_AUTO_DEFAULT_ROUTE: - g_value_set_enum(value, priv->ip4_auto_default_route); - break; - case PROP_IP6_AUTO_DEFAULT_ROUTE: - g_value_set_enum(value, priv->ip6_auto_default_route); - break; - case PROP_LISTEN_PORT: - g_value_set_uint(value, priv->listen_port); - break; - case PROP_MTU: - g_value_set_uint(value, priv->mtu); - break; - case PROP_PEER_ROUTES: - g_value_set_boolean(value, priv->peer_routes); - break; - case PROP_PRIVATE_KEY: - g_value_set_string(value, priv->private_key); - break; - case PROP_PRIVATE_KEY_FLAGS: - g_value_set_flags(value, priv->private_key_flags); - break; - default: - G_OBJECT_WARN_INVALID_PROPERTY_ID(object, prop_id, pspec); - break; + NMSettingWireGuardPrivate *priv = NM_SETTING_WIREGUARD_GET_PRIVATE(setting); + gboolean valid; + char *new = NULL; + char *old; + + if (str) + valid = nm_utils_base64secret_normalize(str, NM_WIREGUARD_PUBLIC_KEY_LEN, &new); + else + valid = FALSE; + + if (nm_streq0(new ?: str, priv->private_key)) { + nm_assert(priv->private_key_valid == valid); + nm_free_secret(new); + return FALSE; } -} -static void -set_property(GObject *object, guint prop_id, const GValue *value, GParamSpec *pspec) -{ - NMSettingWireGuardPrivate *priv = NM_SETTING_WIREGUARD_GET_PRIVATE(object); - const char * str; + priv->private_key_valid = valid; - switch (prop_id) { - case PROP_FWMARK: - priv->fwmark = g_value_get_uint(value); - break; - case PROP_IP4_AUTO_DEFAULT_ROUTE: - priv->ip4_auto_default_route = g_value_get_enum(value); - break; - case PROP_IP6_AUTO_DEFAULT_ROUTE: - priv->ip6_auto_default_route = g_value_get_enum(value); - break; - case PROP_LISTEN_PORT: - priv->listen_port = g_value_get_uint(value); - break; - case PROP_MTU: - priv->mtu = g_value_get_uint(value); - break; - case PROP_PEER_ROUTES: - priv->peer_routes = g_value_get_boolean(value); - break; - case PROP_PRIVATE_KEY: - nm_clear_pointer(&priv->private_key, nm_free_secret); - str = g_value_get_string(value); - if (str) { - if (nm_utils_base64secret_normalize(str, - NM_WIREGUARD_PUBLIC_KEY_LEN, - &priv->private_key)) - priv->private_key_valid = TRUE; - else { - priv->private_key = g_strdup(str); - priv->private_key_valid = FALSE; - } - } - break; - case PROP_PRIVATE_KEY_FLAGS: - priv->private_key_flags = g_value_get_flags(value); - break; - default: - G_OBJECT_WARN_INVALID_PROPERTY_ID(object, prop_id, pspec); - break; - } + old = priv->private_key; + priv->private_key = new ?: g_strdup(str); + nm_free_secret(old); + + return TRUE; } /*****************************************************************************/ @@ -2350,10 +2296,8 @@ nm_setting_wireguard_init(NMSettingWireGuard *setting) { NMSettingWireGuardPrivate *priv = NM_SETTING_WIREGUARD_GET_PRIVATE(setting); - priv->peers_arr = g_ptr_array_new(); - priv->peers_hash = g_hash_table_new(nm_pstr_hash, nm_pstr_equal); - priv->ip4_auto_default_route = NM_TERNARY_DEFAULT; - priv->ip6_auto_default_route = NM_TERNARY_DEFAULT; + priv->peers_arr = g_ptr_array_new(); + priv->peers_hash = g_hash_table_new(nm_pstr_hash, nm_pstr_equal); } /** @@ -2376,8 +2320,6 @@ finalize(GObject *object) { NMSettingWireGuardPrivate *priv = NM_SETTING_WIREGUARD_GET_PRIVATE(object); - nm_free_secret(priv->private_key); - _peers_clear(priv); g_ptr_array_unref(priv->peers_arr); g_hash_table_unref(priv->peers_hash); @@ -2388,12 +2330,12 @@ finalize(GObject *object) static void nm_setting_wireguard_class_init(NMSettingWireGuardClass *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(); - object_class->get_property = get_property; - object_class->set_property = set_property; + 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; @@ -2415,12 +2357,15 @@ nm_setting_wireguard_class_init(NMSettingWireGuardClass *klass) * * Since: 1.16 **/ - obj_properties[PROP_PRIVATE_KEY] = - g_param_spec_string(NM_SETTING_WIREGUARD_PRIVATE_KEY, - "", - "", - NULL, - G_PARAM_READWRITE | NM_SETTING_PARAM_SECRET | G_PARAM_STATIC_STRINGS); + _nm_setting_property_define_direct_string(properties_override, + obj_properties, + NM_SETTING_WIREGUARD_PRIVATE_KEY, + PROP_PRIVATE_KEY, + NM_SETTING_PARAM_SECRET, + NMSettingWireGuard, + _priv.private_key, + .direct_hook.set_string_fcn = + _set_string_fcn_public_key); /** * NMSettingWireGuard:private-key-flags: @@ -2430,13 +2375,12 @@ nm_setting_wireguard_class_init(NMSettingWireGuardClass *klass) * * Since: 1.16 **/ - obj_properties[PROP_PRIVATE_KEY_FLAGS] = - g_param_spec_flags(NM_SETTING_WIREGUARD_PRIVATE_KEY_FLAGS, - "", - "", - NM_TYPE_SETTING_SECRET_FLAGS, - NM_SETTING_SECRET_FLAG_NONE, - G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS); + _nm_setting_property_define_direct_secret_flags(properties_override, + obj_properties, + NM_SETTING_WIREGUARD_PRIVATE_KEY_FLAGS, + PROP_PRIVATE_KEY_FLAGS, + NMSettingWireGuard, + _priv.private_key_flags); /** * NMSettingWireGuard:fwmark: @@ -2449,14 +2393,16 @@ nm_setting_wireguard_class_init(NMSettingWireGuardClass *klass) * * Since: 1.16 **/ - obj_properties[PROP_FWMARK] = - g_param_spec_uint(NM_SETTING_WIREGUARD_FWMARK, - "", - "", - 0, - G_MAXUINT32, - 0, - G_PARAM_READWRITE | NM_SETTING_PARAM_INFERRABLE | G_PARAM_STATIC_STRINGS); + _nm_setting_property_define_direct_uint32(properties_override, + obj_properties, + NM_SETTING_WIREGUARD_FWMARK, + PROP_FWMARK, + 0, + G_MAXUINT32, + 0, + NM_SETTING_PARAM_INFERRABLE, + NMSettingWireGuard, + _priv.fwmark); /** * NMSettingWireGuard:listen-port: @@ -2466,14 +2412,16 @@ nm_setting_wireguard_class_init(NMSettingWireGuardClass *klass) * * Since: 1.16 **/ - obj_properties[PROP_LISTEN_PORT] = - g_param_spec_uint(NM_SETTING_WIREGUARD_LISTEN_PORT, - "", - "", - 0, - 65535, - 0, - G_PARAM_READWRITE | NM_SETTING_PARAM_INFERRABLE | G_PARAM_STATIC_STRINGS); + _nm_setting_property_define_direct_uint32(properties_override, + obj_properties, + NM_SETTING_WIREGUARD_LISTEN_PORT, + PROP_LISTEN_PORT, + 0, + 65535, + 0, + NM_SETTING_PARAM_INFERRABLE, + NMSettingWireGuard, + _priv.listen_port); /** * NMSettingWireGuard:peer-routes: @@ -2498,8 +2446,8 @@ nm_setting_wireguard_class_init(NMSettingWireGuardClass *klass) PROP_PEER_ROUTES, TRUE, NM_SETTING_PARAM_INFERRABLE, - NMSettingWireGuardPrivate, - peer_routes); + NMSettingWireGuard, + _priv.peer_routes); /** * NMSettingWireGuard:mtu: @@ -2513,14 +2461,16 @@ nm_setting_wireguard_class_init(NMSettingWireGuardClass *klass) * * Since: 1.16 **/ - obj_properties[PROP_MTU] = - g_param_spec_uint(NM_SETTING_WIREGUARD_MTU, - "", - "", - 0, - G_MAXUINT32, - 0, - G_PARAM_READWRITE | NM_SETTING_PARAM_INFERRABLE | G_PARAM_STATIC_STRINGS); + _nm_setting_property_define_direct_uint32(properties_override, + obj_properties, + NM_SETTING_WIREGUARD_MTU, + PROP_MTU, + 0, + G_MAXUINT32, + 0, + NM_SETTING_PARAM_INFERRABLE, + NMSettingWireGuard, + _priv.mtu); /** * NMSettingWireGuard:ip4-auto-default-route: @@ -2542,13 +2492,13 @@ nm_setting_wireguard_class_init(NMSettingWireGuardClass *klass) * * Since: 1.20 **/ - obj_properties[PROP_IP4_AUTO_DEFAULT_ROUTE] = g_param_spec_enum( - NM_SETTING_WIREGUARD_IP4_AUTO_DEFAULT_ROUTE, - "", - "", - NM_TYPE_TERNARY, - NM_TERNARY_DEFAULT, - NM_SETTING_PARAM_FUZZY_IGNORE | G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS); + _nm_setting_property_define_direct_ternary_enum(properties_override, + obj_properties, + NM_SETTING_WIREGUARD_IP4_AUTO_DEFAULT_ROUTE, + PROP_IP4_AUTO_DEFAULT_ROUTE, + NM_SETTING_PARAM_FUZZY_IGNORE, + NMSettingWireGuard, + _priv.ip4_auto_default_route); /** * NMSettingWireGuard:ip6-auto-default-route: @@ -2557,13 +2507,13 @@ nm_setting_wireguard_class_init(NMSettingWireGuardClass *klass) * * Since: 1.20 **/ - obj_properties[PROP_IP6_AUTO_DEFAULT_ROUTE] = g_param_spec_enum( - NM_SETTING_WIREGUARD_IP6_AUTO_DEFAULT_ROUTE, - "", - "", - NM_TYPE_TERNARY, - NM_TERNARY_DEFAULT, - NM_SETTING_PARAM_FUZZY_IGNORE | G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS); + _nm_setting_property_define_direct_ternary_enum(properties_override, + obj_properties, + NM_SETTING_WIREGUARD_IP6_AUTO_DEFAULT_ROUTE, + PROP_IP6_AUTO_DEFAULT_ROUTE, + NM_SETTING_PARAM_FUZZY_IGNORE, + NMSettingWireGuard, + _priv.ip6_auto_default_route); /* ---dbus--- * property: peers @@ -2585,5 +2535,5 @@ nm_setting_wireguard_class_init(NMSettingWireGuardClass *klass) NM_META_SETTING_TYPE_WIREGUARD, NULL, properties_override, - G_STRUCT_OFFSET(NMSettingWireGuard, _priv)); + 0); } diff --git a/src/libnm-core-impl/nm-setting-wireless-security.c b/src/libnm-core-impl/nm-setting-wireless-security.c index 0bfc30c8..d9c5afb8 100644 --- a/src/libnm-core-impl/nm-setting-wireless-security.c +++ b/src/libnm-core-impl/nm-setting-wireless-security.c @@ -62,26 +62,26 @@ NM_GOBJECT_PROPERTIES_DEFINE(NMSettingWirelessSecurity, PROP_FILS, ); typedef struct { - GSList * proto; /* GSList of strings */ - GSList * pairwise; /* GSList of strings */ - GSList * group; /* GSList of strings */ - char * key_mgmt; - char * auth_alg; - char * leap_username; - char * leap_password; - char * wep_key0; - char * wep_key1; - char * wep_key2; - char * wep_key3; - char * psk; - NMSettingSecretFlags leap_password_flags; - NMSettingSecretFlags wep_key_flags; - NMSettingSecretFlags psk_flags; - NMSettingWirelessSecurityPmf pmf; - NMWepKeyType wep_key_type; - NMSettingWirelessSecurityWpsMethod wps_method; - NMSettingWirelessSecurityFils fils; - guint32 wep_tx_keyidx; + GSList *proto; /* GSList of strings */ + GSList *pairwise; /* GSList of strings */ + GSList *group; /* GSList of strings */ + char *key_mgmt; + char *auth_alg; + char *leap_username; + char *leap_password; + char *wep_key0; + char *wep_key1; + char *wep_key2; + char *wep_key3; + char *psk; + guint leap_password_flags; + guint wep_key_flags; + guint psk_flags; + NMWepKeyType wep_key_type; + gint32 pmf; + gint32 fils; + guint32 wep_tx_keyidx; + guint32 wps_method; } NMSettingWirelessSecurityPrivate; /** @@ -177,7 +177,7 @@ gboolean nm_setting_wireless_security_add_proto(NMSettingWirelessSecurity *setting, const char *proto) { NMSettingWirelessSecurityPrivate *priv; - GSList * iter; + GSList *iter; g_return_val_if_fail(NM_IS_SETTING_WIRELESS_SECURITY(setting), FALSE); g_return_val_if_fail(proto != NULL, FALSE); @@ -204,7 +204,7 @@ void nm_setting_wireless_security_remove_proto(NMSettingWirelessSecurity *setting, guint32 i) { NMSettingWirelessSecurityPrivate *priv; - GSList * elt; + GSList *elt; g_return_if_fail(NM_IS_SETTING_WIRELESS_SECURITY(setting)); @@ -228,10 +228,10 @@ nm_setting_wireless_security_remove_proto(NMSettingWirelessSecurity *setting, gu **/ gboolean nm_setting_wireless_security_remove_proto_by_value(NMSettingWirelessSecurity *setting, - const char * proto) + const char *proto) { NMSettingWirelessSecurityPrivate *priv; - GSList * iter; + GSList *iter; g_return_val_if_fail(NM_IS_SETTING_WIRELESS_SECURITY(setting), FALSE); g_return_val_if_fail(proto != NULL, FALSE); @@ -321,7 +321,7 @@ gboolean nm_setting_wireless_security_add_pairwise(NMSettingWirelessSecurity *setting, const char *pairwise) { NMSettingWirelessSecurityPrivate *priv; - GSList * iter; + GSList *iter; g_return_val_if_fail(NM_IS_SETTING_WIRELESS_SECURITY(setting), FALSE); g_return_val_if_fail(pairwise != NULL, FALSE); @@ -349,7 +349,7 @@ void nm_setting_wireless_security_remove_pairwise(NMSettingWirelessSecurity *setting, guint32 i) { NMSettingWirelessSecurityPrivate *priv; - GSList * elt; + GSList *elt; g_return_if_fail(NM_IS_SETTING_WIRELESS_SECURITY(setting)); @@ -374,10 +374,10 @@ nm_setting_wireless_security_remove_pairwise(NMSettingWirelessSecurity *setting, **/ gboolean nm_setting_wireless_security_remove_pairwise_by_value(NMSettingWirelessSecurity *setting, - const char * pairwise) + const char *pairwise) { NMSettingWirelessSecurityPrivate *priv; - GSList * iter; + GSList *iter; g_return_val_if_fail(NM_IS_SETTING_WIRELESS_SECURITY(setting), FALSE); g_return_val_if_fail(pairwise != NULL, FALSE); @@ -468,7 +468,7 @@ gboolean nm_setting_wireless_security_add_group(NMSettingWirelessSecurity *setting, const char *group) { NMSettingWirelessSecurityPrivate *priv; - GSList * iter; + GSList *iter; g_return_val_if_fail(NM_IS_SETTING_WIRELESS_SECURITY(setting), FALSE); g_return_val_if_fail(group != NULL, FALSE); @@ -496,7 +496,7 @@ void nm_setting_wireless_security_remove_group(NMSettingWirelessSecurity *setting, guint32 i) { NMSettingWirelessSecurityPrivate *priv; - GSList * elt; + GSList *elt; g_return_if_fail(NM_IS_SETTING_WIRELESS_SECURITY(setting)); @@ -522,10 +522,10 @@ nm_setting_wireless_security_remove_group(NMSettingWirelessSecurity *setting, gu **/ gboolean nm_setting_wireless_security_remove_group_by_value(NMSettingWirelessSecurity *setting, - const char * group) + const char *group) { NMSettingWirelessSecurityPrivate *priv; - GSList * iter; + GSList *iter; g_return_val_if_fail(NM_IS_SETTING_WIRELESS_SECURITY(setting), FALSE); g_return_val_if_fail(group != NULL, FALSE); @@ -691,7 +691,7 @@ nm_setting_wireless_security_get_wep_key(NMSettingWirelessSecurity *setting, gui void nm_setting_wireless_security_set_wep_key(NMSettingWirelessSecurity *setting, guint32 idx, - const char * key) + const char *key) { NMSettingWirelessSecurityPrivate *priv; @@ -817,9 +817,9 @@ nm_setting_wireless_security_get_fils(NMSettingWirelessSecurity *setting) static GPtrArray * need_secrets(NMSetting *setting) { - NMSettingWirelessSecurity * self = NM_SETTING_WIRELESS_SECURITY(setting); + NMSettingWirelessSecurity *self = NM_SETTING_WIRELESS_SECURITY(setting); NMSettingWirelessSecurityPrivate *priv = NM_SETTING_WIRELESS_SECURITY_GET_PRIVATE(self); - GPtrArray * secrets; + GPtrArray *secrets; secrets = g_ptr_array_sized_new(4); @@ -895,16 +895,16 @@ no_secrets: static gboolean verify(NMSetting *setting, NMConnection *connection, GError **error) { - NMSettingWirelessSecurity * self = NM_SETTING_WIRELESS_SECURITY(setting); + NMSettingWirelessSecurity *self = NM_SETTING_WIRELESS_SECURITY(setting); NMSettingWirelessSecurityPrivate *priv = NM_SETTING_WIRELESS_SECURITY_GET_PRIVATE(self); - const char * valid_key_mgmt[] = + const char *valid_key_mgmt[] = {"none", "ieee8021x", "wpa-psk", "wpa-eap", "wpa-eap-suite-b-192", "sae", "owe", NULL}; - const char * valid_auth_algs[] = {"open", "shared", "leap", NULL}; - const char * valid_protos[] = {"wpa", "rsn", NULL}; - const char * valid_pairwise[] = {"tkip", "ccmp", NULL}; - const char * valid_groups[] = {"wep40", "wep104", "tkip", "ccmp", NULL}; + const char *valid_auth_algs[] = {"open", "shared", "leap", NULL}; + const char *valid_protos[] = {"wpa", "rsn", NULL}; + const char *valid_pairwise[] = {"tkip", "ccmp", NULL}; + const char *valid_groups[] = {"wep40", "wep104", "tkip", "ccmp", NULL}; NMSettingWireless *s_wifi; - const char * wifi_mode; + const char *wifi_mode; s_wifi = connection ? nm_connection_get_setting_wireless(connection) : NULL; wifi_mode = s_wifi ? nm_setting_wireless_get_mode(s_wifi) : NULL; @@ -993,7 +993,7 @@ verify(NMSetting *setting, NMConnection *connection, GError **error) } } - if (priv->leap_username && !strlen(priv->leap_username)) { + if (priv->leap_username && nm_str_is_empty(priv->leap_username)) { g_set_error_literal(error, NM_CONNECTION_ERROR, NM_CONNECTION_ERROR_INVALID_PROPERTY, @@ -1005,19 +1005,6 @@ verify(NMSetting *setting, NMConnection *connection, GError **error) return FALSE; } - if (priv->wep_tx_keyidx > 3) { - g_set_error(error, - NM_CONNECTION_ERROR, - NM_CONNECTION_ERROR_INVALID_PROPERTY, - _("'%d' value is out of range <0-3>"), - priv->wep_tx_keyidx); - g_prefix_error(error, - "%s.%s: ", - NM_SETTING_WIRELESS_SECURITY_SETTING_NAME, - NM_SETTING_WIRELESS_SECURITY_WEP_TX_KEYIDX); - return FALSE; - } - if (priv->wep_key_type > NM_WEP_KEY_TYPE_LAST) { g_set_error_literal(error, NM_CONNECTION_ERROR, @@ -1161,10 +1148,10 @@ verify(NMSetting *setting, NMConnection *connection, GError **error) } static gboolean -_verify_wep_key(const char * wep_key, +_verify_wep_key(const char *wep_key, NMWepKeyType wep_key_type, - const char * property, - GError ** error) + const char *property, + GError **error) { if (wep_key && !nm_utils_wep_key_valid(wep_key, wep_key_type)) { g_set_error_literal(error, @@ -1180,7 +1167,7 @@ _verify_wep_key(const char * wep_key, static gboolean verify_secrets(NMSetting *setting, NMConnection *connection, GError **error) { - NMSettingWirelessSecurity * self = NM_SETTING_WIRELESS_SECURITY(setting); + NMSettingWirelessSecurity *self = NM_SETTING_WIRELESS_SECURITY(setting); NMSettingWirelessSecurityPrivate *priv = NM_SETTING_WIRELESS_SECURITY_GET_PRIVATE(self); /* LEAP */ @@ -1231,10 +1218,10 @@ verify_secrets(NMSetting *setting, NMConnection *connection, GError **error) } static gboolean -get_secret_flags(NMSetting * setting, - const char * secret_name, +get_secret_flags(NMSetting *setting, + const char *secret_name, NMSettingSecretFlags *out_flags, - GError ** error) + GError **error) { NMSettingSecretFlags flags; @@ -1260,10 +1247,10 @@ get_secret_flags(NMSetting * setting, } static gboolean -set_secret_flags(NMSetting * setting, - const char * secret_name, +set_secret_flags(NMSetting *setting, + const char *secret_name, NMSettingSecretFlags flags, - GError ** error) + GError **error) { if (NM_IN_STRSET(secret_name, NM_SETTING_WIRELESS_SECURITY_WEP_KEY0, @@ -1310,19 +1297,10 @@ wep_key_type_to_dbus(_NM_SETT_INFO_PROP_TO_DBUS_FCN_ARGS _nm_nil) static void get_property(GObject *object, guint prop_id, GValue *value, GParamSpec *pspec) { - NMSettingWirelessSecurity * setting = NM_SETTING_WIRELESS_SECURITY(object); + NMSettingWirelessSecurity *setting = NM_SETTING_WIRELESS_SECURITY(object); NMSettingWirelessSecurityPrivate *priv = NM_SETTING_WIRELESS_SECURITY_GET_PRIVATE(setting); switch (prop_id) { - case PROP_KEY_MGMT: - g_value_set_string(value, priv->key_mgmt); - break; - case PROP_WEP_TX_KEYIDX: - g_value_set_uint(value, priv->wep_tx_keyidx); - break; - case PROP_AUTH_ALG: - g_value_set_string(value, priv->auth_alg); - break; case PROP_PROTO: g_value_take_boxed(value, _nm_utils_slist_to_strv(priv->proto, TRUE)); break; @@ -1332,50 +1310,11 @@ get_property(GObject *object, guint prop_id, GValue *value, GParamSpec *pspec) case PROP_GROUP: g_value_take_boxed(value, _nm_utils_slist_to_strv(priv->group, TRUE)); break; - case PROP_PMF: - g_value_set_int(value, nm_setting_wireless_security_get_pmf(setting)); - break; - case PROP_LEAP_USERNAME: - g_value_set_string(value, priv->leap_username); - break; - case PROP_WEP_KEY0: - g_value_set_string(value, priv->wep_key0); - break; - case PROP_WEP_KEY1: - g_value_set_string(value, priv->wep_key1); - break; - case PROP_WEP_KEY2: - g_value_set_string(value, priv->wep_key2); - break; - case PROP_WEP_KEY3: - g_value_set_string(value, priv->wep_key3); - break; - case PROP_WEP_KEY_FLAGS: - g_value_set_flags(value, priv->wep_key_flags); - break; - case PROP_PSK: - g_value_set_string(value, priv->psk); - break; - case PROP_PSK_FLAGS: - g_value_set_flags(value, priv->psk_flags); - break; - case PROP_LEAP_PASSWORD: - g_value_set_string(value, priv->leap_password); - break; - case PROP_LEAP_PASSWORD_FLAGS: - g_value_set_flags(value, priv->leap_password_flags); - break; case PROP_WEP_KEY_TYPE: g_value_set_enum(value, priv->wep_key_type); break; - case PROP_WPS_METHOD: - g_value_set_uint(value, priv->wps_method); - break; - case PROP_FILS: - g_value_set_int(value, nm_setting_wireless_security_get_fils(setting)); - break; default: - G_OBJECT_WARN_INVALID_PROPERTY_ID(object, prop_id, pspec); + _nm_setting_property_get_property_direct(object, prop_id, value, pspec); break; } } @@ -1383,24 +1322,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) { - NMSettingWirelessSecurity * setting = NM_SETTING_WIRELESS_SECURITY(object); + NMSettingWirelessSecurity *setting = NM_SETTING_WIRELESS_SECURITY(object); NMSettingWirelessSecurityPrivate *priv = NM_SETTING_WIRELESS_SECURITY_GET_PRIVATE(setting); - const char * str; switch (prop_id) { - case PROP_KEY_MGMT: - g_free(priv->key_mgmt); - str = g_value_get_string(value); - priv->key_mgmt = str ? g_ascii_strdown(str, -1) : NULL; - break; - case PROP_WEP_TX_KEYIDX: - priv->wep_tx_keyidx = g_value_get_uint(value); - break; - case PROP_AUTH_ALG: - g_free(priv->auth_alg); - str = g_value_get_string(value); - priv->auth_alg = str ? g_ascii_strdown(str, -1) : NULL; - break; case PROP_PROTO: g_slist_free_full(priv->proto, g_free); priv->proto = nm_strv_to_gslist(g_value_get_boxed(value), TRUE); @@ -1413,57 +1338,11 @@ set_property(GObject *object, guint prop_id, const GValue *value, GParamSpec *ps g_slist_free_full(priv->group, g_free); priv->group = nm_strv_to_gslist(g_value_get_boxed(value), TRUE); break; - case PROP_PMF: - priv->pmf = g_value_get_int(value); - break; - case PROP_LEAP_USERNAME: - g_free(priv->leap_username); - priv->leap_username = g_value_dup_string(value); - break; - case PROP_WEP_KEY0: - nm_free_secret(priv->wep_key0); - priv->wep_key0 = g_value_dup_string(value); - break; - case PROP_WEP_KEY1: - nm_free_secret(priv->wep_key1); - priv->wep_key1 = g_value_dup_string(value); - break; - case PROP_WEP_KEY2: - nm_free_secret(priv->wep_key2); - priv->wep_key2 = g_value_dup_string(value); - break; - case PROP_WEP_KEY3: - nm_free_secret(priv->wep_key3); - priv->wep_key3 = g_value_dup_string(value); - break; - case PROP_WEP_KEY_FLAGS: - priv->wep_key_flags = g_value_get_flags(value); - break; - case PROP_PSK: - nm_free_secret(priv->psk); - priv->psk = g_value_dup_string(value); - break; - case PROP_PSK_FLAGS: - priv->psk_flags = g_value_get_flags(value); - break; - case PROP_LEAP_PASSWORD: - nm_free_secret(priv->leap_password); - priv->leap_password = g_value_dup_string(value); - break; - case PROP_LEAP_PASSWORD_FLAGS: - priv->leap_password_flags = g_value_get_flags(value); - break; case PROP_WEP_KEY_TYPE: priv->wep_key_type = g_value_get_enum(value); break; - case PROP_WPS_METHOD: - priv->wps_method = g_value_get_uint(value); - break; - case PROP_FILS: - priv->fils = g_value_get_int(value); - break; default: - G_OBJECT_WARN_INVALID_PROPERTY_ID(object, prop_id, pspec); + _nm_setting_property_set_property_direct(object, prop_id, value, pspec); break; } } @@ -1475,8 +1354,6 @@ nm_setting_wireless_security_init(NMSettingWirelessSecurity *self) { nm_assert(NM_SETTING_WIRELESS_SECURITY_GET_PRIVATE(self)->wep_key_type == NM_WEP_KEY_TYPE_UNKNOWN); - nm_assert(NM_SETTING_WIRELESS_SECURITY_GET_PRIVATE(self)->wps_method - == NM_SETTING_WIRELESS_SECURITY_WPS_METHOD_DEFAULT); } /** @@ -1495,19 +1372,9 @@ nm_setting_wireless_security_new(void) static void finalize(GObject *object) { - NMSettingWirelessSecurity * self = NM_SETTING_WIRELESS_SECURITY(object); + NMSettingWirelessSecurity *self = NM_SETTING_WIRELESS_SECURITY(object); NMSettingWirelessSecurityPrivate *priv = NM_SETTING_WIRELESS_SECURITY_GET_PRIVATE(self); - g_free(priv->key_mgmt); - g_free(priv->auth_alg); - g_free(priv->leap_username); - nm_free_secret(priv->wep_key0); - nm_free_secret(priv->wep_key1); - nm_free_secret(priv->wep_key2); - nm_free_secret(priv->wep_key3); - nm_free_secret(priv->psk); - nm_free_secret(priv->leap_password); - g_slist_free_full(priv->proto, g_free); g_slist_free_full(priv->pairwise, g_free); g_slist_free_full(priv->group, g_free); @@ -1518,9 +1385,9 @@ finalize(GObject *object) static void nm_setting_wireless_security_class_init(NMSettingWirelessSecurityClass *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(NMSettingWirelessSecurityPrivate)); @@ -1552,12 +1419,14 @@ nm_setting_wireless_security_class_init(NMSettingWirelessSecurityClass *klass) * description: Key management method. * ---end--- */ - obj_properties[PROP_KEY_MGMT] = - g_param_spec_string(NM_SETTING_WIRELESS_SECURITY_KEY_MGMT, - "", - "", - NULL, - G_PARAM_READWRITE | NM_SETTING_PARAM_REQUIRED | G_PARAM_STATIC_STRINGS); + _nm_setting_property_define_direct_string(properties_override, + obj_properties, + NM_SETTING_WIRELESS_SECURITY_KEY_MGMT, + PROP_KEY_MGMT, + NM_SETTING_PARAM_REQUIRED, + NMSettingWirelessSecurityPrivate, + key_mgmt, + .direct_set_string_ascii_strdown = TRUE); /** * NMSettingWirelessSecurity:wep-tx-keyidx: @@ -1572,17 +1441,20 @@ nm_setting_wireless_security_class_init(NMSettingWirelessSecurityClass *klass) * variable: DEFAULTKEY * values: 1, 2, 3, 4 * default: 1 - * description: Index of active WEP key. + * description: Index of active WEP key. Note that in ifcfg format the index starts counting + * at 1, while NetworkManager API otherwise is zero based. * ---end--- */ - obj_properties[PROP_WEP_TX_KEYIDX] = - g_param_spec_uint(NM_SETTING_WIRELESS_SECURITY_WEP_TX_KEYIDX, - "", - "", - 0, - 3, - 0, - G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS); + _nm_setting_property_define_direct_uint32(properties_override, + obj_properties, + NM_SETTING_WIRELESS_SECURITY_WEP_TX_KEYIDX, + PROP_WEP_TX_KEYIDX, + 0, + 3, + 0, + NM_SETTING_PARAM_NONE, + NMSettingWirelessSecurityPrivate, + wep_tx_keyidx); /** * NMSettingWirelessSecurity:auth-alg: @@ -1600,11 +1472,14 @@ nm_setting_wireless_security_class_init(NMSettingWirelessSecurityClass *klass) * description: Authentication algorithm for WEP. * ---end--- */ - obj_properties[PROP_AUTH_ALG] = g_param_spec_string(NM_SETTING_WIRELESS_SECURITY_AUTH_ALG, - "", - "", - NULL, - G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS); + _nm_setting_property_define_direct_string(properties_override, + obj_properties, + NM_SETTING_WIRELESS_SECURITY_AUTH_ALG, + PROP_AUTH_ALG, + NM_SETTING_PARAM_NONE, + NMSettingWirelessSecurityPrivate, + auth_alg, + .direct_set_string_ascii_strdown = TRUE); /** * NMSettingWirelessSecurity:proto: @@ -1693,14 +1568,16 @@ nm_setting_wireless_security_class_init(NMSettingWirelessSecurityClass *klass) * example: PMF=required * ---end--- */ - obj_properties[PROP_PMF] = g_param_spec_int(NM_SETTING_WIRELESS_SECURITY_PMF, - "", - "", - G_MININT32, - G_MAXINT32, - 0, - G_PARAM_READWRITE | NM_SETTING_PARAM_FUZZY_IGNORE - | G_PARAM_STATIC_STRINGS); + _nm_setting_property_define_direct_int32(properties_override, + obj_properties, + NM_SETTING_WIRELESS_SECURITY_PMF, + PROP_PMF, + G_MININT32, + G_MAXINT32, + 0, + NM_SETTING_PARAM_FUZZY_IGNORE, + NMSettingWirelessSecurityPrivate, + pmf); /** * NMSettingWirelessSecurity:leap-username: @@ -1714,12 +1591,13 @@ nm_setting_wireless_security_class_init(NMSettingWirelessSecurityClass *klass) * description: Login name for LEAP. * ---end--- */ - obj_properties[PROP_LEAP_USERNAME] = - g_param_spec_string(NM_SETTING_WIRELESS_SECURITY_LEAP_USERNAME, - "", - "", - NULL, - G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS); + _nm_setting_property_define_direct_string(properties_override, + obj_properties, + NM_SETTING_WIRELESS_SECURITY_LEAP_USERNAME, + PROP_LEAP_USERNAME, + NM_SETTING_PARAM_NONE, + NMSettingWirelessSecurityPrivate, + leap_username); /** * NMSettingWirelessSecurity:wep-key0: @@ -1733,12 +1611,13 @@ nm_setting_wireless_security_class_init(NMSettingWirelessSecurityClass *klass) * description: The first WEP key (used in most networks). See also DEFAULTKEY for key index. * ---end--- */ - obj_properties[PROP_WEP_KEY0] = - g_param_spec_string(NM_SETTING_WIRELESS_SECURITY_WEP_KEY0, - "", - "", - NULL, - G_PARAM_READWRITE | NM_SETTING_PARAM_SECRET | G_PARAM_STATIC_STRINGS); + _nm_setting_property_define_direct_string(properties_override, + obj_properties, + NM_SETTING_WIRELESS_SECURITY_WEP_KEY0, + PROP_WEP_KEY0, + NM_SETTING_PARAM_SECRET, + NMSettingWirelessSecurityPrivate, + wep_key0); /** * NMSettingWirelessSecurity:wep-key1: @@ -1752,12 +1631,13 @@ nm_setting_wireless_security_class_init(NMSettingWirelessSecurityClass *klass) * description: WEP key with index 1. See also DEFAULTKEY for key index. * ---end--- */ - obj_properties[PROP_WEP_KEY1] = - g_param_spec_string(NM_SETTING_WIRELESS_SECURITY_WEP_KEY1, - "", - "", - NULL, - G_PARAM_READWRITE | NM_SETTING_PARAM_SECRET | G_PARAM_STATIC_STRINGS); + _nm_setting_property_define_direct_string(properties_override, + obj_properties, + NM_SETTING_WIRELESS_SECURITY_WEP_KEY1, + PROP_WEP_KEY1, + NM_SETTING_PARAM_SECRET, + NMSettingWirelessSecurityPrivate, + wep_key1); /** * NMSettingWirelessSecurity:wep-key2: @@ -1771,12 +1651,13 @@ nm_setting_wireless_security_class_init(NMSettingWirelessSecurityClass *klass) * description: WEP key with index 2. See also DEFAULTKEY for key index. * ---end--- */ - obj_properties[PROP_WEP_KEY2] = - g_param_spec_string(NM_SETTING_WIRELESS_SECURITY_WEP_KEY2, - "", - "", - NULL, - G_PARAM_READWRITE | NM_SETTING_PARAM_SECRET | G_PARAM_STATIC_STRINGS); + _nm_setting_property_define_direct_string(properties_override, + obj_properties, + NM_SETTING_WIRELESS_SECURITY_WEP_KEY2, + PROP_WEP_KEY2, + NM_SETTING_PARAM_SECRET, + NMSettingWirelessSecurityPrivate, + wep_key2); /** * NMSettingWirelessSecurity:wep-key3: @@ -1790,12 +1671,13 @@ nm_setting_wireless_security_class_init(NMSettingWirelessSecurityClass *klass) * description: WEP key with index 3. See also DEFAULTKEY for key index. * ---end--- */ - obj_properties[PROP_WEP_KEY3] = - g_param_spec_string(NM_SETTING_WIRELESS_SECURITY_WEP_KEY3, - "", - "", - NULL, - G_PARAM_READWRITE | NM_SETTING_PARAM_SECRET | G_PARAM_STATIC_STRINGS); + _nm_setting_property_define_direct_string(properties_override, + obj_properties, + NM_SETTING_WIRELESS_SECURITY_WEP_KEY3, + PROP_WEP_KEY3, + NM_SETTING_PARAM_SECRET, + NMSettingWirelessSecurityPrivate, + wep_key3); /** * NMSettingWirelessSecurity:wep-key-flags: @@ -1811,13 +1693,12 @@ nm_setting_wireless_security_class_init(NMSettingWirelessSecurityClass *klass) * description: Password flags for KEY<i>, KEY_PASSPHRASE<i> password. * ---end--- */ - obj_properties[PROP_WEP_KEY_FLAGS] = - g_param_spec_flags(NM_SETTING_WIRELESS_SECURITY_WEP_KEY_FLAGS, - "", - "", - NM_TYPE_SETTING_SECRET_FLAGS, - NM_SETTING_SECRET_FLAG_NONE, - G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS); + _nm_setting_property_define_direct_secret_flags(properties_override, + obj_properties, + NM_SETTING_WIRELESS_SECURITY_WEP_KEY_FLAGS, + PROP_WEP_KEY_FLAGS, + NMSettingWirelessSecurityPrivate, + wep_key_flags); /** * NMSettingWirelessSecurity:psk: @@ -1834,12 +1715,13 @@ nm_setting_wireless_security_class_init(NMSettingWirelessSecurityClass *klass) * description: Pre-Shared-Key for WPA networks. * ---end--- */ - obj_properties[PROP_PSK] = - g_param_spec_string(NM_SETTING_WIRELESS_SECURITY_PSK, - "", - "", - NULL, - G_PARAM_READWRITE | NM_SETTING_PARAM_SECRET | G_PARAM_STATIC_STRINGS); + _nm_setting_property_define_direct_string(properties_override, + obj_properties, + NM_SETTING_WIRELESS_SECURITY_PSK, + PROP_PSK, + NM_SETTING_PARAM_SECRET, + NMSettingWirelessSecurityPrivate, + psk); /** * NMSettingWirelessSecurity:psk-flags: @@ -1855,12 +1737,12 @@ nm_setting_wireless_security_class_init(NMSettingWirelessSecurityClass *klass) * example: WPA_PSK_FLAGS=user * ---end--- */ - obj_properties[PROP_PSK_FLAGS] = g_param_spec_flags(NM_SETTING_WIRELESS_SECURITY_PSK_FLAGS, - "", - "", - NM_TYPE_SETTING_SECRET_FLAGS, - NM_SETTING_SECRET_FLAG_NONE, - G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS); + _nm_setting_property_define_direct_secret_flags(properties_override, + obj_properties, + NM_SETTING_WIRELESS_SECURITY_PSK_FLAGS, + PROP_PSK_FLAGS, + NMSettingWirelessSecurityPrivate, + psk_flags); /** * NMSettingWirelessSecurity:leap-password: @@ -1875,12 +1757,13 @@ nm_setting_wireless_security_class_init(NMSettingWirelessSecurityClass *klass) * lookaside file, or it can be owned by a secret agent. * ---end--- */ - obj_properties[PROP_LEAP_PASSWORD] = - g_param_spec_string(NM_SETTING_WIRELESS_SECURITY_LEAP_PASSWORD, - "", - "", - NULL, - G_PARAM_READWRITE | NM_SETTING_PARAM_SECRET | G_PARAM_STATIC_STRINGS); + _nm_setting_property_define_direct_string(properties_override, + obj_properties, + NM_SETTING_WIRELESS_SECURITY_LEAP_PASSWORD, + PROP_LEAP_PASSWORD, + NM_SETTING_PARAM_SECRET, + NMSettingWirelessSecurityPrivate, + leap_password); /** * NMSettingWirelessSecurity:leap-password-flags: @@ -1895,13 +1778,13 @@ nm_setting_wireless_security_class_init(NMSettingWirelessSecurityClass *klass) * description: Password flags for IEEE_8021X_PASSWORD_FLAGS. * ---end--- */ - obj_properties[PROP_LEAP_PASSWORD_FLAGS] = - g_param_spec_flags(NM_SETTING_WIRELESS_SECURITY_LEAP_PASSWORD_FLAGS, - "", - "", - NM_TYPE_SETTING_SECRET_FLAGS, - NM_SETTING_SECRET_FLAG_NONE, - G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS); + _nm_setting_property_define_direct_secret_flags( + properties_override, + obj_properties, + NM_SETTING_WIRELESS_SECURITY_LEAP_PASSWORD_FLAGS, + PROP_LEAP_PASSWORD_FLAGS, + NMSettingWirelessSecurityPrivate, + leap_password_flags); /** * NMSettingWirelessSecurity:wep-key-type: @@ -1961,14 +1844,16 @@ nm_setting_wireless_security_class_init(NMSettingWirelessSecurityClass *klass) * example: WPS_METHOD=disabled, WPS_METHOD="pin pbc" * ---end--- */ - obj_properties[PROP_WPS_METHOD] = g_param_spec_uint( - NM_SETTING_WIRELESS_SECURITY_WPS_METHOD, - "", - "", - 0, - G_MAXUINT32, - NM_SETTING_WIRELESS_SECURITY_WPS_METHOD_DEFAULT, - G_PARAM_READWRITE | NM_SETTING_PARAM_FUZZY_IGNORE | G_PARAM_STATIC_STRINGS); + _nm_setting_property_define_direct_uint32(properties_override, + obj_properties, + NM_SETTING_WIRELESS_SECURITY_WPS_METHOD, + PROP_WPS_METHOD, + 0, + G_MAXUINT32, + NM_SETTING_WIRELESS_SECURITY_WPS_METHOD_DEFAULT, + NM_SETTING_PARAM_FUZZY_IGNORE, + NMSettingWirelessSecurityPrivate, + wps_method); /** * NMSettingWirelessSecurity:fils: @@ -1992,14 +1877,16 @@ nm_setting_wireless_security_class_init(NMSettingWirelessSecurityClass *klass) * example: FILS=required * ---end--- */ - obj_properties[PROP_FILS] = g_param_spec_int(NM_SETTING_WIRELESS_SECURITY_FILS, - "", - "", - G_MININT32, - G_MAXINT32, - 0, - G_PARAM_READWRITE | NM_SETTING_PARAM_FUZZY_IGNORE - | G_PARAM_STATIC_STRINGS); + _nm_setting_property_define_direct_int32(properties_override, + obj_properties, + NM_SETTING_WIRELESS_SECURITY_FILS, + PROP_FILS, + G_MININT32, + G_MAXINT32, + 0, + NM_SETTING_PARAM_FUZZY_IGNORE, + NMSettingWirelessSecurityPrivate, + fils); g_object_class_install_properties(object_class, _PROPERTY_ENUMS_LAST, obj_properties); diff --git a/src/libnm-core-impl/nm-setting-wireless.c b/src/libnm-core-impl/nm-setting-wireless.c index f5a4cb6a..8f57f69b 100644 --- a/src/libnm-core-impl/nm-setting-wireless.c +++ b/src/libnm-core-impl/nm-setting-wireless.c @@ -46,24 +46,24 @@ NM_GOBJECT_PROPERTIES_DEFINE(NMSettingWireless, PROP_AP_ISOLATION, ); typedef struct { - GBytes * ssid; - GArray * mac_address_blacklist; - GPtrArray * seen_bssids; - char * mode; - char * band; - char * bssid; - char * device_mac_address; - char * cloned_mac_address; - char * generate_mac_address_mask; - NMSettingMacRandomization mac_address_randomization; - NMTernary ap_isolation; - guint32 channel; - guint32 rate; - guint32 tx_power; - guint32 mtu; - guint32 powersave; - guint32 wowl; - bool hidden; + GBytes *ssid; + GArray *mac_address_blacklist; + GPtrArray *seen_bssids; + char *mode; + char *band; + char *bssid; + char *device_mac_address; + char *cloned_mac_address; + char *generate_mac_address_mask; + int ap_isolation; + guint32 mac_address_randomization; + guint32 channel; + guint32 rate; + guint32 tx_power; + guint32 mtu; + guint32 powersave; + guint32 wake_on_wlan; + bool hidden; } NMSettingWirelessPrivate; /** @@ -127,7 +127,7 @@ match_cipher(const char *cipher, * security flags and mode, %FALSE if they are not. */ gboolean -nm_setting_wireless_ap_security_compatible(NMSettingWireless * s_wireless, +nm_setting_wireless_ap_security_compatible(NMSettingWireless *s_wireless, NMSettingWirelessSecurity *s_wireless_sec, NM80211ApFlags ap_flags, NM80211ApSecurityFlags ap_wpa, @@ -300,6 +300,16 @@ nm_setting_wireless_ap_security_compatible(NMSettingWireless * s_wireless return TRUE; } + /* WPA3 Enterprise Suite B 192 */ + if (!strcmp(key_mgmt, "wpa-eap-suite-b-192")) { + if (!(ap_rsn & NM_802_11_AP_SEC_KEY_MGMT_EAP_SUITE_B_192)) { + return FALSE; + } + + /* Since NetworkManager doesn't handle GCMP-256 directly, cipher check can be skipped */ + return TRUE; + } + return FALSE; } @@ -511,7 +521,7 @@ gboolean nm_setting_wireless_add_mac_blacklist_item(NMSettingWireless *setting, const char *mac) { NMSettingWirelessPrivate *priv; - const char * candidate; + const char *candidate; int i; g_return_val_if_fail(NM_IS_SETTING_WIRELESS(setting), FALSE); @@ -568,7 +578,7 @@ gboolean nm_setting_wireless_remove_mac_blacklist_item_by_value(NMSettingWireless *setting, const char *mac) { NMSettingWirelessPrivate *priv; - const char * candidate; + const char *candidate; int i; g_return_val_if_fail(NM_IS_SETTING_WIRELESS(setting), FALSE); @@ -678,7 +688,7 @@ gboolean nm_setting_wireless_add_seen_bssid(NMSettingWireless *setting, const char *bssid) { NMSettingWirelessPrivate *priv; - gs_free char * lower_bssid = NULL; + gs_free char *lower_bssid = NULL; g_return_val_if_fail(NM_IS_SETTING_WIRELESS(setting), FALSE); g_return_val_if_fail(bssid != NULL, FALSE); @@ -764,7 +774,7 @@ static gboolean _from_dbus_fcn_seen_bssids(_NM_SETT_INFO_PROP_FROM_DBUS_FCN_ARGS _nm_nil) { NMSettingWirelessPrivate *priv; - gs_free const char ** s = NULL; + gs_free const char **s = NULL; gsize len; gsize i; @@ -810,15 +820,15 @@ static gboolean verify(NMSetting *setting, NMConnection *connection, GError **error) { NMSettingWirelessPrivate *priv = NM_SETTING_WIRELESS_GET_PRIVATE(setting); - const char * valid_modes[] = {NM_SETTING_WIRELESS_MODE_INFRA, + const char *valid_modes[] = {NM_SETTING_WIRELESS_MODE_INFRA, NM_SETTING_WIRELESS_MODE_ADHOC, NM_SETTING_WIRELESS_MODE_AP, NM_SETTING_WIRELESS_MODE_MESH, NULL}; - const char * valid_bands[] = {"a", "bg", NULL}; + const char *valid_bands[] = {"a", "bg", NULL}; guint i; gsize length; - GError * local = NULL; + GError *local = NULL; if (!priv->ssid) { g_set_error_literal(error, @@ -1025,8 +1035,8 @@ verify(NMSetting *setting, NMConnection *connection, GError **error) return FALSE; } - if (NM_FLAGS_ANY(priv->wowl, NM_SETTING_WIRELESS_WAKE_ON_WLAN_EXCLUSIVE_FLAGS)) { - if (!nm_utils_is_power_of_two(priv->wowl)) { + if (NM_FLAGS_ANY(priv->wake_on_wlan, NM_SETTING_WIRELESS_WAKE_ON_WLAN_EXCLUSIVE_FLAGS)) { + if (!nm_utils_is_power_of_two(priv->wake_on_wlan)) { g_set_error_literal(error, NM_CONNECTION_ERROR, NM_CONNECTION_ERROR_INVALID_PROPERTY, @@ -1037,7 +1047,7 @@ verify(NMSetting *setting, NMConnection *connection, GError **error) NM_SETTING_WIRELESS_WAKE_ON_WLAN); return FALSE; } - } else if (NM_FLAGS_ANY(priv->wowl, ~NM_SETTING_WIRELESS_WAKE_ON_WLAN_ALL)) { + } else if (NM_FLAGS_ANY(priv->wake_on_wlan, ~NM_SETTING_WIRELESS_WAKE_ON_WLAN_ALL)) { g_set_error_literal(error, NM_CONNECTION_ERROR, NM_CONNECTION_ERROR_INVALID_PROPERTY, @@ -1138,7 +1148,7 @@ nm_setting_wireless_get_wake_on_wlan(NMSettingWireless *setting) { g_return_val_if_fail(NM_IS_SETTING_WIRELESS(setting), NM_SETTING_WIRELESS_WAKE_ON_WLAN_NONE); - return NM_SETTING_WIRELESS_GET_PRIVATE(setting)->wowl; + return NM_SETTING_WIRELESS_GET_PRIVATE(setting)->wake_on_wlan; } static void @@ -1152,37 +1162,16 @@ clear_blacklist_item(char **item_p) static void get_property(GObject *object, guint prop_id, GValue *value, GParamSpec *pspec) { - NMSettingWireless * setting = NM_SETTING_WIRELESS(object); + NMSettingWireless *setting = NM_SETTING_WIRELESS(object); NMSettingWirelessPrivate *priv = NM_SETTING_WIRELESS_GET_PRIVATE(object); switch (prop_id) { - case PROP_MODE: - g_value_set_string(value, nm_setting_wireless_get_mode(setting)); - break; - case PROP_BAND: - g_value_set_string(value, nm_setting_wireless_get_band(setting)); - break; - case PROP_CHANNEL: - g_value_set_uint(value, nm_setting_wireless_get_channel(setting)); - break; - case PROP_RATE: - g_value_set_uint(value, nm_setting_wireless_get_rate(setting)); - break; - case PROP_TX_POWER: - g_value_set_uint(value, nm_setting_wireless_get_tx_power(setting)); - break; case PROP_CLONED_MAC_ADDRESS: g_value_set_string(value, nm_setting_wireless_get_cloned_mac_address(setting)); break; - case PROP_GENERATE_MAC_ADDRESS_MASK: - g_value_set_string(value, nm_setting_wireless_get_generate_mac_address_mask(setting)); - break; case PROP_MAC_ADDRESS_BLACKLIST: g_value_set_boxed(value, (char **) priv->mac_address_blacklist->data); break; - case PROP_MTU: - g_value_set_uint(value, nm_setting_wireless_get_mtu(setting)); - break; case PROP_SEEN_BSSIDS: g_value_take_boxed( value, @@ -1190,18 +1179,6 @@ get_property(GObject *object, guint prop_id, GValue *value, GParamSpec *pspec) ? nm_strv_dup((char **) priv->seen_bssids->pdata, priv->seen_bssids->len, TRUE) : NULL); break; - case PROP_POWERSAVE: - g_value_set_uint(value, nm_setting_wireless_get_powersave(setting)); - break; - case PROP_MAC_ADDRESS_RANDOMIZATION: - g_value_set_uint(value, nm_setting_wireless_get_mac_address_randomization(setting)); - break; - case PROP_WAKE_ON_WLAN: - g_value_set_uint(value, nm_setting_wireless_get_wake_on_wlan(setting)); - break; - case PROP_AP_ISOLATION: - g_value_set_enum(value, priv->ap_isolation); - break; default: _nm_setting_property_get_property_direct(object, prop_id, value, pspec); break; @@ -1212,28 +1189,11 @@ static void set_property(GObject *object, guint prop_id, const GValue *value, GParamSpec *pspec) { NMSettingWirelessPrivate *priv = NM_SETTING_WIRELESS_GET_PRIVATE(object); - const char *const * blacklist; - const char * mac; + const char *const *blacklist; + const char *mac; gboolean bool_val; switch (prop_id) { - case PROP_MODE: - g_free(priv->mode); - priv->mode = g_value_dup_string(value); - break; - case PROP_BAND: - g_free(priv->band); - priv->band = g_value_dup_string(value); - break; - case PROP_CHANNEL: - priv->channel = g_value_get_uint(value); - break; - case PROP_RATE: - priv->rate = g_value_get_uint(value); - break; - case PROP_TX_POWER: - priv->tx_power = g_value_get_uint(value); - break; case PROP_CLONED_MAC_ADDRESS: bool_val = !!priv->cloned_mac_address; g_free(priv->cloned_mac_address); @@ -1248,10 +1208,6 @@ set_property(GObject *object, guint prop_id, const GValue *value, GParamSpec *ps } } break; - case PROP_GENERATE_MAC_ADDRESS_MASK: - g_free(priv->generate_mac_address_mask); - priv->generate_mac_address_mask = g_value_dup_string(value); - break; case PROP_MAC_ADDRESS_BLACKLIST: blacklist = g_value_get_boxed(value); g_array_set_size(priv->mac_address_blacklist, 0); @@ -1264,13 +1220,10 @@ set_property(GObject *object, guint prop_id, const GValue *value, GParamSpec *ps } } break; - case PROP_MTU: - priv->mtu = g_value_get_uint(value); - break; case PROP_SEEN_BSSIDS: { gs_unref_ptrarray GPtrArray *arr_old = NULL; - const char *const * strv; + const char *const *strv; arr_old = g_steal_pointer(&priv->seen_bssids); @@ -1285,18 +1238,6 @@ set_property(GObject *object, guint prop_id, const GValue *value, GParamSpec *ps } break; } - case PROP_POWERSAVE: - priv->powersave = g_value_get_uint(value); - break; - case PROP_MAC_ADDRESS_RANDOMIZATION: - priv->mac_address_randomization = g_value_get_uint(value); - break; - case PROP_WAKE_ON_WLAN: - priv->wowl = g_value_get_uint(value); - break; - case PROP_AP_ISOLATION: - priv->ap_isolation = g_value_get_enum(value); - break; default: _nm_setting_property_set_property_direct(object, prop_id, value, pspec); break; @@ -1313,9 +1254,6 @@ nm_setting_wireless_init(NMSettingWireless *setting) /* We use GArray rather than GPtrArray so it will automatically be NULL-terminated */ priv->mac_address_blacklist = g_array_new(TRUE, FALSE, sizeof(char *)); g_array_set_clear_func(priv->mac_address_blacklist, (GDestroyNotify) clear_blacklist_item); - - priv->wowl = NM_SETTING_WIRELESS_WAKE_ON_WLAN_DEFAULT; - priv->ap_isolation = NM_TERNARY_DEFAULT; } /** @@ -1336,13 +1274,9 @@ finalize(GObject *object) { NMSettingWirelessPrivate *priv = NM_SETTING_WIRELESS_GET_PRIVATE(object); - g_free(priv->mode); - g_free(priv->band); - g_free(priv->cloned_mac_address); - g_free(priv->generate_mac_address_mask); g_array_unref(priv->mac_address_blacklist); - nm_clear_pointer(&priv->seen_bssids, g_ptr_array_unref); + nm_g_ptr_array_unref(priv->seen_bssids); G_OBJECT_CLASS(nm_setting_wireless_parent_class)->finalize(object); } @@ -1350,9 +1284,9 @@ finalize(GObject *object) static void nm_setting_wireless_class_init(NMSettingWirelessClass *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(NMSettingWirelessPrivate)); @@ -1401,11 +1335,13 @@ nm_setting_wireless_class_init(NMSettingWirelessClass *klass) * description: Wi-Fi network mode. * ---end--- */ - obj_properties[PROP_MODE] = g_param_spec_string(NM_SETTING_WIRELESS_MODE, - "", - "", - NULL, - G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS); + _nm_setting_property_define_direct_string(properties_override, + obj_properties, + NM_SETTING_WIRELESS_MODE, + PROP_MODE, + NM_SETTING_PARAM_NONE, + NMSettingWirelessPrivate, + mode); /** * NMSettingWireless:band: @@ -1426,11 +1362,13 @@ nm_setting_wireless_class_init(NMSettingWirelessClass *klass) * example: BAND=bg * ---end--- */ - obj_properties[PROP_BAND] = g_param_spec_string(NM_SETTING_WIRELESS_BAND, - "", - "", - NULL, - G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS); + _nm_setting_property_define_direct_string(properties_override, + obj_properties, + NM_SETTING_WIRELESS_BAND, + PROP_BAND, + NM_SETTING_PARAM_NONE, + NMSettingWirelessPrivate, + band); /** * NMSettingWireless:channel: @@ -1449,13 +1387,16 @@ nm_setting_wireless_class_init(NMSettingWirelessClass *klass) * example: CHANNEL=6 * ---end--- */ - obj_properties[PROP_CHANNEL] = g_param_spec_uint(NM_SETTING_WIRELESS_CHANNEL, - "", - "", - 0, - G_MAXUINT32, - 0, - G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS); + _nm_setting_property_define_direct_uint32(properties_override, + obj_properties, + NM_SETTING_WIRELESS_CHANNEL, + PROP_CHANNEL, + 0, + G_MAXUINT32, + 0, + NM_SETTING_PARAM_NONE, + NMSettingWirelessPrivate, + channel); /** * NMSettingWireless:bssid: @@ -1495,14 +1436,16 @@ nm_setting_wireless_class_init(NMSettingWirelessClass *klass) * description: This property is not handled by ifcfg-rh plugin. * ---end--- */ - obj_properties[PROP_RATE] = g_param_spec_uint(NM_SETTING_WIRELESS_RATE, - "", - "", - 0, - G_MAXUINT32, - 0, - G_PARAM_READWRITE | NM_SETTING_PARAM_FUZZY_IGNORE - | G_PARAM_STATIC_STRINGS); + _nm_setting_property_define_direct_uint32(properties_override, + obj_properties, + NM_SETTING_WIRELESS_RATE, + PROP_RATE, + 0, + G_MAXUINT32, + 0, + NM_SETTING_PARAM_FUZZY_IGNORE, + NMSettingWirelessPrivate, + rate); /** * NMSettingWireless:tx-power: @@ -1517,14 +1460,16 @@ nm_setting_wireless_class_init(NMSettingWirelessClass *klass) * description: This property is not handled by ifcfg-rh plugin. * ---end--- */ - obj_properties[PROP_TX_POWER] = g_param_spec_uint( - NM_SETTING_WIRELESS_TX_POWER, - "", - "", - 0, - G_MAXUINT32, - 0, - G_PARAM_READWRITE | NM_SETTING_PARAM_FUZZY_IGNORE | G_PARAM_STATIC_STRINGS); + _nm_setting_property_define_direct_uint32(properties_override, + obj_properties, + NM_SETTING_WIRELESS_TX_POWER, + PROP_TX_POWER, + 0, + G_MAXUINT32, + 0, + NM_SETTING_PARAM_FUZZY_IGNORE, + NMSettingWirelessPrivate, + tx_power); /** * NMSettingWireless:mac-address: @@ -1671,12 +1616,13 @@ nm_setting_wireless_class_init(NMSettingWirelessClass *klass) * cloned-mac-address. * ---end--- */ - obj_properties[PROP_GENERATE_MAC_ADDRESS_MASK] = g_param_spec_string( - NM_SETTING_WIRELESS_GENERATE_MAC_ADDRESS_MASK, - "", - "", - NULL, - G_PARAM_READWRITE | NM_SETTING_PARAM_FUZZY_IGNORE | G_PARAM_STATIC_STRINGS); + _nm_setting_property_define_direct_string(properties_override, + obj_properties, + NM_SETTING_WIRELESS_GENERATE_MAC_ADDRESS_MASK, + PROP_GENERATE_MAC_ADDRESS_MASK, + NM_SETTING_PARAM_FUZZY_IGNORE, + NMSettingWirelessPrivate, + generate_mac_address_mask); /** * NMSettingWireless:mac-address-blacklist: @@ -1747,14 +1693,16 @@ nm_setting_wireless_class_init(NMSettingWirelessClass *klass) * description: MTU of the wireless interface. * ---end--- */ - obj_properties[PROP_MTU] = g_param_spec_uint(NM_SETTING_WIRELESS_MTU, - "", - "", - 0, - G_MAXUINT32, - 0, - G_PARAM_READWRITE | NM_SETTING_PARAM_FUZZY_IGNORE - | G_PARAM_STATIC_STRINGS); + _nm_setting_property_define_direct_uint32(properties_override, + obj_properties, + NM_SETTING_WIRELESS_MTU, + PROP_MTU, + 0, + G_MAXUINT32, + 0, + NM_SETTING_PARAM_FUZZY_IGNORE, + NMSettingWirelessPrivate, + mtu); /** * NMSettingWireless:hidden: @@ -1808,13 +1756,16 @@ nm_setting_wireless_class_init(NMSettingWirelessClass *klass) * example: POWERSAVE=enable * ---end--- */ - obj_properties[PROP_POWERSAVE] = g_param_spec_uint(NM_SETTING_WIRELESS_POWERSAVE, - "", - "", - 0, - G_MAXUINT32, - NM_SETTING_WIRELESS_POWERSAVE_DEFAULT, - G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS); + _nm_setting_property_define_direct_uint32(properties_override, + obj_properties, + NM_SETTING_WIRELESS_POWERSAVE, + PROP_POWERSAVE, + 0, + G_MAXUINT32, + NM_SETTING_WIRELESS_POWERSAVE_DEFAULT, + NM_SETTING_PARAM_NONE, + NMSettingWirelessPrivate, + powersave); /** * NMSettingWireless:mac-address-randomization: @@ -1837,14 +1788,16 @@ nm_setting_wireless_class_init(NMSettingWirelessClass *klass) * example: MAC_ADDRESS_RANDOMIZATION=always * ---end--- */ - obj_properties[PROP_MAC_ADDRESS_RANDOMIZATION] = - g_param_spec_uint(NM_SETTING_WIRELESS_MAC_ADDRESS_RANDOMIZATION, - "", - "", - 0, - G_MAXUINT32, - NM_SETTING_MAC_RANDOMIZATION_DEFAULT, - G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS); + _nm_setting_property_define_direct_uint32(properties_override, + obj_properties, + NM_SETTING_WIRELESS_MAC_ADDRESS_RANDOMIZATION, + PROP_MAC_ADDRESS_RANDOMIZATION, + 0, + G_MAXUINT32, + NM_SETTING_MAC_RANDOMIZATION_DEFAULT, + NM_SETTING_PARAM_NONE, + NMSettingWirelessPrivate, + mac_address_randomization); /* Compatibility for deprecated property */ /* ---ifcfg-rh--- @@ -1885,14 +1838,16 @@ nm_setting_wireless_class_init(NMSettingWirelessClass *klass) * * Since: 1.12 **/ - obj_properties[PROP_WAKE_ON_WLAN] = - g_param_spec_uint(NM_SETTING_WIRELESS_WAKE_ON_WLAN, - "", - "", - 0, - G_MAXUINT32, - NM_SETTING_WIRELESS_WAKE_ON_WLAN_DEFAULT, - G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS); + _nm_setting_property_define_direct_uint32(properties_override, + obj_properties, + NM_SETTING_WIRELESS_WAKE_ON_WLAN, + PROP_WAKE_ON_WLAN, + 0, + G_MAXUINT32, + NM_SETTING_WIRELESS_WAKE_ON_WLAN_DEFAULT, + NM_SETTING_PARAM_NONE, + NMSettingWirelessPrivate, + wake_on_wlan); /** * NMSettingWireless:ap-isolation @@ -1924,13 +1879,13 @@ nm_setting_wireless_class_init(NMSettingWirelessClass *klass) * description: Whether AP isolation is enabled * ---end--- */ - obj_properties[PROP_AP_ISOLATION] = g_param_spec_enum( - NM_SETTING_WIRELESS_AP_ISOLATION, - "", - "", - NM_TYPE_TERNARY, - NM_TERNARY_DEFAULT, - NM_SETTING_PARAM_FUZZY_IGNORE | G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS); + _nm_setting_property_define_direct_ternary_enum(properties_override, + obj_properties, + NM_SETTING_WIRELESS_AP_ISOLATION, + PROP_AP_ISOLATION, + NM_SETTING_PARAM_FUZZY_IGNORE, + NMSettingWirelessPrivate, + ap_isolation); g_object_class_install_properties(object_class, _PROPERTY_ENUMS_LAST, obj_properties); diff --git a/src/libnm-core-impl/nm-setting-wpan.c b/src/libnm-core-impl/nm-setting-wpan.c index 78cdc036..9e25dd16 100644 --- a/src/libnm-core-impl/nm-setting-wpan.c +++ b/src/libnm-core-impl/nm-setting-wpan.c @@ -42,7 +42,7 @@ NM_GOBJECT_PROPERTIES_DEFINE_BASE(PROP_MAC_ADDRESS, PROP_CHANNEL, ); typedef struct { - char * mac_address; + char *mac_address; guint32 pan_id; guint32 short_address; gint32 page; @@ -222,9 +222,9 @@ nm_setting_wpan_new(void) static void nm_setting_wpan_class_init(NMSettingWpanClass *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(setting_class, sizeof(NMSettingWpanPrivate)); diff --git a/src/libnm-core-impl/nm-setting.c b/src/libnm-core-impl/nm-setting.c index 9ef9e96c..be88effb 100644 --- a/src/libnm-core-impl/nm-setting.c +++ b/src/libnm-core-impl/nm-setting.c @@ -8,11 +8,13 @@ #include "nm-setting.h" -#include "nm-setting-private.h" -#include "nm-utils.h" #include "libnm-core-intern/nm-core-internal.h" -#include "nm-utils-private.h" +#include "libnm-glib-aux/nm-ref-string.h" +#include "libnm-glib-aux/nm-secret-utils.h" #include "nm-property-compare.h" +#include "nm-setting-private.h" +#include "nm-utils-private.h" +#include "nm-utils.h" /** * SECTION:nm-setting @@ -29,13 +31,13 @@ /*****************************************************************************/ typedef struct { - GHashTable * hash; + GHashTable *hash; const char **names; - GVariant ** values; + GVariant **values; } GenData; typedef struct { - const char * name; + const char *name; GType type; NMSettingPriority priority; } SettingInfo; @@ -55,8 +57,8 @@ G_DEFINE_ABSTRACT_TYPE(NMSetting, nm_setting, G_TYPE_OBJECT) static GenData *_gendata_hash(NMSetting *setting, gboolean create_if_necessary); static gboolean set_property_from_dbus(const NMSettInfoProperty *property_info, - GVariant * src_value, - GValue * dst_value); + GVariant *src_value, + GValue *dst_value); /*****************************************************************************/ @@ -148,7 +150,7 @@ _nm_setting_slave_type_is_valid(const char *slave_type, const char **out_port_ty static const NMSettInfoProperty * _nm_sett_info_property_find_in_array(const NMSettInfoProperty *properties, guint len, - const char * name) + const char *name) { guint i; @@ -234,7 +236,7 @@ _property_infos_sort_cmp_setting_connection(gconstpointer p_a, static const NMSettInfoProperty *const * _property_infos_sort(const NMSettInfoProperty *property_infos, guint16 property_infos_len, - NMSettingClass * setting_class) + NMSettingClass *setting_class) { const NMSettInfoProperty **arr; guint16 i; @@ -280,14 +282,14 @@ _property_lookup_by_param_spec_sort(gconstpointer p_a, gconstpointer p_b, gpoint } void -_nm_setting_class_commit(NMSettingClass * setting_class, +_nm_setting_class_commit(NMSettingClass *setting_class, NMMetaSettingType meta_type, const NMSettInfoSettDetail *detail, - GArray * properties_override, + GArray *properties_override, gint16 private_offset) { - NMSettInfoSetting *sett_info; - gs_free GParamSpec ** property_specs = NULL; + NMSettInfoSetting *sett_info; + gs_free GParamSpec **property_specs = NULL; guint n_property_specs; NMSettInfoPropertLookupByParamSpec *lookup_by_iter; guint override_len; @@ -350,7 +352,7 @@ _nm_setting_class_commit(NMSettingClass * setting_class, #endif for (i = 0; i < n_property_specs; i++) { - const char * name = property_specs[i]->name; + const char *name = property_specs[i]->name; NMSettInfoProperty *p; if (_nm_sett_info_property_find_in_array((NMSettInfoProperty *) properties_override->data, @@ -375,55 +377,27 @@ _nm_setting_class_commit(NMSettingClass * setting_class, nm_assert(p->param_spec); vtype = p->param_spec->value_type; - if (vtype == G_TYPE_INT) - p->property_type = &nm_sett_info_propert_type_plain_i; - else if (vtype == G_TYPE_UINT) - p->property_type = &nm_sett_info_propert_type_plain_u; - else if (vtype == G_TYPE_INT64) - p->property_type = NM_SETT_INFO_PROPERT_TYPE_GPROP( - G_VARIANT_TYPE_INT64, - .compare_fcn = _nm_setting_property_compare_fcn_default, - .from_dbus_fcn = _nm_setting_property_from_dbus_fcn_gprop, - .from_dbus_is_full = TRUE); - else if (vtype == G_TYPE_STRING) { - nm_assert(nm_streq(p->name, NM_SETTING_NAME) - == (!NM_FLAGS_HAS(p->param_spec->flags, G_PARAM_WRITABLE))); - if (!NM_FLAGS_HAS(p->param_spec->flags, G_PARAM_WRITABLE)) - p->property_type = &nm_sett_info_propert_type_setting_name; - else { - p->property_type = NM_SETT_INFO_PROPERT_TYPE_GPROP( - G_VARIANT_TYPE_STRING, - .compare_fcn = _nm_setting_property_compare_fcn_default, - .from_dbus_fcn = _nm_setting_property_from_dbus_fcn_gprop, - .from_dbus_is_full = TRUE); - } - } else if (vtype == G_TYPE_DOUBLE) - p->property_type = NM_SETT_INFO_PROPERT_TYPE_GPROP( - G_VARIANT_TYPE_DOUBLE, - .compare_fcn = _nm_setting_property_compare_fcn_default, - .from_dbus_fcn = _nm_setting_property_from_dbus_fcn_gprop, - .from_dbus_is_full = TRUE); - else if (vtype == G_TYPE_STRV) + + 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 if (g_type_is_a(vtype, G_TYPE_ENUM)) { - p->property_type = NM_SETT_INFO_PROPERT_TYPE_GPROP( - G_VARIANT_TYPE_INT32, - .typdata_to_dbus.gprop_type = NM_SETTING_PROPERTY_TO_DBUS_FCN_GPROP_TYPE_ENUM, - .compare_fcn = _nm_setting_property_compare_fcn_default, - .from_dbus_fcn = _nm_setting_property_from_dbus_fcn_gprop, - .from_dbus_is_full = TRUE); - } else if (g_type_is_a(vtype, G_TYPE_FLAGS)) { - p->property_type = NM_SETT_INFO_PROPERT_TYPE_GPROP( - G_VARIANT_TYPE_UINT32, - .typdata_to_dbus.gprop_type = NM_SETTING_PROPERTY_TO_DBUS_FCN_GPROP_TYPE_FLAGS, - .compare_fcn = _nm_setting_property_compare_fcn_default, - .from_dbus_fcn = _nm_setting_property_from_dbus_fcn_gprop, - .from_dbus_is_full = TRUE); - } else + else nm_assert_not_reached(); has_property_type: @@ -493,7 +467,7 @@ has_property_type: const NMSettInfoProperty * _nm_sett_info_setting_get_property_info(const NMSettInfoSetting *sett_info, - const char * property_name) + const char *property_name) { const NMSettInfoProperty *property_info; gssize idx; @@ -539,7 +513,7 @@ _nm_setting_class_get_sett_info(NMSettingClass *setting_class) const NMSettInfoProperty * _nm_sett_info_property_lookup_by_param_spec(const NMSettInfoSetting *sett_info, - const GParamSpec * param_spec) + const GParamSpec *param_spec) { NMSettInfoPropertLookupByParamSpec needle; int imin; @@ -610,8 +584,8 @@ _nm_setting_emit_property_changed(NMSetting *setting) /*****************************************************************************/ gboolean -_nm_setting_use_legacy_property(NMSetting * setting, - GVariant * connection_dict, +_nm_setting_use_legacy_property(NMSetting *setting, + GVariant *connection_dict, const char *legacy_property, const char *new_property) { @@ -656,33 +630,74 @@ _nm_setting_use_legacy_property(NMSetting * setting, /*****************************************************************************/ static gboolean -_property_direct_set_string(const NMSettInfoProperty *property_info, char **dst, const char *src) +_property_direct_set_string(const NMSettInfoSetting *sett_info, + const NMSettInfoProperty *property_info, + NMSetting *setting, + const char *src) { - if (property_info->direct_set_string_ascii_strdown) - return nm_strdup_reset_take(dst, src ? g_ascii_strdown(src, -1) : NULL); + char **dst; + char *s; + + nm_assert(property_info->property_type->direct_type == NM_VALUE_TYPE_STRING); + nm_assert(((!!property_info->direct_set_string_ascii_strdown) + + (!!property_info->direct_set_string_strip) + + (!!property_info->direct_string_is_refstr) + + (property_info->direct_set_string_mac_address_len > 0) + + (property_info->direct_set_string_ip_address_addr_family != 0)) + <= (property_info->direct_hook.set_string_fcn ? 0 : 1)); + + if (property_info->direct_hook.set_string_fcn) { + return property_info->direct_hook.set_string_fcn(sett_info, property_info, setting, src); + } + + dst = _nm_setting_get_private_field(setting, sett_info, property_info); + + if (property_info->direct_string_is_refstr) { + nm_assert(property_info->param_spec); + nm_assert(!NM_FLAGS_HAS(property_info->param_spec->flags, NM_SETTING_PARAM_SECRET)); + return nm_ref_string_reset_str_upcast((const char **) dst, src); + } + + if (property_info->direct_set_string_ascii_strdown) { + s = src ? g_ascii_strdown(src, -1) : NULL; + goto out_take; + } + if (property_info->direct_set_string_strip) { + s = nm_strstrip_dup(src); + goto out_take; + } if (property_info->direct_set_string_mac_address_len > 0) { - return nm_strdup_reset_take(dst, - _nm_utils_hwaddr_canonical_or_invalid( - src, - property_info->direct_set_string_mac_address_len)); + s = _nm_utils_hwaddr_canonical_or_invalid(src, + property_info->direct_set_string_mac_address_len); + goto out_take; } if (property_info->direct_set_string_ip_address_addr_family != 0) { - return nm_strdup_reset_take(dst, - _nm_utils_ipaddr_canonical_or_invalid( - property_info->direct_set_string_ip_address_addr_family, - src)); - } + s = _nm_utils_ipaddr_canonical_or_invalid( + property_info->direct_set_string_ip_address_addr_family - 1, + src, + property_info->direct_set_string_ip_address_addr_family_map_zero_to_null); + goto out_take; + } else + nm_assert(!property_info->direct_set_string_ip_address_addr_family_map_zero_to_null); + + if (NM_FLAGS_HAS(property_info->param_spec->flags, NM_SETTING_PARAM_SECRET)) + return nm_strdup_reset_secret(dst, src); + return nm_strdup_reset(dst, src); + +out_take: + nm_assert(!NM_FLAGS_HAS(property_info->param_spec->flags, NM_SETTING_PARAM_SECRET)); + return nm_strdup_reset_take(dst, s); } void -_nm_setting_property_get_property_direct(GObject * object, +_nm_setting_property_get_property_direct(GObject *object, guint prop_id, - GValue * value, + GValue *value, GParamSpec *pspec) { - NMSetting * setting = NM_SETTING(object); - const NMSettInfoSetting * sett_info; + NMSetting *setting = NM_SETTING(object); + const NMSettInfoSetting *sett_info; const NMSettInfoProperty *property_info; sett_info = _nm_setting_class_get_sett_info(NM_SETTING_GET_CLASS(setting)); @@ -697,56 +712,56 @@ _nm_setting_property_get_property_direct(GObject * object, switch (property_info->property_type->direct_type) { case NM_VALUE_TYPE_BOOL: { - const bool *p_val = - _nm_setting_get_private(setting, sett_info, property_info->direct_offset); + const bool *p_val = _nm_setting_get_private_field(setting, sett_info, property_info); g_value_set_boolean(value, *p_val); return; } case NM_VALUE_TYPE_INT32: { - const gint32 *p_val = - _nm_setting_get_private(setting, sett_info, property_info->direct_offset); + const gint32 *p_val = _nm_setting_get_private_field(setting, sett_info, property_info); g_value_set_int(value, *p_val); return; } case NM_VALUE_TYPE_UINT32: { - const guint32 *p_val = - _nm_setting_get_private(setting, sett_info, property_info->direct_offset); + const guint32 *p_val = _nm_setting_get_private_field(setting, sett_info, property_info); g_value_set_uint(value, *p_val); return; } + case NM_VALUE_TYPE_INT64: + { + const gint64 *p_val = _nm_setting_get_private_field(setting, sett_info, property_info); + + g_value_set_int64(value, *p_val); + return; + } case NM_VALUE_TYPE_UINT64: { - const guint64 *p_val = - _nm_setting_get_private(setting, sett_info, property_info->direct_offset); + const guint64 *p_val = _nm_setting_get_private_field(setting, sett_info, property_info); g_value_set_uint64(value, *p_val); return; } case NM_VALUE_TYPE_ENUM: { - const int *p_val = - _nm_setting_get_private(setting, sett_info, property_info->direct_offset); + const int *p_val = _nm_setting_get_private_field(setting, sett_info, property_info); g_value_set_enum(value, *p_val); return; } case NM_VALUE_TYPE_FLAGS: { - const guint *p_val = - _nm_setting_get_private(setting, sett_info, property_info->direct_offset); + const guint *p_val = _nm_setting_get_private_field(setting, sett_info, property_info); g_value_set_flags(value, *p_val); return; } case NM_VALUE_TYPE_STRING: { - const char *const *p_val = - _nm_setting_get_private(setting, sett_info, property_info->direct_offset); + const char *const *p_val = _nm_setting_get_private_field(setting, sett_info, property_info); g_value_set_string(value, *p_val); return; @@ -754,7 +769,7 @@ _nm_setting_property_get_property_direct(GObject * object, case NM_VALUE_TYPE_BYTES: { const GBytes *const *p_val = - _nm_setting_get_private(setting, sett_info, property_info->direct_offset); + _nm_setting_get_private_field(setting, sett_info, property_info); g_value_set_boxed(value, *p_val); return; @@ -770,13 +785,13 @@ out_fail: } void -_nm_setting_property_set_property_direct(GObject * object, +_nm_setting_property_set_property_direct(GObject *object, guint prop_id, const GValue *value, - GParamSpec * pspec) + GParamSpec *pspec) { - NMSetting * setting = NM_SETTING(object); - const NMSettInfoSetting * sett_info; + NMSetting *setting = NM_SETTING(object); + const NMSettInfoSetting *sett_info; const NMSettInfoProperty *property_info; sett_info = _nm_setting_class_get_sett_info(NM_SETTING_GET_CLASS(setting)); @@ -791,7 +806,7 @@ _nm_setting_property_set_property_direct(GObject * object, switch (property_info->property_type->direct_type) { case NM_VALUE_TYPE_BOOL: { - bool * p_val = _nm_setting_get_private(setting, sett_info, property_info->direct_offset); + bool *p_val = _nm_setting_get_private_field(setting, sett_info, property_info); gboolean v; v = g_value_get_boolean(value); @@ -802,7 +817,7 @@ _nm_setting_property_set_property_direct(GObject * object, } case NM_VALUE_TYPE_INT32: { - gint32 *p_val = _nm_setting_get_private(setting, sett_info, property_info->direct_offset); + gint32 *p_val = _nm_setting_get_private_field(setting, sett_info, property_info); int v; v = g_value_get_int(value); @@ -817,7 +832,7 @@ _nm_setting_property_set_property_direct(GObject * object, } case NM_VALUE_TYPE_UINT32: { - guint32 *p_val = _nm_setting_get_private(setting, sett_info, property_info->direct_offset); + guint32 *p_val = _nm_setting_get_private_field(setting, sett_info, property_info); guint v; v = g_value_get_uint(value); @@ -830,9 +845,20 @@ _nm_setting_property_set_property_direct(GObject * object, nm_assert(*p_val == v); goto out_notify; } + case NM_VALUE_TYPE_INT64: + { + gint64 *p_val = _nm_setting_get_private_field(setting, sett_info, property_info); + gint64 v; + + v = g_value_get_int64(value); + if (*p_val == v) + return; + *p_val = v; + goto out_notify; + } case NM_VALUE_TYPE_UINT64: { - guint64 *p_val = _nm_setting_get_private(setting, sett_info, property_info->direct_offset); + guint64 *p_val = _nm_setting_get_private_field(setting, sett_info, property_info); guint64 v; v = g_value_get_uint64(value); @@ -843,7 +869,7 @@ _nm_setting_property_set_property_direct(GObject * object, } case NM_VALUE_TYPE_ENUM: { - int *p_val = _nm_setting_get_private(setting, sett_info, property_info->direct_offset); + int *p_val = _nm_setting_get_private_field(setting, sett_info, property_info); int v; v = g_value_get_enum(value); @@ -854,7 +880,7 @@ _nm_setting_property_set_property_direct(GObject * object, } case NM_VALUE_TYPE_FLAGS: { - guint *p_val = _nm_setting_get_private(setting, sett_info, property_info->direct_offset); + guint *p_val = _nm_setting_get_private_field(setting, sett_info, property_info); guint v; v = g_value_get_flags(value); @@ -864,16 +890,16 @@ _nm_setting_property_set_property_direct(GObject * object, goto out_notify; } case NM_VALUE_TYPE_STRING: - if (!_property_direct_set_string( - property_info, - _nm_setting_get_private(setting, sett_info, property_info->direct_offset), - g_value_get_string(value))) + if (!_property_direct_set_string(sett_info, + property_info, + setting, + g_value_get_string(value))) return; goto out_notify; case NM_VALUE_TYPE_BYTES: { - GBytes **p_val = _nm_setting_get_private(setting, sett_info, property_info->direct_offset); - GBytes * v; + GBytes **p_val = _nm_setting_get_private_field(setting, sett_info, property_info); + GBytes *v; _nm_unused gs_unref_bytes GBytes *old = NULL; v = g_value_get_boxed(value); @@ -923,7 +949,7 @@ _init_direct(NMSetting *setting) break; case NM_VALUE_TYPE_BOOL: { - bool *p_val = _nm_setting_get_private(setting, sett_info, property_info->direct_offset); + bool *p_val = _nm_setting_get_private_field(setting, sett_info, property_info); gboolean def_val; def_val = NM_G_PARAM_SPEC_GET_DEFAULT_BOOLEAN(property_info->param_spec); @@ -933,9 +959,8 @@ _init_direct(NMSetting *setting) } case NM_VALUE_TYPE_INT32: { - gint32 *p_val = - _nm_setting_get_private(setting, sett_info, property_info->direct_offset); - int def_val; + gint32 *p_val = _nm_setting_get_private_field(setting, sett_info, property_info); + int def_val; def_val = NM_G_PARAM_SPEC_GET_DEFAULT_INT(property_info->param_spec); nm_assert(*p_val == 0); @@ -944,20 +969,28 @@ _init_direct(NMSetting *setting) } case NM_VALUE_TYPE_UINT32: { - guint32 *p_val = - _nm_setting_get_private(setting, sett_info, property_info->direct_offset); - guint def_val; + guint32 *p_val = _nm_setting_get_private_field(setting, sett_info, property_info); + guint def_val; def_val = NM_G_PARAM_SPEC_GET_DEFAULT_UINT(property_info->param_spec); nm_assert(*p_val == 0); *p_val = def_val; break; } + case NM_VALUE_TYPE_INT64: + { + gint64 *p_val = _nm_setting_get_private_field(setting, sett_info, property_info); + gint64 def_val; + + def_val = NM_G_PARAM_SPEC_GET_DEFAULT_INT64(property_info->param_spec); + nm_assert(*p_val == 0); + *p_val = def_val; + break; + } case NM_VALUE_TYPE_UINT64: { - guint64 *p_val = - _nm_setting_get_private(setting, sett_info, property_info->direct_offset); - guint64 def_val; + guint64 *p_val = _nm_setting_get_private_field(setting, sett_info, property_info); + guint64 def_val; def_val = NM_G_PARAM_SPEC_GET_DEFAULT_UINT64(property_info->param_spec); nm_assert(*p_val == 0); @@ -966,7 +999,7 @@ _init_direct(NMSetting *setting) } case NM_VALUE_TYPE_ENUM: { - int *p_val = _nm_setting_get_private(setting, sett_info, property_info->direct_offset); + int *p_val = _nm_setting_get_private_field(setting, sett_info, property_info); int def_val; def_val = NM_G_PARAM_SPEC_GET_DEFAULT_ENUM(property_info->param_spec); @@ -976,9 +1009,8 @@ _init_direct(NMSetting *setting) } case NM_VALUE_TYPE_FLAGS: { - guint *p_val = - _nm_setting_get_private(setting, sett_info, property_info->direct_offset); - guint def_val; + guint *p_val = _nm_setting_get_private_field(setting, sett_info, property_info); + guint def_val; def_val = NM_G_PARAM_SPEC_GET_DEFAULT_FLAGS(property_info->param_spec); nm_assert(*p_val == 0); @@ -987,14 +1019,12 @@ _init_direct(NMSetting *setting) } case NM_VALUE_TYPE_STRING: nm_assert(!NM_G_PARAM_SPEC_GET_DEFAULT_STRING(property_info->param_spec)); - nm_assert(!( - *((const char *const *) - _nm_setting_get_private(setting, sett_info, property_info->direct_offset)))); + nm_assert(!(*((const char *const *) + _nm_setting_get_private_field(setting, sett_info, property_info)))); break; case NM_VALUE_TYPE_BYTES: - nm_assert(!( - *((const GBytes *const *) - _nm_setting_get_private(setting, sett_info, property_info->direct_offset)))); + nm_assert(!(*((const GBytes *const *) + _nm_setting_get_private_field(setting, sett_info, property_info)))); break; default: nm_assert_not_reached(); @@ -1027,22 +1057,26 @@ _finalize_direct(NMSetting *setting) case NM_VALUE_TYPE_BOOL: case NM_VALUE_TYPE_INT32: case NM_VALUE_TYPE_UINT32: + case NM_VALUE_TYPE_INT64: case NM_VALUE_TYPE_UINT64: case NM_VALUE_TYPE_ENUM: case NM_VALUE_TYPE_FLAGS: break; case NM_VALUE_TYPE_STRING: { - char **p_val = - _nm_setting_get_private(setting, sett_info, property_info->direct_offset); - - nm_clear_g_free(p_val); + char **p_val = _nm_setting_get_private_field(setting, sett_info, property_info); + + if (property_info->direct_string_is_refstr) + nm_clear_pointer(p_val, nm_ref_string_unref_upcast); + else if (NM_FLAGS_HAS(property_info->param_spec->flags, NM_SETTING_PARAM_SECRET)) + nm_clear_pointer(p_val, nm_free_secret); + else + nm_clear_g_free(p_val); break; } case NM_VALUE_TYPE_BYTES: { - GBytes **p_val = - _nm_setting_get_private(setting, sett_info, property_info->direct_offset); + GBytes **p_val = _nm_setting_get_private_field(setting, sett_info, property_info); nm_clear_pointer(p_val, g_bytes_unref); break; @@ -1064,7 +1098,7 @@ _nm_setting_property_to_dbus_fcn_direct(_NM_SETT_INFO_PROP_TO_DBUS_FCN_ARGS _nm_ { gboolean val; - val = *((bool *) _nm_setting_get_private(setting, sett_info, property_info->direct_offset)); + val = *((bool *) _nm_setting_get_private_field(setting, sett_info, property_info)); if (!property_info->to_dbus_including_default && val == NM_G_PARAM_SPEC_GET_DEFAULT_BOOLEAN(property_info->param_spec)) return NULL; @@ -1074,8 +1108,7 @@ _nm_setting_property_to_dbus_fcn_direct(_NM_SETT_INFO_PROP_TO_DBUS_FCN_ARGS _nm_ { gint32 val; - val = - *((gint32 *) _nm_setting_get_private(setting, sett_info, property_info->direct_offset)); + val = *((gint32 *) _nm_setting_get_private_field(setting, sett_info, property_info)); if (!property_info->to_dbus_including_default && val == NM_G_PARAM_SPEC_GET_DEFAULT_INT(property_info->param_spec)) return NULL; @@ -1085,19 +1118,27 @@ _nm_setting_property_to_dbus_fcn_direct(_NM_SETT_INFO_PROP_TO_DBUS_FCN_ARGS _nm_ { guint32 val; - val = *( - (guint32 *) _nm_setting_get_private(setting, sett_info, property_info->direct_offset)); + val = *((guint32 *) _nm_setting_get_private_field(setting, sett_info, property_info)); 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); } + case NM_VALUE_TYPE_INT64: + { + gint64 val; + + val = *((gint64 *) _nm_setting_get_private_field(setting, sett_info, property_info)); + if (!property_info->to_dbus_including_default + && val == NM_G_PARAM_SPEC_GET_DEFAULT_INT64(property_info->param_spec)) + return NULL; + return g_variant_new_int64(val); + } case NM_VALUE_TYPE_UINT64: { guint64 val; - val = *( - (guint64 *) _nm_setting_get_private(setting, sett_info, property_info->direct_offset)); + val = *((guint64 *) _nm_setting_get_private_field(setting, sett_info, property_info)); if (!property_info->to_dbus_including_default && val == NM_G_PARAM_SPEC_GET_DEFAULT_UINT64(property_info->param_spec)) return NULL; @@ -1107,7 +1148,7 @@ _nm_setting_property_to_dbus_fcn_direct(_NM_SETT_INFO_PROP_TO_DBUS_FCN_ARGS _nm_ { int val; - val = *((int *) _nm_setting_get_private(setting, sett_info, property_info->direct_offset)); + val = *((int *) _nm_setting_get_private_field(setting, sett_info, property_info)); if (!property_info->to_dbus_including_default && val == NM_G_PARAM_SPEC_GET_DEFAULT_ENUM(property_info->param_spec)) return NULL; @@ -1117,8 +1158,7 @@ _nm_setting_property_to_dbus_fcn_direct(_NM_SETT_INFO_PROP_TO_DBUS_FCN_ARGS _nm_ { guint val; - val = - *((guint *) _nm_setting_get_private(setting, sett_info, property_info->direct_offset)); + val = *((guint *) _nm_setting_get_private_field(setting, sett_info, property_info)); if (!property_info->to_dbus_including_default && val == NM_G_PARAM_SPEC_GET_DEFAULT_FLAGS(property_info->param_spec)) return NULL; @@ -1136,9 +1176,8 @@ _nm_setting_property_to_dbus_fcn_direct(_NM_SETT_INFO_PROP_TO_DBUS_FCN_ARGS _nm_ nm_assert(!NM_G_PARAM_SPEC_GET_DEFAULT_STRING(property_info->param_spec)); nm_assert(!property_info->to_dbus_including_default); - val = *((const char *const *) _nm_setting_get_private(setting, - sett_info, - property_info->direct_offset)); + val = *( + (const char *const *) _nm_setting_get_private_field(setting, sett_info, property_info)); if (!val) return NULL; if (!val[0]) @@ -1153,9 +1192,9 @@ _nm_setting_property_to_dbus_fcn_direct(_NM_SETT_INFO_PROP_TO_DBUS_FCN_ARGS _nm_ * (but it could have). */ nm_assert(!property_info->to_dbus_including_default); - val = *((const GBytes *const *) _nm_setting_get_private(setting, - sett_info, - property_info->direct_offset)); + val = *((const GBytes *const *) _nm_setting_get_private_field(setting, + sett_info, + property_info)); if (!val) return NULL; return nm_g_bytes_to_variant_ay(val); @@ -1175,9 +1214,7 @@ _nm_setting_property_to_dbus_fcn_direct_mac_address(_NM_SETT_INFO_PROP_TO_DBUS_F nm_assert(!NM_G_PARAM_SPEC_GET_DEFAULT_STRING(property_info->param_spec)); nm_assert(!property_info->to_dbus_including_default); - val = *((const char *const *) _nm_setting_get_private(setting, - sett_info, - property_info->direct_offset)); + val = *((const char *const *) _nm_setting_get_private_field(setting, sett_info, property_info)); return nm_utils_hwaddr_to_dbus(val); } @@ -1209,10 +1246,6 @@ _nm_setting_property_to_dbus_fcn_gprop(_NM_SETT_INFO_PROP_TO_DBUS_FCN_ARGS _nm_n switch (property_info->property_type->typdata_to_dbus.gprop_type) { case NM_SETTING_PROPERTY_TO_DBUS_FCN_GPROP_TYPE_DEFAULT: return g_dbus_gvalue_to_gvariant(&prop_value, property_info->property_type->dbus_type); - case NM_SETTING_PROPERTY_TO_DBUS_FCN_GPROP_TYPE_ENUM: - return nm_g_variant_maybe_singleton_i(g_value_get_enum(&prop_value)); - case NM_SETTING_PROPERTY_TO_DBUS_FCN_GPROP_TYPE_FLAGS: - return g_variant_new_uint32(g_value_get_flags(&prop_value)); case NM_SETTING_PROPERTY_TO_DBUS_FCN_GPROP_TYPE_GARRAY_UINT: G_STATIC_ASSERT_EXPR(sizeof(guint) == sizeof(guint32)); nm_assert(G_VALUE_HOLDS(&prop_value, G_TYPE_ARRAY)); @@ -1249,9 +1282,8 @@ _nm_setting_property_from_dbus_fcn_direct_mac_address(_NM_SETT_INFO_PROP_FROM_DB array = g_variant_get_fixed_array(value, &length, 1); - if (nm_strdup_reset_take( - _nm_setting_get_private(setting, sett_info, property_info->direct_offset), - length > 0 ? nm_utils_hwaddr_ntoa(array, length) : NULL)) { + if (nm_strdup_reset_take(_nm_setting_get_private_field(setting, sett_info, property_info), + length > 0 ? nm_utils_hwaddr_ntoa(array, length) : NULL)) { g_object_notify_by_pspec(G_OBJECT(setting), property_info->param_spec); } else *out_is_modified = FALSE; @@ -1271,7 +1303,7 @@ _nm_setting_property_from_dbus_fcn_direct(_NM_SETT_INFO_PROP_FROM_DBUS_FCN_ARGS ({ \ const NMSettInfoProperty const *_property_info = (property_info); \ const GType _gtype = (gtype); \ - GVariant * _value = (value); \ + GVariant *_value = (value); \ gboolean _success = FALSE; \ \ nm_assert(_property_info->param_spec->value_type == _gtype); \ @@ -1292,7 +1324,7 @@ _nm_setting_property_from_dbus_fcn_direct(_NM_SETT_INFO_PROP_FROM_DBUS_FCN_ARGS switch (property_info->property_type->direct_type) { case NM_VALUE_TYPE_BOOL: { - bool * p_val; + bool *p_val; gboolean v; if (g_variant_is_of_type(value, G_VARIANT_TYPE_BOOLEAN)) @@ -1307,7 +1339,7 @@ _nm_setting_property_from_dbus_fcn_direct(_NM_SETT_INFO_PROP_FROM_DBUS_FCN_ARGS v = !!v; } - p_val = _nm_setting_get_private(setting, sett_info, property_info->direct_offset); + p_val = _nm_setting_get_private_field(setting, sett_info, property_info); if (*p_val == v) goto out_unchanged; *p_val = v; @@ -1316,7 +1348,7 @@ _nm_setting_property_from_dbus_fcn_direct(_NM_SETT_INFO_PROP_FROM_DBUS_FCN_ARGS case NM_VALUE_TYPE_INT32: { const GParamSpecInt *param_spec; - gint32 * p_val; + gint32 *p_val; int v; if (g_variant_is_of_type(value, G_VARIANT_TYPE_INT32)) { @@ -1331,7 +1363,7 @@ _nm_setting_property_from_dbus_fcn_direct(_NM_SETT_INFO_PROP_FROM_DBUS_FCN_ARGS goto out_error_wrong_dbus_type; } - p_val = _nm_setting_get_private(setting, sett_info, property_info->direct_offset); + p_val = _nm_setting_get_private_field(setting, sett_info, property_info); if (*p_val == v) goto out_unchanged; @@ -1344,7 +1376,7 @@ _nm_setting_property_from_dbus_fcn_direct(_NM_SETT_INFO_PROP_FROM_DBUS_FCN_ARGS case NM_VALUE_TYPE_UINT32: { const GParamSpecUInt *param_spec; - guint32 * p_val; + guint32 *p_val; guint v; if (g_variant_is_of_type(value, G_VARIANT_TYPE_UINT32)) { @@ -1359,7 +1391,7 @@ _nm_setting_property_from_dbus_fcn_direct(_NM_SETT_INFO_PROP_FROM_DBUS_FCN_ARGS goto out_error_wrong_dbus_type; } - p_val = _nm_setting_get_private(setting, sett_info, property_info->direct_offset); + p_val = _nm_setting_get_private_field(setting, sett_info, property_info); if (*p_val == v) goto out_unchanged; @@ -1369,10 +1401,37 @@ _nm_setting_property_from_dbus_fcn_direct(_NM_SETT_INFO_PROP_FROM_DBUS_FCN_ARGS *p_val = v; goto out_notify; } + case NM_VALUE_TYPE_INT64: + { + const GParamSpecInt64 *param_spec; + gint64 *p_val; + gint64 v; + + if (g_variant_is_of_type(value, G_VARIANT_TYPE_INT64)) + v = g_variant_get_int64(value); + else { + if (!_variant_get_value_transform(property_info, + value, + G_TYPE_INT64, + g_value_get_int64, + &v)) + goto out_error_wrong_dbus_type; + } + + p_val = _nm_setting_get_private_field(setting, sett_info, property_info); + if (*p_val == v) + goto out_unchanged; + + param_spec = NM_G_PARAM_SPEC_CAST_INT64(property_info->param_spec); + if (v < param_spec->minimum || v > param_spec->maximum) + goto out_error_param_spec_validation; + *p_val = v; + goto out_notify; + } case NM_VALUE_TYPE_UINT64: { const GParamSpecUInt64 *param_spec; - guint64 * p_val; + guint64 *p_val; guint64 v; if (g_variant_is_of_type(value, G_VARIANT_TYPE_UINT64)) @@ -1386,7 +1445,7 @@ _nm_setting_property_from_dbus_fcn_direct(_NM_SETT_INFO_PROP_FROM_DBUS_FCN_ARGS goto out_error_wrong_dbus_type; } - p_val = _nm_setting_get_private(setting, sett_info, property_info->direct_offset); + p_val = _nm_setting_get_private_field(setting, sett_info, property_info); if (*p_val == v) goto out_unchanged; @@ -1399,7 +1458,7 @@ _nm_setting_property_from_dbus_fcn_direct(_NM_SETT_INFO_PROP_FROM_DBUS_FCN_ARGS case NM_VALUE_TYPE_ENUM: { const GParamSpecEnum *param_spec; - int * p_val; + int *p_val; int v; param_spec = NM_G_PARAM_SPEC_CAST_ENUM(property_info->param_spec); @@ -1416,7 +1475,7 @@ _nm_setting_property_from_dbus_fcn_direct(_NM_SETT_INFO_PROP_FROM_DBUS_FCN_ARGS goto out_error_wrong_dbus_type; } - p_val = _nm_setting_get_private(setting, sett_info, property_info->direct_offset); + p_val = _nm_setting_get_private_field(setting, sett_info, property_info); if (*p_val == v) goto out_unchanged; @@ -1428,7 +1487,7 @@ _nm_setting_property_from_dbus_fcn_direct(_NM_SETT_INFO_PROP_FROM_DBUS_FCN_ARGS case NM_VALUE_TYPE_FLAGS: { const GParamSpecFlags *param_spec; - guint * p_val; + guint *p_val; guint v; param_spec = NM_G_PARAM_SPEC_CAST_FLAGS(property_info->param_spec); @@ -1445,7 +1504,7 @@ _nm_setting_property_from_dbus_fcn_direct(_NM_SETT_INFO_PROP_FROM_DBUS_FCN_ARGS goto out_error_wrong_dbus_type; } - p_val = _nm_setting_get_private(setting, sett_info, property_info->direct_offset); + p_val = _nm_setting_get_private_field(setting, sett_info, property_info); if (*p_val == v) goto out_unchanged; @@ -1457,8 +1516,8 @@ _nm_setting_property_from_dbus_fcn_direct(_NM_SETT_INFO_PROP_FROM_DBUS_FCN_ARGS case NM_VALUE_TYPE_STRING: { gs_free char *v_free = NULL; - char ** p_val; - const char * v; + const char *v; + gboolean changed; if (g_variant_is_of_type(value, G_VARIANT_TYPE_STRING)) { v = g_variant_get_string(value, NULL); @@ -1472,23 +1531,26 @@ _nm_setting_property_from_dbus_fcn_direct(_NM_SETT_INFO_PROP_FROM_DBUS_FCN_ARGS v = v_free; } - p_val = _nm_setting_get_private(setting, sett_info, property_info->direct_offset); - if (!_property_direct_set_string(property_info, p_val, v)) - goto out_unchanged; + changed = _property_direct_set_string(sett_info, property_info, setting, v); + + if (NM_FLAGS_HAS(property_info->param_spec->flags, NM_SETTING_PARAM_SECRET)) + nm_clear_pointer(&v_free, nm_free_secret); + if (!changed) + goto out_unchanged; goto out_notify; } case NM_VALUE_TYPE_BYTES: { gs_unref_bytes GBytes *v = NULL; - GBytes ** p_val; + GBytes **p_val; if (!g_variant_is_of_type(value, G_VARIANT_TYPE_BYTESTRING)) goto out_error_wrong_dbus_type; v = nm_g_bytes_new_from_variant_ay(value); - p_val = _nm_setting_get_private(setting, sett_info, property_info->direct_offset); + p_val = _nm_setting_get_private_field(setting, sett_info, property_info); if (nm_g_bytes_equal0(*p_val, v)) goto out_unchanged; @@ -1542,7 +1604,7 @@ gboolean _nm_setting_property_from_dbus_fcn_gprop(_NM_SETT_INFO_PROP_FROM_DBUS_FCN_ARGS _nm_nil) { nm_auto_unset_gvalue GValue object_value = G_VALUE_INIT; - gs_free_error GError *local = NULL; + gs_free_error GError *local = NULL; nm_assert(property_info->param_spec); @@ -1586,10 +1648,10 @@ _nm_setting_property_from_dbus_fcn_gprop(_NM_SETT_INFO_PROP_FROM_DBUS_FCN_ARGS _ } static GVariant * -property_to_dbus(const NMSettInfoSetting * sett_info, - const NMSettInfoProperty * property_info, - NMConnection * connection, - NMSetting * setting, +property_to_dbus(const NMSettInfoSetting *sett_info, + const NMSettInfoProperty *property_info, + NMConnection *connection, + NMSetting *setting, NMConnectionSerializationFlags flags, const NMConnectionSerializationOptions *options, gboolean ignore_flags) @@ -1646,8 +1708,8 @@ property_to_dbus(const NMSettInfoSetting * sett_info, static gboolean set_property_from_dbus(const NMSettInfoProperty *property_info, - GVariant * src_value, - GValue * dst_value) + GVariant *src_value, + GValue *dst_value) { nm_assert(property_info->param_spec); nm_assert(property_info->property_type->dbus_type); @@ -1687,18 +1749,18 @@ set_property_from_dbus(const NMSettInfoProperty *property_info, * properties **/ GVariant * -_nm_setting_to_dbus(NMSetting * setting, - NMConnection * connection, +_nm_setting_to_dbus(NMSetting *setting, + NMConnection *connection, NMConnectionSerializationFlags flags, const NMConnectionSerializationOptions *options) { - NMSettingPrivate * priv; + NMSettingPrivate *priv; GVariantBuilder builder; const NMSettInfoSetting *sett_info; guint n_properties; guint i; guint16 j; - const char *const * gendata_keys; + const char *const *gendata_keys; g_return_val_if_fail(NM_IS_SETTING(setting), NULL); @@ -1716,8 +1778,8 @@ _nm_setting_to_dbus(NMSetting * setting, sett_info = _nm_setting_class_get_sett_info(NM_SETTING_GET_CLASS(setting)); for (j = 0; j < sett_info->property_infos_len; j++) { - const NMSettInfoProperty *property_info = &sett_info->property_infos[j]; - gs_unref_variant GVariant *dbus_value = NULL; + const NMSettInfoProperty *property_info = &sett_info->property_infos[j]; + gs_unref_variant GVariant *dbus_value = NULL; dbus_value = property_to_dbus(sett_info, property_info, connection, setting, flags, options, FALSE); @@ -1751,14 +1813,14 @@ _nm_setting_to_dbus(NMSetting * setting, **/ NMSetting * _nm_setting_new_from_dbus(GType setting_type, - GVariant * setting_dict, - GVariant * connection_dict, + GVariant *setting_dict, + GVariant *connection_dict, NMSettingParseFlags parse_flags, - GError ** error) + GError **error) { - gs_unref_ptrarray GPtrArray *keys_keep_variant = NULL; - gs_unref_object NMSetting *setting = NULL; - gs_unref_hashtable GHashTable *keys = NULL; + gs_unref_ptrarray GPtrArray *keys_keep_variant = NULL; + gs_unref_object NMSetting *setting = NULL; + gs_unref_hashtable GHashTable *keys = NULL; g_return_val_if_fail(G_TYPE_IS_INSTANTIATABLE(setting_type), NULL); g_return_val_if_fail(g_variant_is_of_type(setting_dict, NM_VARIANT_TYPE_SETTING), NULL); @@ -1783,8 +1845,8 @@ _nm_setting_new_from_dbus(GType setting_type, if (NM_FLAGS_HAS(parse_flags, NM_SETTING_PARSE_FLAGS_STRICT)) { GVariantIter iter; - GVariant * entry, *entry_key; - const char * key; + GVariant *entry, *entry_key; + const char *key; keys_keep_variant = g_ptr_array_new_with_free_func((GDestroyNotify) g_variant_unref); keys = g_hash_table_new(nm_str_hash, g_str_equal); @@ -1813,7 +1875,7 @@ _nm_setting_new_from_dbus(GType setting_type, if (NM_FLAGS_HAS(parse_flags, NM_SETTING_PARSE_FLAGS_STRICT) && g_hash_table_size(keys) > 0) { GHashTableIter iter; - const char * key; + const char *key; g_hash_table_iter_init(&iter, keys); if (g_hash_table_iter_next(&iter, (gpointer *) &key, NULL)) { @@ -1830,14 +1892,14 @@ _nm_setting_new_from_dbus(GType setting_type, } static gboolean -_property_set_from_dbus(const NMSettInfoSetting * sett_info, +_property_set_from_dbus(const NMSettInfoSetting *sett_info, const NMSettInfoProperty *property_info, - NMSetting * setting, - GVariant * connection_dict, - GVariant * value, + NMSetting *setting, + GVariant *connection_dict, + GVariant *value, NMSettingParseFlags parse_flags, - gboolean * out_is_modified, - GError ** error) + gboolean *out_is_modified, + GError **error) { gs_free_error GError *local = NULL; NMTernary is_modified = NM_TERNARY_DEFAULT; @@ -1904,12 +1966,12 @@ _property_set_from_dbus(const NMSettInfoSetting * sett_info, } static gboolean -init_from_dbus(NMSetting * setting, - GHashTable * keys, - GVariant * setting_dict, - GVariant * connection_dict, +init_from_dbus(NMSetting *setting, + GHashTable *keys, + GVariant *setting_dict, + GVariant *connection_dict, guint /* NMSettingParseFlags */ parse_flags, - GError ** error) + GError **error) { const NMSettInfoSetting *sett_info; guint16 i; @@ -1922,10 +1984,10 @@ init_from_dbus(NMSetting * setting, sett_info = _nm_setting_class_get_sett_info(NM_SETTING_GET_CLASS(setting)); if (sett_info->detail.gendata_info) { - GHashTable * hash; + GHashTable *hash; GVariantIter iter; - char * key; - GVariant * val; + char *key; + GVariant *val; hash = _gendata_hash(setting, TRUE)->hash; @@ -1952,9 +2014,9 @@ init_from_dbus(NMSetting * setting, } for (i = 0; i < sett_info->property_infos_len; i++) { - const NMSettInfoProperty *property_info = &sett_info->property_infos[i]; - gs_unref_variant GVariant *value = NULL; - gs_free_error GError *local = NULL; + const NMSettInfoProperty *property_info = &sett_info->property_infos[i]; + gs_unref_variant GVariant *value = NULL; + gs_free_error GError *local = NULL; if (property_info->property_type == &nm_sett_info_propert_type_setting_name) continue; @@ -2034,7 +2096,7 @@ nm_setting_get_dbus_property_type(NMSetting *setting, const char *property_name) gboolean _nm_setting_get_property(NMSetting *setting, const char *property_name, GValue *value) { - const NMSettInfoSetting * sett_info; + const NMSettInfoSetting *sett_info; const NMSettInfoProperty *property_info; g_return_val_if_fail(NM_IS_SETTING(setting), FALSE); @@ -2045,7 +2107,7 @@ _nm_setting_get_property(NMSetting *setting, const char *property_name, GValue * if (sett_info->detail.gendata_info) { GVariant *variant; - GenData * gendata = _gendata_hash(setting, FALSE); + GenData *gendata = _gendata_hash(setting, FALSE); variant = gendata ? g_hash_table_lookup(gendata->hash, property_name) : NULL; @@ -2096,9 +2158,9 @@ duplicate_copy_properties(const NMSettInfoSetting *sett_info, NMSetting *src, NM if (gendata && g_hash_table_size(gendata->hash) > 0) { GHashTableIter iter; - GHashTable * h = _gendata_hash(dst, TRUE)->hash; - const char * key; - GVariant * val; + GHashTable *h = _gendata_hash(dst, TRUE)->hash; + const char *key; + GVariant *val; g_hash_table_iter_init(&iter, gendata->hash); while (g_hash_table_iter_next(&iter, (gpointer *) &key, (gpointer *) &val)) { @@ -2146,8 +2208,8 @@ NMSetting * nm_setting_duplicate(NMSetting *setting) { const NMSettInfoSetting *sett_info; - NMSettingClass * klass; - NMSetting * dst; + NMSettingClass *klass; + NMSetting *dst; g_return_val_if_fail(NM_IS_SETTING(setting), NULL); @@ -2256,7 +2318,7 @@ gboolean _nm_setting_verify_secret_string(const char *str, const char *setting_name, const char *property, - GError ** error) + GError **error) { if (str && !*str) { g_set_error_literal(error, @@ -2270,9 +2332,9 @@ _nm_setting_verify_secret_string(const char *str, } gboolean -_nm_setting_should_compare_secret_property(NMSetting * setting, - NMSetting * other, - const char * secret_name, +_nm_setting_should_compare_secret_property(NMSetting *setting, + NMSetting *other, + const char *secret_name, NMSettingCompareFlags flags) { NMSettingSecretFlags a_secret_flags = NM_SETTING_SECRET_FLAG_NONE; @@ -2328,10 +2390,10 @@ _nm_setting_should_compare_secret_property(NMSetting * setting, /*****************************************************************************/ gboolean -_nm_setting_compare_flags_check(const GParamSpec * param_spec, +_nm_setting_compare_flags_check(const GParamSpec *param_spec, NMSettingCompareFlags flags, - NMSetting * set_a, - NMSetting * set_b) + NMSetting *set_a, + NMSetting *set_b) { if (NM_FLAGS_HAS(flags, NM_SETTING_COMPARE_FLAG_FUZZY) && NM_FLAGS_ANY(param_spec->flags, NM_SETTING_PARAM_FUZZY_IGNORE | NM_SETTING_PARAM_SECRET)) @@ -2381,8 +2443,8 @@ _nm_setting_property_compare_fcn_direct(_NM_SETT_INFO_PROP_COMPARE_FCN_ARGS _nm_ if (!set_b) return TRUE; - p_a = _nm_setting_get_private(set_a, sett_info, property_info->direct_offset); - p_b = _nm_setting_get_private(set_b, sett_info, property_info->direct_offset); + p_a = _nm_setting_get_private_field(set_a, sett_info, property_info); + p_b = _nm_setting_get_private_field(set_b, sett_info, property_info); switch (property_info->property_type->direct_type) { case NM_VALUE_TYPE_BOOL: @@ -2391,6 +2453,8 @@ _nm_setting_property_compare_fcn_direct(_NM_SETT_INFO_PROP_COMPARE_FCN_ARGS _nm_ return *((const gint32 *) p_a) == *((const gint32 *) p_b); case NM_VALUE_TYPE_UINT32: return *((const guint32 *) p_a) == *((const guint32 *) p_b); + case NM_VALUE_TYPE_INT64: + return *((const gint64 *) p_a) == *((const gint64 *) p_b); case NM_VALUE_TYPE_UINT64: return *((const guint64 *) p_a) == *((const guint64 *) p_b); case NM_VALUE_TYPE_ENUM: @@ -2443,12 +2507,12 @@ _nm_setting_property_compare_fcn_default(_NM_SETT_INFO_PROP_COMPARE_FCN_ARGS _nm } static NMTernary -_compare_property(const NMSettInfoSetting * sett_info, +_compare_property(const NMSettInfoSetting *sett_info, const NMSettInfoProperty *property_info, - NMConnection * con_a, - NMSetting * set_a, - NMConnection * con_b, - NMSetting * set_b, + NMConnection *con_a, + NMSetting *set_a, + NMConnection *con_b, + NMSetting *set_b, NMSettingCompareFlags flags) { NMTernary compare_result; @@ -2500,10 +2564,10 @@ nm_setting_compare(NMSetting *a, NMSetting *b, NMSettingCompareFlags flags) } gboolean -_nm_setting_compare(NMConnection * con_a, - NMSetting * a, - NMConnection * con_b, - NMSetting * b, +_nm_setting_compare(NMConnection *con_a, + NMSetting *a, + NMConnection *con_b, + NMSetting *b, NMSettingCompareFlags flags) { const NMSettInfoSetting *sett_info; @@ -2579,23 +2643,23 @@ _setting_diff_add_result(GHashTable *results, const char *prop_name, NMSettingDi * Returns: %TRUE if the settings contain the same values, %FALSE if they do not **/ gboolean -nm_setting_diff(NMSetting * a, - NMSetting * b, +nm_setting_diff(NMSetting *a, + NMSetting *b, NMSettingCompareFlags flags, gboolean invert_results, - GHashTable ** results) + GHashTable **results) { return _nm_setting_diff(NULL, a, NULL, b, flags, invert_results, results); } gboolean -_nm_setting_diff(NMConnection * con_a, - NMSetting * a, - NMConnection * con_b, - NMSetting * b, +_nm_setting_diff(NMConnection *con_a, + NMSetting *a, + NMConnection *con_b, + NMSetting *b, NMSettingCompareFlags flags, gboolean invert_results, - GHashTable ** results) + GHashTable **results) { const NMSettInfoSetting *sett_info; NMSettingDiffResult a_result = NM_SETTING_DIFF_RESULT_IN_A; @@ -2650,11 +2714,11 @@ _nm_setting_diff(NMConnection * con_a, sett_info = _nm_setting_class_get_sett_info(NM_SETTING_GET_CLASS(a)); if (sett_info->detail.gendata_info) { - const char * key; - GVariant * val, *val2; + const char *key; + GVariant *val, *val2; GHashTableIter iter; - GenData * a_gendata = _gendata_hash(a, FALSE); - GenData * b_gendata = b ? _gendata_hash(b, FALSE) : NULL; + GenData *a_gendata = _gendata_hash(a, FALSE); + GenData *b_gendata = b ? _gendata_hash(b, FALSE) : NULL; if (!a_gendata || !b_gendata) { if (a_gendata || b_gendata) { @@ -2692,7 +2756,7 @@ _nm_setting_diff(NMConnection * con_a, NMSettingDiffResult r = NM_SETTING_DIFF_RESULT_UNKNOWN; const NMSettInfoProperty *property_info = &sett_info->property_infos[i]; NMTernary compare_result; - GParamSpec * prop_spec; + GParamSpec *prop_spec; compare_result = _compare_property(sett_info, property_info, con_a, a, con_b, b, flags); if (compare_result == NM_TERNARY_DEFAULT) @@ -2809,7 +2873,7 @@ _nm_setting_diff(NMConnection * con_a, static void enumerate_values(const NMSettInfoProperty *property_info, - NMSetting * setting, + NMSetting *setting, NMSettingValueIterFn func, gpointer user_data) { @@ -2859,7 +2923,7 @@ nm_setting_enumerate_values(NMSetting *setting, NMSettingValueIterFn func, gpoin n_properties = _nm_setting_option_get_all(setting, &names, NULL); if (n_properties > 0) { gs_strfreev char **keys = g_strdupv((char **) names); - GHashTable * h = _gendata_hash(setting, FALSE)->hash; + GHashTable *h = _gendata_hash(setting, FALSE)->hash; for (i = 0; i < n_properties; i++) { GValue value = G_VALUE_INIT; @@ -2894,7 +2958,7 @@ static gboolean aggregate(NMSetting *setting, int type_i, gpointer arg) { NMConnectionAggregateType type = type_i; - const NMSettInfoSetting * sett_info; + const NMSettInfoSetting *sett_info; guint16 i; nm_assert(NM_IN_SET(type, @@ -2903,8 +2967,8 @@ aggregate(NMSetting *setting, int type_i, gpointer arg) sett_info = _nm_setting_class_get_sett_info(NM_SETTING_GET_CLASS(setting)); for (i = 0; i < sett_info->property_infos_len; i++) { - const NMSettInfoProperty * property_info = &sett_info->property_infos[i]; - GParamSpec * prop_spec = property_info->param_spec; + const NMSettInfoProperty *property_info = &sett_info->property_infos[i]; + GParamSpec *prop_spec = property_info->param_spec; nm_auto_unset_gvalue GValue value = G_VALUE_INIT; NMSettingSecretFlags secret_flags; @@ -2969,14 +3033,14 @@ _nm_setting_aggregate(NMSetting *setting, NMConnectionAggregateType type, gpoint } static gboolean -clear_secrets(const NMSettInfoSetting * sett_info, - const NMSettInfoProperty * property_info, - NMSetting * setting, +clear_secrets(const NMSettInfoSetting *sett_info, + const NMSettInfoProperty *property_info, + NMSetting *setting, NMSettingClearSecretsWithFlagsFn func, gpointer user_data) { NMSettingSecretFlags flags = NM_SETTING_SECRET_FLAG_NONE; - GParamSpec * param_spec = property_info->param_spec; + GParamSpec *param_spec = property_info->param_spec; if (!param_spec) return FALSE; @@ -3019,13 +3083,13 @@ clear_secrets(const NMSettInfoSetting * sett_info, * Returns: %TRUE if the setting changed at all **/ gboolean -_nm_setting_clear_secrets(NMSetting * setting, +_nm_setting_clear_secrets(NMSetting *setting, NMSettingClearSecretsWithFlagsFn func, gpointer user_data) { const NMSettInfoSetting *sett_info; gboolean changed = FALSE; - NMSettingClass * klass; + NMSettingClass *klass; guint16 i; g_return_val_if_fail(NM_IS_SETTING(setting), FALSE); @@ -3073,7 +3137,7 @@ _nm_setting_need_secrets(NMSetting *setting) static int update_one_secret(NMSetting *setting, const char *key, GVariant *value, GError **error) { - const NMSettInfoSetting * sett_info; + const NMSettInfoSetting *sett_info; const NMSettInfoProperty *property_info; gboolean is_modified; @@ -3125,9 +3189,9 @@ NMSettingUpdateSecretResult _nm_setting_update_secrets(NMSetting *setting, GVariant *secrets, GError **error) { GVariantIter iter; - const char * secret_key; - GVariant * secret_value; - GError * tmp_error = NULL; + const char *secret_key; + GVariant *secret_value; + GError *tmp_error = NULL; NMSettingUpdateSecretResult result = NM_SETTING_UPDATE_SECRET_SUCCESS_UNCHANGED; g_return_val_if_fail(NM_IS_SETTING(setting), NM_SETTING_UPDATE_SECRET_ERROR); @@ -3161,13 +3225,13 @@ _nm_setting_update_secrets(NMSetting *setting, GVariant *secrets, GError **error } static void -for_each_secret(NMSetting * setting, - const char * secret_name, - GVariant * val, +for_each_secret(NMSetting *setting, + const char *secret_name, + GVariant *val, gboolean remove_non_secrets, _NMConnectionForEachSecretFunc callback, gpointer callback_data, - GVariantBuilder * setting_builder) + GVariantBuilder *setting_builder) { NMSettingSecretFlags secret_flags = NM_SETTING_SECRET_FLAG_NONE; @@ -3219,13 +3283,13 @@ _nm_setting_property_is_regular_secret_flags(NMSetting *setting, const char *sec } static gboolean -get_secret_flags(NMSetting * setting, - const char * secret_name, +get_secret_flags(NMSetting *setting, + const char *secret_name, NMSettingSecretFlags *out_flags, - GError ** error) + GError **error) { - gs_free char * secret_flags_name_free = NULL; - const char * secret_flags_name; + gs_free char *secret_flags_name_free = NULL; + const char *secret_flags_name; NMSettingSecretFlags flags; if (!_nm_setting_property_is_regular_secret(setting, secret_name)) { @@ -3257,10 +3321,10 @@ get_secret_flags(NMSetting * setting, * this setting, and if that property is secret), %FALSE if not **/ gboolean -nm_setting_get_secret_flags(NMSetting * setting, - const char * secret_name, +nm_setting_get_secret_flags(NMSetting *setting, + const char *secret_name, NMSettingSecretFlags *out_flags, - GError ** error) + GError **error) { g_return_val_if_fail(NM_IS_SETTING(setting), FALSE); g_return_val_if_fail(secret_name != NULL, FALSE); @@ -3269,13 +3333,13 @@ nm_setting_get_secret_flags(NMSetting * setting, } static gboolean -set_secret_flags(NMSetting * setting, - const char * secret_name, +set_secret_flags(NMSetting *setting, + const char *secret_name, NMSettingSecretFlags flags, - GError ** error) + GError **error) { gs_free char *secret_flags_name_free = NULL; - const char * secret_flags_name; + const char *secret_flags_name; if (!_nm_setting_property_is_regular_secret(setting, secret_name)) { _set_error_secret_property_not_found(error, setting, secret_name); @@ -3309,10 +3373,10 @@ set_secret_flags(NMSetting * setting, * this setting, and if that property is secret), %FALSE if not **/ gboolean -nm_setting_set_secret_flags(NMSetting * setting, - const char * secret_name, +nm_setting_set_secret_flags(NMSetting *setting, + const char *secret_name, NMSettingSecretFlags flags, - GError ** error) + GError **error) { g_return_val_if_fail(NM_IS_SETTING(setting), FALSE); g_return_val_if_fail(secret_name != NULL, FALSE); @@ -3337,9 +3401,9 @@ nm_setting_set_secret_flags(NMSetting * setting, char * nm_setting_to_string(NMSetting *setting) { - GString * string; + GString *string; gs_unref_variant GVariant *variant = NULL; - GVariant * child; + GVariant *child; GVariantIter iter; string = g_string_new(nm_setting_get_name(setting)); @@ -3349,9 +3413,9 @@ nm_setting_to_string(NMSetting *setting) g_variant_iter_init(&iter, variant); while ((child = g_variant_iter_next_value(&iter))) { - gs_free char * name = NULL; - gs_free char * value_str = NULL; - gs_unref_variant GVariant *value = NULL; + gs_free char *name = NULL; + gs_free char *value_str = NULL; + gs_unref_variant GVariant *value = NULL; g_variant_get(child, "{sv}", &name, &value); value_str = g_variant_print(value, FALSE); @@ -3405,18 +3469,6 @@ 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); -const NMSettInfoPropertType nm_sett_info_propert_type_plain_i = - NM_SETT_INFO_PROPERT_TYPE_GPROP_INIT(G_VARIANT_TYPE_INT32, - .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_plain_u = - NM_SETT_INFO_PROPERT_TYPE_GPROP_INIT(G_VARIANT_TYPE_UINT32, - .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, @@ -3444,6 +3496,15 @@ const NMSettInfoPropertType nm_sett_info_propert_type_direct_uint32 = .from_dbus_is_full = TRUE, .from_dbus_direct_allow_transform = TRUE); +const NMSettInfoPropertType nm_sett_info_propert_type_direct_int64 = + NM_SETT_INFO_PROPERT_TYPE_DBUS_INIT(G_VARIANT_TYPE_INT64, + .direct_type = NM_VALUE_TYPE_INT64, + .compare_fcn = _nm_setting_property_compare_fcn_direct, + .to_dbus_fcn = _nm_setting_property_to_dbus_fcn_direct, + .from_dbus_fcn = _nm_setting_property_from_dbus_fcn_direct, + .from_dbus_is_full = TRUE, + .from_dbus_direct_allow_transform = TRUE); + const NMSettInfoPropertType nm_sett_info_propert_type_direct_uint64 = NM_SETT_INFO_PROPERT_TYPE_DBUS_INIT(G_VARIANT_TYPE_UINT64, .direct_type = NM_VALUE_TYPE_UINT64, @@ -3568,11 +3629,11 @@ out: } guint -_nm_setting_option_get_all(NMSetting * setting, +_nm_setting_option_get_all(NMSetting *setting, const char *const **out_names, - GVariant *const ** out_values) + GVariant *const **out_values) { - GenData * gendata; + GenData *gendata; GHashTable *hash; guint i, len; @@ -3668,9 +3729,9 @@ _nm_setting_option_clear(NMSetting *setting, const char *optname) void nm_setting_option_clear_by_name(NMSetting *setting, NMUtilsPredicateStr predicate) { - GHashTable * hash; + GHashTable *hash; GHashTableIter iter; - const char * name; + const char *name; gboolean changed = FALSE; g_return_if_fail(NM_IS_SETTING(setting)); @@ -3790,7 +3851,7 @@ nm_setting_option_get_uint32(NMSetting *setting, const char *opt_name, guint32 * void nm_setting_option_set(NMSetting *setting, const char *opt_name, GVariant *variant) { - GVariant * old_variant; + GVariant *old_variant; gboolean changed_name; gboolean changed_value; GHashTable *hash; @@ -3850,7 +3911,7 @@ nm_setting_option_set(NMSetting *setting, const char *opt_name, GVariant *varian void nm_setting_option_set_boolean(NMSetting *setting, const char *opt_name, gboolean value) { - GVariant * old_variant; + GVariant *old_variant; gboolean changed_name; gboolean changed_value; GHashTable *hash; @@ -3887,7 +3948,7 @@ nm_setting_option_set_boolean(NMSetting *setting, const char *opt_name, gboolean void nm_setting_option_set_uint32(NMSetting *setting, const char *opt_name, guint32 value) { - GVariant * old_variant; + GVariant *old_variant; gboolean changed_name; gboolean changed_value; GHashTable *hash; @@ -3936,7 +3997,7 @@ nm_setting_init(NMSetting *setting) static void constructed(GObject *object) { - NMSetting * self = NM_SETTING(object); + NMSetting *self = NM_SETTING(object); NMSettingClass *klass = NM_SETTING_GET_CLASS(self); /* we don't support that NMSetting subclasses override constructed. @@ -3962,7 +4023,7 @@ constructed(GObject *object) static void finalize(GObject *object) { - NMSetting * self = NM_SETTING(object); + NMSetting *self = NM_SETTING(object); NMSettingPrivate *priv = NM_SETTING_GET_PRIVATE(self); if (priv->gendata) { diff --git a/src/libnm-core-impl/nm-simple-connection.c b/src/libnm-core-impl/nm-simple-connection.c index f16d9d59..6252dc2c 100644 --- a/src/libnm-core-impl/nm-simple-connection.c +++ b/src/libnm-core-impl/nm-simple-connection.c @@ -139,7 +139,7 @@ NMConnection * nm_simple_connection_new_clone(NMConnection *connection) { NMConnection *clone; - const char * path; + const char *path; g_return_val_if_fail(NM_IS_CONNECTION(connection), NULL); @@ -164,8 +164,6 @@ dispose(GObject *object) (gpointer) &_nm_assert_connection_unchanging_user_data); #endif - nm_connection_clear_secrets(connection); - _nm_connection_private_clear(_GET_PRIVATE(connection)); G_OBJECT_CLASS(nm_simple_connection_parent_class)->dispose(object); diff --git a/src/libnm-core-impl/nm-team-utils.c b/src/libnm-core-impl/nm-team-utils.c index f67c08be..2f62f6c6 100644 --- a/src/libnm-core-impl/nm-team-utils.c +++ b/src/libnm-core-impl/nm-team-utils.c @@ -133,7 +133,7 @@ static const RunnerCompatElem _runner_compat_lst[] = { typedef struct { const char *const *js_keys; - const char * property_name; + const char *property_name; NMValueTypUnion default_val; union { struct { @@ -377,8 +377,8 @@ typedef enum { LINK_WATCHER_ATTRIBUTE_VLANID, LINK_WATCHER_ATTRIBUTE_SEND_ALWAYS typedef struct { - const char * js_key; - const char * dbus_name; + const char *js_key; + const char *dbus_name; NMValueTypUnion default_val; LinkWatcherAttribute link_watcher_attr; NMValueType value_type; @@ -389,9 +389,9 @@ static const LinkWatcherAttrData link_watcher_attr_datas[] = { [_link_watcher_attr] = {.link_watcher_attr = (_link_watcher_attr), \ .value_type = (_value_type), \ .js_key = (""_js_key \ - ""), \ + ""), \ .dbus_name = (""_dbus_name \ - ""), \ + ""), \ __VA_ARGS__} _INIT(LINK_WATCHER_ATTRIBUTE_NAME, "name", "name", NM_VALUE_TYPE_STRING, ), _INIT(LINK_WATCHER_ATTRIBUTE_DELAY_UP, "delay_up", "delay-up", NM_VALUE_TYPE_INT, ), @@ -547,9 +547,9 @@ _team_attr_data_copy(const TeamAttrData *attr_data, gpointer dst, gconstpointer src) { - GPtrArray * v_ptrarray_dst; + GPtrArray *v_ptrarray_dst; const GPtrArray *v_ptrarray_src; - GPtrArray * dst_array; + GPtrArray *dst_array; guint i, len; if (attr_data->value_type != NM_VALUE_TYPE_UNSPEC) @@ -595,7 +595,7 @@ _team_attr_data_copy(const TeamAttrData *attr_data, static void _team_attr_data_to_json(const TeamAttrData *attr_data, gboolean is_port, - GString * gstr, + GString *gstr, gconstpointer p_field) { guint i; @@ -677,7 +677,7 @@ _team_setting_has_field(const NMTeamSetting *self, const TeamAttrData *attr_data } static gboolean -_team_setting_has_fields_any_v(const NMTeamSetting * self, +_team_setting_has_fields_any_v(const NMTeamSetting *self, const NMTeamAttribute *team_attrs, gsize n_team_attrs) { @@ -698,7 +698,7 @@ _team_setting_has_fields_any_v(const NMTeamSetting * self, NM_NARG(__VA_ARGS__)) static void -_team_setting_has_field_set(NMTeamSetting * self, +_team_setting_has_field_set(NMTeamSetting *self, const TeamAttrData *attr_data, SetFieldModeEnum set_field_mode) { @@ -745,7 +745,7 @@ _team_setting_get_field(const NMTeamSetting *self, const TeamAttrData *attr_data } static guint32 -_team_setting_attribute_changed(NMTeamSetting * self, +_team_setting_attribute_changed(NMTeamSetting *self, const TeamAttrData *attr_data, gboolean changed, SetFieldModeEnum set_field_mode, @@ -785,7 +785,7 @@ _team_setting_attribute_changed(NMTeamSetting * self, } static guint32 -_team_setting_attribute_changed_attr(NMTeamSetting * self, +_team_setting_attribute_changed_attr(NMTeamSetting *self, NMTeamAttribute team_attr, gboolean changed, SetFieldModeEnum set_field_mode, @@ -800,9 +800,9 @@ _team_setting_attribute_changed_attr(NMTeamSetting * self, static gboolean _team_setting_field_to_json(const NMTeamSetting *self, - GString * gstr, + GString *gstr, gboolean prepend_delimiter, - const TeamAttrData * attr_data) + const TeamAttrData *attr_data) { if (!_team_setting_has_field(self, attr_data)) return FALSE; @@ -817,8 +817,8 @@ _team_setting_field_to_json(const NMTeamSetting *self, } static gboolean -_team_setting_fields_to_json_maybe(const NMTeamSetting * self, - GString * gstr, +_team_setting_fields_to_json_maybe(const NMTeamSetting *self, + GString *gstr, gboolean prepend_delimiter, const NMTeamAttribute *team_attrs_lst, gsize team_attrs_lst_len) @@ -839,9 +839,9 @@ _team_setting_fields_to_json_maybe(const NMTeamSetting * self, } static guint32 -_team_setting_set(NMTeamSetting * self, +_team_setting_set(NMTeamSetting *self, gboolean modify, - const bool * has_lst, + const bool *has_lst, const NMValueTypUnion *val_lst) { guint32 changed_flags = 0; @@ -914,7 +914,7 @@ _nm_team_setting_value_get(const NMTeamSetting *self, } static guint32 -_team_setting_value_set(NMTeamSetting * self, +_team_setting_value_set(NMTeamSetting *self, const TeamAttrData *attr_data, gconstpointer val, SetFieldModeEnum set_field_mode, @@ -936,7 +936,7 @@ _team_setting_value_set(NMTeamSetting * self, } guint32 -nm_team_setting_value_reset(NMTeamSetting * self, +nm_team_setting_value_reset(NMTeamSetting *self, NMTeamAttribute team_attr, gboolean to_default /* or else unset */) { @@ -954,7 +954,7 @@ nm_team_setting_value_reset(NMTeamSetting * self, } guint32 -_nm_team_setting_value_set(NMTeamSetting * self, +_nm_team_setting_value_set(NMTeamSetting *self, NMTeamAttribute team_attr, NMValueType value_type, gconstpointer val) @@ -998,7 +998,7 @@ out: } guint32 -nm_team_setting_value_link_watchers_remove_by_value(NMTeamSetting * self, +nm_team_setting_value_link_watchers_remove_by_value(NMTeamSetting *self, const NMTeamLinkWatcher *link_watcher) { guint i; @@ -1026,7 +1026,7 @@ nm_team_setting_value_link_watchers_remove(NMTeamSetting *self, guint idx) } static guint32 -_team_setting_value_link_watchers_set_list(NMTeamSetting * self, +_team_setting_value_link_watchers_set_list(NMTeamSetting *self, const NMTeamLinkWatcher *const *arr, guint len, SetFieldModeEnum set_field_mode, @@ -1074,7 +1074,7 @@ out: } guint32 -nm_team_setting_value_link_watchers_set_list(NMTeamSetting * self, +nm_team_setting_value_link_watchers_set_list(NMTeamSetting *self, const NMTeamLinkWatcher *const *arr, guint len) { @@ -1125,7 +1125,7 @@ nm_team_setting_value_master_runner_tx_hash_remove(NMTeamSetting *self, guint id } static guint32 -_team_setting_value_master_runner_tx_hash_set_list(NMTeamSetting * self, +_team_setting_value_master_runner_tx_hash_set_list(NMTeamSetting *self, const char *const *arr, guint len, SetFieldModeEnum set_field_mode, @@ -1167,7 +1167,7 @@ out: } guint32 -nm_team_setting_value_master_runner_tx_hash_set_list(NMTeamSetting * self, +nm_team_setting_value_master_runner_tx_hash_set_list(NMTeamSetting *self, const char *const *arr, guint len) { @@ -1214,7 +1214,7 @@ static void _link_watcher_unpack(const NMTeamLinkWatcher *link_watcher, NMValueTypUnioMaybe args[static G_N_ELEMENTS(link_watcher_attr_datas)]) { - const char * v_name = nm_team_link_watcher_get_name(link_watcher); + const char *v_name = nm_team_link_watcher_get_name(link_watcher); NMTeamLinkWatcherArpPingFlags v_arp_ping_flags; memset(args, 0, sizeof(args[0]) * G_N_ELEMENTS(link_watcher_attr_datas)); @@ -1305,22 +1305,22 @@ _link_watcher_to_json(const NMTeamLinkWatcher *link_watcher, GString *gstr) } static NMTeamLinkWatcher * -_link_watcher_from_json(const NMJsonVt * vt, +_link_watcher_from_json(const NMJsonVt *vt, const nm_json_t *root_js_obj, - gboolean * out_unrecognized_content) + gboolean *out_unrecognized_content) { NMValueTypUnioMaybe args[G_N_ELEMENTS(link_watcher_attr_datas)] = {}; - const char * j_key; - nm_json_t * j_val; - const char * v_name; - NMTeamLinkWatcher * result = NULL; + const char *j_key; + nm_json_t *j_val; + const char *v_name; + NMTeamLinkWatcher *result = NULL; if (!nm_json_is_object(root_js_obj)) goto fail; nm_json_object_foreach (vt, (nm_json_t *) root_js_obj, j_key, j_val) { const LinkWatcherAttrData *attr_data = NULL; - NMValueTypUnioMaybe * parse_result; + NMValueTypUnioMaybe *parse_result; if (j_key) { int i; @@ -1434,7 +1434,7 @@ _link_watcher_to_variant(const NMTeamLinkWatcher *link_watcher) for (i = 0; i < (int) G_N_ELEMENTS(link_watcher_attr_datas); i++) { const NMValueTypUnioMaybe *p_val = &args[i]; const LinkWatcherAttrData *attr_data = &link_watcher_attr_datas[i]; - GVariant * v; + GVariant *v; if (!p_val->has) continue; @@ -1459,7 +1459,7 @@ _link_watcher_to_variant(const NMTeamLinkWatcher *link_watcher) #define _LINK_WATCHER_ATTR_VARGET(variants, link_watcher_attribute, _value_type, c_type, _cmd) \ ({ \ GVariant *const *_variants = (variants); \ - GVariant * _cc; \ + GVariant *_cc; \ \ nm_assert(link_watcher_attr_datas[(link_watcher_attribute)].value_type == (_value_type)); \ \ @@ -1502,9 +1502,9 @@ _link_watcher_from_variant(GVariant *watcher_var, gboolean strict_parsing, GErro GVariant *variants[G_N_ELEMENTS(link_watcher_attr_datas)] = { NULL, }; - const char * v_key; - GVariant * v_val; - const char * v_name; + const char *v_key; + GVariant *v_val; + const char *v_name; GVariantIter iter; g_return_val_if_fail(g_variant_is_of_type(watcher_var, G_VARIANT_TYPE("a{sv}")), NULL); @@ -1512,8 +1512,8 @@ _link_watcher_from_variant(GVariant *watcher_var, gboolean strict_parsing, GErro g_variant_iter_init(&iter, watcher_var); while (g_variant_iter_next(&iter, "{&sv}", &v_key, &v_val)) { _nm_unused gs_unref_variant GVariant *v_val_free = v_val; - const LinkWatcherAttrData * attr_data = NULL; - const GVariantType * variant_type; + const LinkWatcherAttrData *attr_data = NULL; + const GVariantType *variant_type; int i; for (i = 0; i < (int) G_N_ELEMENTS(link_watcher_attr_datas); i++) { @@ -1704,7 +1704,7 @@ _nm_utils_team_link_watchers_from_variant(GVariant *value, gboolean strict_parsi { gs_unref_ptrarray GPtrArray *link_watchers = NULL; GVariantIter iter; - GVariant * watcher_var; + GVariant *watcher_var; g_return_val_if_fail(g_variant_is_of_type(value, G_VARIANT_TYPE("aa{sv}")), NULL); @@ -1713,7 +1713,7 @@ _nm_utils_team_link_watchers_from_variant(GVariant *value, gboolean strict_parsi g_variant_iter_init(&iter, value); while (g_variant_iter_next(&iter, "@a{sv}", &watcher_var)) { _nm_unused gs_unref_variant GVariant *watcher_var_free = watcher_var; - NMTeamLinkWatcher * watcher; + NMTeamLinkWatcher *watcher; watcher = _link_watcher_from_variant(watcher_var, strict_parsing, error); if (error && *error) @@ -1942,18 +1942,18 @@ _attr_data_find_by_json_key(gboolean is_port, const char *const *keys, guint8 n_ static void _js_parse_locate_keys(const NMJsonVt *vt, - NMTeamSetting * self, - nm_json_t * root_js_obj, - nm_json_t * found_keys[static _NM_TEAM_ATTRIBUTE_NUM], - gboolean * out_unrecognized_content) + NMTeamSetting *self, + nm_json_t *root_js_obj, + nm_json_t *found_keys[static _NM_TEAM_ATTRIBUTE_NUM], + gboolean *out_unrecognized_content) { const char *keys[3]; const char *cur_key1; const char *cur_key2; const char *cur_key3; - nm_json_t * cur_val1; - nm_json_t * cur_val2; - nm_json_t * cur_val3; + nm_json_t *cur_val1; + nm_json_t *cur_val2; + nm_json_t *cur_val3; nm_assert(vt); @@ -2007,12 +2007,12 @@ _js_parse_locate_keys(const NMJsonVt *vt, static void _js_parse_unpack(const NMJsonVt *vt, gboolean is_port, - nm_json_t * found_keys[static _NM_TEAM_ATTRIBUTE_NUM], + nm_json_t *found_keys[static _NM_TEAM_ATTRIBUTE_NUM], bool out_has_lst[static _NM_TEAM_ATTRIBUTE_NUM], NMValueTypUnion out_val_lst[static _NM_TEAM_ATTRIBUTE_NUM], - gboolean * out_unrecognized_content, - GPtrArray ** out_ptr_array_link_watchers_free, - GPtrArray ** out_ptr_array_master_runner_tx_hash_free) + gboolean *out_unrecognized_content, + GPtrArray **out_ptr_array_link_watchers_free, + GPtrArray **out_ptr_array_master_runner_tx_hash_free) { const TeamAttrData *attr_data; @@ -2023,7 +2023,7 @@ _js_parse_unpack(const NMJsonVt *vt, attr_data++) { NMValueTypUnion *p_out_val; gboolean valid = FALSE; - nm_json_t * arg_js_obj; + nm_json_t *arg_js_obj; if (!_team_attr_data_is_relevant(attr_data, is_port)) continue; @@ -2039,7 +2039,7 @@ _js_parse_unpack(const NMJsonVt *vt, if (attr_data->value_type != NM_VALUE_TYPE_UNSPEC) valid = nm_value_type_from_json(vt, attr_data->value_type, arg_js_obj, p_out_val); else if (attr_data->team_attr == NM_TEAM_ATTRIBUTE_LINK_WATCHERS) { - GPtrArray * link_watchers = NULL; + GPtrArray *link_watchers = NULL; NMTeamLinkWatcher *link_watcher; nm_assert(out_ptr_array_link_watchers_free && !*out_ptr_array_link_watchers_free); @@ -2151,7 +2151,7 @@ nm_team_setting_config_set(NMTeamSetting *self, const char *js_str) FALSE, }; NMValueTypUnion val_lst[_NM_TEAM_ATTRIBUTE_NUM]; - nm_json_t * found_keys[_NM_TEAM_ATTRIBUTE_NUM] = { + nm_json_t *found_keys[_NM_TEAM_ATTRIBUTE_NUM] = { NULL, }; gs_unref_ptrarray GPtrArray *ptr_array_master_runner_tx_hash_free = NULL; @@ -2199,9 +2199,9 @@ _team_setting_prefix_error_plain(gboolean is_port, const char *property_name, GE static void _team_setting_prefix_error(const NMTeamSetting *self, - const char * prop_name_master, - const char * prop_name_port, - GError ** error) + const char *prop_name_master, + const char *prop_name_port, + GError **error) { _team_setting_ASSERT(self); nm_assert(self->d.is_port ? (!!prop_name_port) : (!!prop_name_master)); @@ -2501,29 +2501,29 @@ _variants_list_team_unref_auto(GVariant *(*p_variants)[]) } gboolean -nm_team_setting_reset_from_dbus(NMTeamSetting * self, - GVariant * setting_dict, - GHashTable * keys, - guint32 * out_changed, +nm_team_setting_reset_from_dbus(NMTeamSetting *self, + GVariant *setting_dict, + GHashTable *keys, + guint32 *out_changed, guint /* NMSettingParseFlags */ parse_flags, - GError ** error) + GError **error) { nm_auto(_variants_list_team_unref_auto) GVariant *variants[_NM_TEAM_ATTRIBUTE_NUM] = { NULL, }; gs_unref_ptrarray GPtrArray *v_link_watchers = NULL; - const TeamAttrData * attr_data; + const TeamAttrData *attr_data; GVariantIter iter; - const char * v_key; - GVariant * v_val; - const NMJsonVt * vt; + const char *v_key; + GVariant *v_val; + const NMJsonVt *vt; *out_changed = 0; g_variant_iter_init(&iter, setting_dict); while (g_variant_iter_next(&iter, "{&sv}", &v_key, &v_val)) { _nm_unused gs_unref_variant GVariant *v_val_free = v_val; - const GVariantType * variant_type = NULL; + const GVariantType *variant_type = NULL; attr_data = _team_attr_data_find_for_property_name(self->d.is_port, v_key); if (!attr_data) { @@ -2678,7 +2678,7 @@ nm_team_setting_reset_from_dbus(NMTeamSetting * self, /*****************************************************************************/ gboolean -nm_team_setting_maybe_changed(NMSetting * source, +nm_team_setting_maybe_changed(NMSetting *source, const GParamSpec *const *obj_properties, guint32 changed_flags) { @@ -2727,7 +2727,7 @@ _nm_setting_get_team_setting(struct _NMSetting *setting) GVariant * _nm_team_settings_property_to_dbus(_NM_SETT_INFO_PROP_TO_DBUS_FCN_ARGS _nm_nil) { - NMTeamSetting * self = _nm_setting_get_team_setting(setting); + NMTeamSetting *self = _nm_setting_get_team_setting(setting); const TeamAttrData *attr_data = _team_attr_data_get(self->d.is_port, property_info->param_spec->param_id); diff --git a/src/libnm-core-impl/nm-team-utils.h b/src/libnm-core-impl/nm-team-utils.h index d888e191..06fa6cc8 100644 --- a/src/libnm-core-impl/nm-team-utils.h +++ b/src/libnm-core-impl/nm-team-utils.h @@ -87,10 +87,10 @@ struct _NMTeamSettingData { union { struct { const GPtrArray *runner_tx_hash; - const char * runner; - const char * runner_hwaddr_policy; - const char * runner_tx_balancer; - const char * runner_agg_select_policy; + const char *runner; + const char *runner_hwaddr_policy; + const char *runner_tx_balancer; + const char *runner_agg_select_policy; gint32 notify_peers_count; gint32 notify_peers_interval; gint32 mcast_rejoin_count; @@ -169,11 +169,11 @@ nm_team_setting_value_get_string(const NMTeamSetting *self, NMTeamAttribute team /*****************************************************************************/ -guint32 nm_team_setting_value_reset(NMTeamSetting * self, +guint32 nm_team_setting_value_reset(NMTeamSetting *self, NMTeamAttribute team_attr, gboolean to_default /* or else unset */); -guint32 _nm_team_setting_value_set(NMTeamSetting * self, +guint32 _nm_team_setting_value_set(NMTeamSetting *self, NMTeamAttribute team_attr, NMValueType value_type, gconstpointer val); @@ -200,16 +200,16 @@ nm_team_setting_value_set_string(NMTeamSetting *self, NMTeamAttribute team_attr, /*****************************************************************************/ -guint32 nm_team_setting_value_link_watchers_add(NMTeamSetting * self, +guint32 nm_team_setting_value_link_watchers_add(NMTeamSetting *self, const struct NMTeamLinkWatcher *link_watcher); guint32 nm_team_setting_value_link_watchers_remove(NMTeamSetting *self, guint idx); guint32 -nm_team_setting_value_link_watchers_remove_by_value(NMTeamSetting * self, +nm_team_setting_value_link_watchers_remove_by_value(NMTeamSetting *self, const struct NMTeamLinkWatcher *link_watcher); -guint32 nm_team_setting_value_link_watchers_set_list(NMTeamSetting * self, +guint32 nm_team_setting_value_link_watchers_set_list(NMTeamSetting *self, const struct NMTeamLinkWatcher *const *arr, guint len); @@ -219,7 +219,7 @@ guint32 nm_team_setting_value_master_runner_tx_hash_add(NMTeamSetting *self, con guint32 nm_team_setting_value_master_runner_tx_hash_remove(NMTeamSetting *self, guint idx); -guint32 nm_team_setting_value_master_runner_tx_hash_set_list(NMTeamSetting * self, +guint32 nm_team_setting_value_master_runner_tx_hash_set_list(NMTeamSetting *self, const char *const *arr, guint len); @@ -235,12 +235,12 @@ int nm_team_setting_cmp(const NMTeamSetting *self_a, guint32 nm_team_setting_reset(NMTeamSetting *self, const NMTeamSetting *src); -gboolean nm_team_setting_reset_from_dbus(NMTeamSetting * self, - GVariant * setting_dict, - GHashTable * keys, - guint32 * out_changed, +gboolean nm_team_setting_reset_from_dbus(NMTeamSetting *self, + GVariant *setting_dict, + GHashTable *keys, + guint32 *out_changed, guint /* NMSettingParseFlags */ parse_flags, - GError ** error); + GError **error); /*****************************************************************************/ @@ -250,7 +250,7 @@ GVariant *_nm_utils_team_link_watchers_to_variant(const GPtrArray *link_watchers /*****************************************************************************/ -gboolean nm_team_setting_maybe_changed(struct _NMSetting * source, +gboolean nm_team_setting_maybe_changed(struct _NMSetting *source, const GParamSpec *const *obj_properties, guint32 changed); diff --git a/src/libnm-core-impl/nm-utils-private.h b/src/libnm-core-impl/nm-utils-private.h index 679fd6b4..1a6f29ef 100644 --- a/src/libnm-core-impl/nm-utils-private.h +++ b/src/libnm-core-impl/nm-utils-private.h @@ -19,16 +19,16 @@ gboolean _nm_utils_string_slist_validate(GSList *list, const char **valid_values); gboolean _nm_utils_secret_flags_validate(NMSettingSecretFlags secret_flags, - const char * setting_name, - const char * property_name, + const char *setting_name, + const char *property_name, NMSettingSecretFlags disallowed_flags, - GError ** error); + GError **error); gboolean _nm_utils_wps_method_validate(NMSettingWirelessSecurityWpsMethod wps_method, - const char * setting_name, - const char * property_name, + const char *setting_name, + const char *property_name, gboolean wps_required, - GError ** error); + GError **error); /* D-Bus transform funcs */ @@ -44,15 +44,16 @@ void _nm_utils_bytes_from_dbus(GVariant *dbus_value, GValue *prop_value); char *_nm_utils_hwaddr_canonical_or_invalid(const char *mac, gssize length); -char *_nm_utils_ipaddr_canonical_or_invalid(int addr_family, const char *ip); +char * +_nm_utils_ipaddr_canonical_or_invalid(int addr_family, const char *ip, gboolean map_zero_to_null); gboolean _nm_utils_hwaddr_link_local_valid(const char *mac); gboolean _nm_sriov_vf_parse_vlans(NMSriovVF *vf, const char *str, GError **error); -gboolean _nm_utils_bridge_vlan_verify_list(GPtrArray * vlans, +gboolean _nm_utils_bridge_vlan_verify_list(GPtrArray *vlans, gboolean check_normalizable, - GError ** error, + GError **error, const char *setting, const char *property); @@ -66,4 +67,8 @@ void _nm_team_settings_property_from_dbus_link_watchers( GVariant *_nm_utils_ip4_dns_to_variant(const char *const *dns, gssize len); GVariant *_nm_utils_ip6_dns_to_variant(const char *const *dns, gssize len); +const char *const *nmtst_system_encodings_for_lang(const char *lang); +const char *const *nmtst_system_encodings_get_default(void); +const char *const *nmtst_system_encodings_get(void); + #endif diff --git a/src/libnm-core-impl/nm-utils.c b/src/libnm-core-impl/nm-utils.c index ccdd4b92..55b01c15 100644 --- a/src/libnm-core-impl/nm-utils.c +++ b/src/libnm-core-impl/nm-utils.c @@ -79,7 +79,7 @@ NM_IS_SOCK_ADDR_ENDPOINT(const NMSockAddrEndpoint *self) static const char * _parse_endpoint(char *str, guint16 *out_port) { - char * s; + char *s; const char *s_port; gint16 port; @@ -147,8 +147,8 @@ nm_sock_addr_endpoint_new(const char *endpoint) gsize l_endpoint; gsize l_host = 0; gsize i; - gs_free char * host_clone = NULL; - const char * host; + gs_free char *host_clone = NULL; + const char *host; guint16 port; g_return_val_if_fail(endpoint, NULL); @@ -294,7 +294,7 @@ nm_sock_addr_endpoint_get_fixed_sockaddr(NMSockAddrEndpoint *self, gpointer sock { gs_free char *tmp_str = NULL; - const char * host_part; + const char *host_part; host_part = nm_strndup_a(200, self->host, s - self->host, &tmp_str); if (nm_utils_parse_inaddr_bin(AF_INET6, host_part, &addr_family, &addrbin)) @@ -328,169 +328,181 @@ good: /*****************************************************************************/ -struct IsoLangToEncodings { - const char * lang; - const char *const *encodings; -}; +typedef const char *const StrvArray4Type[4]; -#define LANG_ENCODINGS(l, ...) \ - { \ - .lang = l, .encodings = NM_MAKE_STRV(__VA_ARGS__), \ +#define LL(l, ...) \ + { \ + .name = l, .value = {__VA_ARGS__, NULL}, \ } /* 5-letter language codes */ -static const struct IsoLangToEncodings isoLangEntries5[] = { - /* Simplified Chinese */ - LANG_ENCODINGS("zh_cn", "euc-cn", "gb2312", "gb18030"), /* PRC */ - LANG_ENCODINGS("zh_sg", "euc-cn", "gb2312", "gb18030"), /* Singapore */ - - /* Traditional Chinese */ - LANG_ENCODINGS("zh_tw", "big5", "euc-tw"), /* Taiwan */ - LANG_ENCODINGS("zh_hk", "big5", "euc-tw", "big5-hkcs"), /* Hong Kong */ - LANG_ENCODINGS("zh_mo", "big5", "euc-tw"), /* Macau */ - - LANG_ENCODINGS(NULL, NULL)}; +static _NM_UTILS_STRING_TABLE_LOOKUP_DEFINE( + _iso_lang_entries_5_lookup, + StrvArray4Type, + const char *const *, + { nm_assert(name); }, + { return NULL; }, + , + LL("zh_cn", "euc-cn", "gb2312", "gb18030"), /* Simplified Chinese, PRC */ + LL("zh_hk", "big5", "euc-tw", "big5-hkcs"), /* Traditional Chinese, Hong Kong */ + LL("zh_mo", "big5", "euc-tw"), /* Traditional Chinese, Macau */ + LL("zh_sg", "euc-cn", "gb2312", "gb18030"), /* Simplified Chinese, Singapore */ + LL("zh_tw", "big5", "euc-tw"), /* Traditional Chinese, Taiwan */ +); /* 2-letter language codes; we don't care about the other 3 in this table */ -static const struct IsoLangToEncodings isoLangEntries2[] = { - /* Japanese */ - LANG_ENCODINGS("ja", "euc-jp", "shift_jis", "iso-2022-jp"), - - /* Korean */ - LANG_ENCODINGS("ko", "euc-kr", "iso-2022-kr", "johab"), - - /* Thai */ - LANG_ENCODINGS("th", "iso-8859-11", "windows-874"), - - /* Central European */ - LANG_ENCODINGS("hu", "iso-8859-2", "windows-1250"), /* Hungarian */ - LANG_ENCODINGS("cs", "iso-8859-2", "windows-1250"), /* Czech */ - LANG_ENCODINGS("hr", "iso-8859-2", "windows-1250"), /* Croatian */ - LANG_ENCODINGS("pl", "iso-8859-2", "windows-1250"), /* Polish */ - LANG_ENCODINGS("ro", "iso-8859-2", "windows-1250"), /* Romanian */ - LANG_ENCODINGS("sk", "iso-8859-2", "windows-1250"), /* Slovakian */ - LANG_ENCODINGS("sl", "iso-8859-2", "windows-1250"), /* Slovenian */ - LANG_ENCODINGS("sh", "iso-8859-2", "windows-1250"), /* Serbo-Croatian */ - - /* Cyrillic */ - LANG_ENCODINGS("ru", "koi8-r", "windows-1251", "iso-8859-5"), /* Russian */ - LANG_ENCODINGS("be", "koi8-r", "windows-1251", "iso-8859-5"), /* Belorussian */ - LANG_ENCODINGS("bg", "windows-1251", "koi8-r", "iso-8859-5"), /* Bulgarian */ - LANG_ENCODINGS("mk", "koi8-r", "windows-1251", "iso-8859-5"), /* Macedonian */ - LANG_ENCODINGS("sr", "koi8-r", "windows-1251", "iso-8859-5"), /* Serbian */ - LANG_ENCODINGS("uk", "koi8-u", "koi8-r", "windows-1251"), /* Ukrainian */ - - /* Arabic */ - LANG_ENCODINGS("ar", "iso-8859-6", "windows-1256"), - - /* Baltic */ - LANG_ENCODINGS("et", "iso-8859-4", "windows-1257"), /* Estonian */ - LANG_ENCODINGS("lt", "iso-8859-4", "windows-1257"), /* Lithuanian */ - LANG_ENCODINGS("lv", "iso-8859-4", "windows-1257"), /* Latvian */ - - /* Greek */ - LANG_ENCODINGS("el", "iso-8859-7", "windows-1253"), - - /* Hebrew */ - LANG_ENCODINGS("he", "iso-8859-8", "windows-1255"), - LANG_ENCODINGS("iw", "iso-8859-8", "windows-1255"), - - /* Turkish */ - LANG_ENCODINGS("tr", "iso-8859-9", "windows-1254"), - - /* Table end */ - LANG_ENCODINGS(NULL, NULL)}; - -static GHashTable *langToEncodings5 = NULL; -static GHashTable *langToEncodings2 = NULL; +static _NM_UTILS_STRING_TABLE_LOOKUP_DEFINE( + _iso_lang_entries_2_lookup, + StrvArray4Type, + const char *const *, + { nm_assert(name); }, + { return NULL; }, + , + LL("ar", "iso-8859-6", "windows-1256"), /* Arabic */ + LL("be", "koi8-r", "windows-1251", "iso-8859-5"), /* Cyrillic, Belorussian */ + LL("bg", "windows-1251", "koi8-r", "iso-8859-5"), /* Cyrillic, Bulgarian */ + LL("cs", "iso-8859-2", "windows-1250"), /* Central European, Czech */ + LL("el", "iso-8859-7", "windows-1253"), /* Greek */ + LL("et", "iso-8859-4", "windows-1257"), /* Baltic, Estonian */ + LL("he", "iso-8859-8", "windows-1255"), /* Hebrew */ + LL("hr", "iso-8859-2", "windows-1250"), /* Central European, Croatian */ + LL("hu", "iso-8859-2", "windows-1250"), /* Central European, Hungarian */ + LL("iw", "iso-8859-8", "windows-1255"), /* Hebrew */ + LL("ja", "euc-jp", "shift_jis", "iso-2022-jp"), /* Japanese */ + LL("ko", "euc-kr", "iso-2022-kr", "johab"), /* Korean */ + LL("lt", "iso-8859-4", "windows-1257"), /* Baltic, Lithuanian */ + LL("lv", "iso-8859-4", "windows-1257"), /* Baltic, Latvian */ + LL("mk", "koi8-r", "windows-1251", "iso-8859-5"), /* Cyrillic, Macedonian */ + LL("pl", "iso-8859-2", "windows-1250"), /* Central European, Polish */ + LL("ro", "iso-8859-2", "windows-1250"), /* Central European, Romanian */ + LL("ru", "koi8-r", "windows-1251", "iso-8859-5"), /* Cyrillic, Russian */ + LL("sh", "iso-8859-2", "windows-1250"), /* Central European, Serbo-Croatian */ + LL("sk", "iso-8859-2", "windows-1250"), /* Central European, Slovakian */ + LL("sl", "iso-8859-2", "windows-1250"), /* Central European, Slovenian */ + LL("sr", "koi8-r", "windows-1251", "iso-8859-5"), /* Cyrillic, Serbian */ + LL("th", "iso-8859-11", "windows-874"), /* Thai */ + LL("tr", "iso-8859-9", "windows-1254"), /* Turkish */ + LL("uk", "koi8-u", "koi8-r", "windows-1251"), /* Cyrillic, Ukrainian */ +); -static void -init_lang_to_encodings_hash(void) +static const char *const * +_system_encodings_for_lang(const char *lang) { - struct IsoLangToEncodings *enc; + char tmp_lang[3]; + const char *const *e; - if (G_UNLIKELY(langToEncodings5 == NULL)) { - /* Five-letter codes */ - enc = (struct IsoLangToEncodings *) &isoLangEntries5[0]; - langToEncodings5 = g_hash_table_new(nm_str_hash, g_str_equal); - while (enc->lang) { - g_hash_table_insert(langToEncodings5, (gpointer) enc->lang, (gpointer) enc->encodings); - enc++; - } + nm_assert(lang); + + if (lang[0] == '\0' || lang[1] == '\0') { + /* need at least two characters. */ + nm_assert(!_iso_lang_entries_5_lookup(lang)); + nm_assert(!_iso_lang_entries_2_lookup(lang)); + return NULL; } - if (G_UNLIKELY(langToEncodings2 == NULL)) { - /* Two-letter codes */ - enc = (struct IsoLangToEncodings *) &isoLangEntries2[0]; - langToEncodings2 = g_hash_table_new(nm_str_hash, g_str_equal); - while (enc->lang) { - g_hash_table_insert(langToEncodings2, (gpointer) enc->lang, (gpointer) enc->encodings); - enc++; - } + if (lang[2] != '\0') { + nm_assert(!_iso_lang_entries_2_lookup(lang)); + + if (lang[3] != '\0' && lang[4] != '\0' && lang[5] == '\0') { + /* lang is 5 characters long. Try it. */ + if ((e = _iso_lang_entries_5_lookup(lang))) + return e; + } else + nm_assert(!_iso_lang_entries_5_lookup(lang)); + + /* extract the first 2 characters and ignore the rest. */ + tmp_lang[0] = lang[0]; + tmp_lang[1] = lang[1]; + tmp_lang[2] = '\0'; + lang = tmp_lang; } + + if ((e = _iso_lang_entries_2_lookup(lang))) + return e; + + return NULL; } -static gboolean -get_encodings_for_lang(const char *lang, const char *const **encodings) +const char *const * +nmtst_system_encodings_for_lang(const char *lang) +{ + return _system_encodings_for_lang(lang); +} + +static const char *const * +_system_encodings_get_default(void) { - gs_free char *tmp_lang = NULL; + static gsize init_once = 0; + static const char *default_encodings[4]; - g_return_val_if_fail(lang, FALSE); - g_return_val_if_fail(encodings, FALSE); + if (g_once_init_enter(&init_once)) { + const char *e_default = NULL; + int i; - init_lang_to_encodings_hash(); + g_get_charset(&e_default); - if ((*encodings = g_hash_table_lookup(langToEncodings5, lang))) - return TRUE; + i = 0; + if (e_default) + default_encodings[i++] = e_default; + if (!nm_streq0(e_default, "iso-8859-1")) + default_encodings[i++] = "iso-8859-1"; + if (!nm_streq0(e_default, "windows-1251")) + default_encodings[i++] = "windows-1251"; + default_encodings[i++] = NULL; + nm_assert(i <= G_N_ELEMENTS(default_encodings)); - /* Truncate tmp_lang to length of 2 */ - if (strlen(lang) > 2) { - tmp_lang = g_strdup(lang); - tmp_lang[2] = '\0'; - if ((*encodings = g_hash_table_lookup(langToEncodings2, tmp_lang))) - return TRUE; + g_once_init_leave(&init_once, 1); } - return FALSE; + return default_encodings; +} + +const char *const * +nmtst_system_encodings_get_default(void) +{ + return _system_encodings_get_default(); } static const char *const * -get_system_encodings(void) +_system_encodings_get(void) { - static const char *const *cached_encodings; - static char * default_encodings[4]; - const char *const * encodings = NULL; - char * lang; + static const char *const *cached = NULL; + const char *const *e; - if (cached_encodings) - return cached_encodings; +again: + if (!(e = g_atomic_pointer_get(&cached))) { + const char *lang; - /* Use environment variables as encoding hint */ - lang = getenv("LC_ALL"); - if (!lang) - lang = getenv("LC_CTYPE"); - if (!lang) - lang = getenv("LANG"); - if (lang) { - char *dot; + /* Use environment variables as encoding hint */ + lang = getenv("LC_ALL") ?: getenv("LC_CTYPE") ?: getenv("LANG"); - lang = g_ascii_strdown(lang, -1); - if ((dot = strchr(lang, '.'))) - *dot = '\0'; + if (lang) { + gs_free char *lang_down = NULL; + char *dot; - get_encodings_for_lang(lang, &encodings); - g_free(lang); - } - if (!encodings) { - g_get_charset((const char **) &default_encodings[0]); - default_encodings[1] = "iso-8859-1"; - default_encodings[2] = "windows-1251"; - default_encodings[3] = NULL; - encodings = (const char *const *) default_encodings; + lang_down = g_ascii_strdown(lang, -1); + if ((dot = strchr(lang_down, '.'))) + *dot = '\0'; + e = _system_encodings_for_lang(lang_down); + } + + if (!e) + e = _system_encodings_get_default(); + + /* in any case, @e is now a static buffer, that we may cache. */ + nm_assert(e); + + if (!g_atomic_pointer_compare_and_exchange(&cached, NULL, e)) + goto again; } - cached_encodings = encodings; - return cached_encodings; + return e; +} + +const char *const * +nmtst_system_encodings_get(void) +{ + return _system_encodings_get(); } /*****************************************************************************/ @@ -560,14 +572,14 @@ nm_utils_ssid_to_utf8(const guint8 *ssid, gsize len) { const char *const *encodings; const char *const *e; - char * converted = NULL; + char *converted = NULL; g_return_val_if_fail(ssid != NULL, NULL); if (g_utf8_validate((const char *) ssid, len, NULL)) return g_strndup((const char *) ssid, len); - encodings = get_system_encodings(); + encodings = _system_encodings_get(); for (e = encodings; *e; e++) { converted = g_convert((const char *) ssid, len, "UTF-8", *e, NULL, NULL, NULL); @@ -652,7 +664,7 @@ nm_utils_escape_ssid(const guint8 *ssid, gsize len) { static char escaped[NM_IW_ESSID_MAX_SIZE * 2 + 1]; const guint8 *s = ssid; - char * d = escaped; + char *d = escaped; if (nm_utils_is_empty_ssid(ssid, len)) { memcpy(escaped, "<hidden>", sizeof("<hidden>")); @@ -746,9 +758,9 @@ _nm_utils_string_slist_validate(GSList *list, const char **valid_values) GSList * _nm_utils_hash_values_to_slist(GHashTable *hash) { - GSList * list = NULL; + GSList *list = NULL; GHashTableIter iter; - void * value; + void *value; g_return_val_if_fail(hash, NULL); @@ -763,8 +775,8 @@ void _nm_utils_strdict_from_dbus(_NM_SETT_INFO_PROP_FROM_DBUS_GPROP_FCN_ARGS _nm_nil) { GVariantIter iter; - const char * key, *value; - GHashTable * hash; + const char *key, *value; + GHashTable *hash; hash = g_hash_table_new_full(nm_str_hash, g_str_equal, g_free, g_free); g_variant_iter_init(&iter, from); @@ -786,7 +798,7 @@ const NMSettInfoPropertType nm_sett_info_propert_type_strdict = GHashTable * _nm_utils_copy_strdict(GHashTable *strdict) { - GHashTable * copy; + GHashTable *copy; GHashTableIter iter; gpointer key, value; @@ -861,7 +873,7 @@ char ** _nm_utils_slist_to_strv(const GSList *slist, gboolean deep_copy) { const GSList *iter; - char ** strv; + char **strv; guint len, i; if (!slist) @@ -1328,7 +1340,7 @@ nm_utils_ip4_dns_from_variant(GVariant *value) { const guint32 *array; gsize length; - char ** dns; + char **dns; gsize i; g_return_val_if_fail(g_variant_is_of_type(value, G_VARIANT_TYPE("au")), NULL); @@ -1409,9 +1421,9 @@ nm_utils_ip4_addresses_to_variant(GPtrArray *addresses, const char *gateway) GPtrArray * nm_utils_ip4_addresses_from_variant(GVariant *value, char **out_gateway) { - GPtrArray * addresses; + GPtrArray *addresses; GVariantIter iter; - GVariant * addr_var; + GVariant *addr_var; g_return_val_if_fail(g_variant_is_of_type(value, G_VARIANT_TYPE("aau")), NULL); @@ -1424,8 +1436,8 @@ nm_utils_ip4_addresses_from_variant(GVariant *value, char **out_gateway) while (g_variant_iter_next(&iter, "@au", &addr_var)) { const guint32 *addr_array; gsize length; - NMIPAddress * addr; - GError * error = NULL; + NMIPAddress *addr; + GError *error = NULL; addr_array = g_variant_get_fixed_array(addr_var, &length, sizeof(guint32)); if (length < 3) { @@ -1506,8 +1518,8 @@ GPtrArray * nm_utils_ip4_routes_from_variant(GVariant *value) { GVariantIter iter; - GVariant * route_var; - GPtrArray * routes; + GVariant *route_var; + GPtrArray *routes; g_return_val_if_fail(g_variant_is_of_type(value, G_VARIANT_TYPE("aau")), NULL); @@ -1517,8 +1529,8 @@ nm_utils_ip4_routes_from_variant(GVariant *value) while (g_variant_iter_next(&iter, "@au", &route_var)) { const guint32 *route_array; gsize length; - NMIPRoute * route; - GError * error = NULL; + NMIPRoute *route; + GError *error = NULL; route_array = g_variant_get_fixed_array(route_var, &length, sizeof(guint32)); if (length < 4) { @@ -1647,8 +1659,8 @@ char ** nm_utils_ip6_dns_from_variant(GVariant *value) { GVariantIter iter; - GVariant * ip_var; - char ** dns; + GVariant *ip_var; + char **dns; gsize i; g_return_val_if_fail(g_variant_is_of_type(value, G_VARIANT_TYPE("aay")), NULL); @@ -1695,7 +1707,7 @@ nm_utils_ip6_addresses_to_variant(GPtrArray *addresses, const char *gateway) if (addresses) { for (i = 0; i < addresses->len; i++) { - NMIPAddress * addr = addresses->pdata[i]; + NMIPAddress *addr = addresses->pdata[i]; struct in6_addr address_bin; struct in6_addr gateway_bin_data; const struct in6_addr *gateway_bin; @@ -1741,9 +1753,9 @@ GPtrArray * nm_utils_ip6_addresses_from_variant(GVariant *value, char **out_gateway) { GVariantIter iter; - GVariant * addr_var, *gateway_var; + GVariant *addr_var, *gateway_var; guint32 prefix; - GPtrArray * addresses; + GPtrArray *addresses; g_return_val_if_fail(g_variant_is_of_type(value, G_VARIANT_TYPE("a(ayuay)")), NULL); @@ -1754,10 +1766,10 @@ nm_utils_ip6_addresses_from_variant(GVariant *value, char **out_gateway) addresses = g_ptr_array_new_with_free_func((GDestroyNotify) nm_ip_address_unref); while (g_variant_iter_next(&iter, "(@ayu@ay)", &addr_var, &prefix, &gateway_var)) { - NMIPAddress * addr; + NMIPAddress *addr; const struct in6_addr *addr_bytes, *gateway_bytes; gsize addr_len, gateway_len; - GError * error = NULL; + GError *error = NULL; if (!g_variant_is_of_type(addr_var, G_VARIANT_TYPE_BYTESTRING) || !g_variant_is_of_type(gateway_var, G_VARIANT_TYPE_BYTESTRING)) { @@ -1820,7 +1832,7 @@ nm_utils_ip6_routes_to_variant(GPtrArray *routes) if (routes) { for (i = 0; i < routes->len; i++) { - NMIPRoute * route = routes->pdata[i]; + NMIPRoute *route = routes->pdata[i]; struct in6_addr dest_bytes; struct in6_addr next_hop_bytes; guint32 metric; @@ -1860,9 +1872,9 @@ nm_utils_ip6_routes_to_variant(GPtrArray *routes) GPtrArray * nm_utils_ip6_routes_from_variant(GVariant *value) { - GPtrArray * routes; + GPtrArray *routes; GVariantIter iter; - GVariant * dest_var, *next_hop_var; + GVariant *dest_var, *next_hop_var; const struct in6_addr *dest, *next_hop; gsize dest_len, next_hop_len; guint32 prefix, metric; @@ -1874,7 +1886,7 @@ nm_utils_ip6_routes_from_variant(GVariant *value) g_variant_iter_init(&iter, value); while (g_variant_iter_next(&iter, "(@ayu@ayu)", &dest_var, &prefix, &next_hop_var, &metric)) { NMIPRoute *route; - GError * error = NULL; + GError *error = NULL; if (!g_variant_is_of_type(dest_var, G_VARIANT_TYPE_BYTESTRING) || !g_variant_is_of_type(next_hop_var, G_VARIANT_TYPE_BYTESTRING)) { @@ -1939,7 +1951,7 @@ nm_utils_ip_addresses_to_variant(GPtrArray *addresses) if (addresses) { for (i = 0; i < addresses->len; i++) { - NMIPAddress * addr = addresses->pdata[i]; + NMIPAddress *addr = addresses->pdata[i]; GVariantBuilder addr_builder; gs_free const char **names = NULL; guint j, len; @@ -1985,15 +1997,15 @@ nm_utils_ip_addresses_to_variant(GPtrArray *addresses) GPtrArray * nm_utils_ip_addresses_from_variant(GVariant *value, int family) { - GPtrArray * addresses; + GPtrArray *addresses; GVariantIter iter, attrs_iter; - GVariant * addr_var; - const char * ip; + GVariant *addr_var; + const char *ip; guint32 prefix; - const char * attr_name; - GVariant * attr_val; + const char *attr_name; + GVariant *attr_val; NMIPAddress *addr; - GError * error = NULL; + GError *error = NULL; g_return_val_if_fail(g_variant_is_of_type(value, G_VARIANT_TYPE("aa{sv}")), NULL); @@ -2051,7 +2063,7 @@ nm_utils_ip_routes_to_variant(GPtrArray *routes) if (routes) { for (i = 0; i < routes->len; i++) { - NMIPRoute * route = routes->pdata[i]; + NMIPRoute *route = routes->pdata[i]; GVariantBuilder route_builder; gs_free const char **names = NULL; guint j, len; @@ -2110,16 +2122,16 @@ nm_utils_ip_routes_to_variant(GPtrArray *routes) GPtrArray * nm_utils_ip_routes_from_variant(GVariant *value, int family) { - GPtrArray * routes; + GPtrArray *routes; GVariantIter iter, attrs_iter; - GVariant * route_var; - const char * dest, *next_hop; + GVariant *route_var; + const char *dest, *next_hop; guint32 prefix, metric32; gint64 metric; - const char * attr_name; - GVariant * attr_val; - NMIPRoute * route; - GError * error = NULL; + const char *attr_name; + GVariant *attr_val; + NMIPRoute *route; + GError *error = NULL; g_return_val_if_fail(g_variant_is_of_type(value, G_VARIANT_TYPE("aa{sv}")), NULL); @@ -2297,7 +2309,7 @@ static const NMVariantAttributeSpec *const tc_qdisc_fq_codel_spec[] = { }; typedef struct { - const char * kind; + const char *kind; const NMVariantAttributeSpec *const *attrs; } NMQdiscAttributeSpec; @@ -2323,7 +2335,7 @@ void _nm_utils_string_append_tc_qdisc_rest(GString *string, NMTCQdisc *qdisc) { guint32 handle = nm_tc_qdisc_get_handle(qdisc); - const char * kind = nm_tc_qdisc_get_kind(qdisc); + const char *kind = nm_tc_qdisc_get_kind(qdisc); gs_free char *str = NULL; if (handle != TC_H_UNSPEC && !NM_IN_STRSET(kind, "ingress", "clsact")) { @@ -2368,14 +2380,14 @@ nm_utils_tc_qdisc_to_str(NMTCQdisc *qdisc, GError **error) static gboolean _tc_read_common_opts(const char *str, - guint32 * handle, - guint32 * parent, - char ** kind, - char ** rest, - GError ** error) + guint32 *handle, + guint32 *parent, + char **kind, + char **rest, + GError **error) { gs_unref_hashtable GHashTable *ht = NULL; - GVariant * variant; + GVariant *variant; ht = nm_utils_parse_variant_attributes(str, ' ', ' ', FALSE, tc_object_attribute_spec, error); if (!ht) @@ -2456,11 +2468,11 @@ _tc_read_common_opts(const char *str, NMTCQdisc * nm_utils_tc_qdisc_from_str(const char *str, GError **error) { - guint32 handle = TC_H_UNSPEC; - guint32 parent = TC_H_UNSPEC; - gs_free char * kind = NULL; - gs_free char * rest = NULL; - NMTCQdisc * qdisc = NULL; + guint32 handle = TC_H_UNSPEC; + guint32 parent = TC_H_UNSPEC; + gs_free char *kind = NULL; + gs_free char *rest = NULL; + NMTCQdisc *qdisc = NULL; gs_unref_hashtable GHashTable *options = NULL; GHashTableIter iter; gpointer key, value; @@ -2541,8 +2553,8 @@ static const NMVariantAttributeSpec *const tc_action_attribute_spec[] = { static gboolean _string_append_tc_action(GString *string, NMTCAction *action, GError **error) { - const char * kind = nm_tc_action_get_kind(action); - gs_free char * str = NULL; + const char *kind = nm_tc_action_get_kind(action); + gs_free char *str = NULL; const NMVariantAttributeSpec *const *attrs; if (nm_streq(kind, "simple")) @@ -2605,12 +2617,12 @@ nm_utils_tc_action_to_str(NMTCAction *action, GError **error) NMTCAction * nm_utils_tc_action_from_str(const char *str, GError **error) { - const char * kind = NULL; - const char * rest = NULL; - nm_auto_unref_tc_action NMTCAction *action = NULL; - gs_unref_hashtable GHashTable *ht = NULL; - gs_unref_hashtable GHashTable * options = NULL; - GVariant * variant; + const char *kind = NULL; + const char *rest = NULL; + nm_auto_unref_tc_action NMTCAction *action = NULL; + gs_unref_hashtable GHashTable *ht = NULL; + gs_unref_hashtable GHashTable *options = NULL; + GVariant *variant; const NMVariantAttributeSpec *const *attrs; nm_assert(str); @@ -2753,15 +2765,15 @@ static const NMVariantAttributeSpec *const tc_tfilter_attribute_spec[] = { NMTCTfilter * nm_utils_tc_tfilter_from_str(const char *str, GError **error) { - guint32 handle = TC_H_UNSPEC; - guint32 parent = TC_H_UNSPEC; - gs_free char * kind = NULL; - gs_free char * rest = NULL; + guint32 handle = TC_H_UNSPEC; + guint32 parent = TC_H_UNSPEC; + gs_free char *kind = NULL; + gs_free char *rest = NULL; nm_auto_unref_tc_action NMTCAction *action = NULL; - const char * extra_opts = NULL; - NMTCTfilter * tfilter = NULL; - gs_unref_hashtable GHashTable *ht = NULL; - GVariant * variant; + const char *extra_opts = NULL; + NMTCTfilter *tfilter = NULL; + gs_unref_hashtable GHashTable *ht = NULL; + GVariant *variant; nm_assert(str); nm_assert(!error || !*error); @@ -2826,11 +2838,11 @@ char * nm_utils_sriov_vf_to_str(const NMSriovVF *vf, gboolean omit_index, GError **error) { gs_free NMUtilsNamedValue *values = NULL; - gs_free const char ** names = NULL; - const guint * vlan_ids; + gs_free const char **names = NULL; + const guint *vlan_ids; guint num_vlans, num_attrs; guint i; - GString * str; + GString *str; str = g_string_new(""); if (!omit_index) @@ -2987,7 +2999,7 @@ NMSriovVF * nm_utils_sriov_vf_from_str(const char *str, GError **error) { gs_free char *index_free = NULL; - const char * detail; + const char *detail; g_return_val_if_fail(str, NULL); g_return_val_if_fail(!error || !*error, NULL); @@ -3008,13 +3020,13 @@ NMSriovVF * _nm_utils_sriov_vf_from_strparts(const char *index, const char *detail, gboolean ignore_unknown, - GError ** error) + GError **error) { - NMSriovVF * vf; - guint32 n_index; - GHashTableIter iter; - char * key; - GVariant * variant; + NMSriovVF *vf; + guint32 n_index; + GHashTableIter iter; + char *key; + GVariant *variant; gs_unref_hashtable GHashTable *ht = NULL; n_index = _nm_utils_ascii_str_to_int64(index, 10, 0, G_MAXUINT32, 0); @@ -3102,7 +3114,7 @@ file_has_extension(const char *filename, const char *extensions[]) gboolean nm_utils_file_is_certificate(const char *filename) { - const char * extensions[] = {".der", ".pem", ".crt", ".cer", NULL}; + const char *extensions[] = {".der", ".pem", ".crt", ".cer", NULL}; NMCryptoFileFormat file_format; g_return_val_if_fail(filename != NULL, FALSE); @@ -3160,12 +3172,12 @@ nm_utils_file_is_pkcs12(const char *filename) /*****************************************************************************/ gboolean -_nm_utils_check_file(const char * filename, +_nm_utils_check_file(const char *filename, gint64 check_owner, NMUtilsCheckFilePredicate check_file, gpointer user_data, - struct stat * out_st, - GError ** error) + struct stat *out_st, + GError **error) { struct stat st_backup; @@ -3232,11 +3244,11 @@ _nm_utils_check_file(const char * filename, } gboolean -_nm_utils_check_module_file(const char * name, +_nm_utils_check_module_file(const char *name, int check_owner, NMUtilsCheckFilePredicate check_file, gpointer user_data, - GError ** error) + GError **error) { if (!g_path_is_absolute(name)) { g_set_error(error, @@ -3310,13 +3322,13 @@ _nm_utils_check_module_file(const char * name, * invocations of the function might overwrite it. */ const char * -nm_utils_file_search_in_paths(const char * progname, - const char * try_first, - const char *const * paths, +nm_utils_file_search_in_paths(const char *progname, + const char *try_first, + const char *const *paths, GFileTest file_test_flags, NMUtilsFileSearchInPathsPredicate predicate, gpointer user_data, - GError ** error) + GError **error) { g_return_val_if_fail(!error || !*error, NULL); g_return_val_if_fail(progname && progname[0] && !strchr(progname, '/'), NULL); @@ -3899,19 +3911,19 @@ _nm_utils_hwaddr_canonical_or_invalid(const char *mac, gssize length) } char * -_nm_utils_ipaddr_canonical_or_invalid(int addr_family, const char *ip) +_nm_utils_ipaddr_canonical_or_invalid(int addr_family, const char *ip, gboolean map_zero_to_null) { NMIPAddr addr_bin; - nm_assert_addr_family(addr_family); + nm_assert_addr_family_or_unspec(addr_family); if (!ip) return NULL; - if (!nm_utils_parse_inaddr_bin(addr_family, ip, NULL, &addr_bin)) + if (!nm_utils_parse_inaddr_bin(addr_family, ip, &addr_family, &addr_bin)) return g_strdup(ip); - if (nm_ip_addr_is_null(addr_family, &addr_bin)) + if (map_zero_to_null && nm_ip_addr_is_null(addr_family, &addr_bin)) return NULL; return nm_utils_inet_ntop_dup(addr_family, &addr_bin); @@ -4078,7 +4090,7 @@ _nm_utils_hwaddr_cloned_set(_NM_SETT_INFO_PROP_FROM_DBUS_FCN_ARGS _nm_nil) { gsize length; const guint8 *array; - char * str; + char *str; nm_assert(nm_streq0(property_info->name, "cloned-mac-address")); @@ -4174,10 +4186,10 @@ const NMSettInfoPropertType nm_sett_info_propert_type_assigned_mac_address = * For new settings, they shall validate the secret-flags strictly. */ gboolean _nm_utils_secret_flags_validate(NMSettingSecretFlags secret_flags, - const char * setting_name, - const char * property_name, + const char *setting_name, + const char *property_name, NMSettingSecretFlags disallowed_flags, - GError ** error) + GError **error) { if (secret_flags == NM_SETTING_SECRET_FLAG_NONE) return TRUE; @@ -4226,10 +4238,10 @@ _nm_utils_secret_flags_validate(NMSettingSecretFlags secret_flags, gboolean _nm_utils_wps_method_validate(NMSettingWirelessSecurityWpsMethod wps_method, - const char * setting_name, - const char * property_name, + const char *setting_name, + const char *property_name, gboolean wps_required, - GError ** error) + GError **error) { if (wps_method > NM_SETTING_WIRELESS_SECURITY_WPS_METHOD_PIN) { g_set_error_literal(error, @@ -4283,15 +4295,15 @@ _split_word(char *s) } gboolean -_nm_utils_generate_mac_address_mask_parse(const char * value, - struct ether_addr * out_mask, +_nm_utils_generate_mac_address_mask_parse(const char *value, + struct ether_addr *out_mask, struct ether_addr **out_ouis, - gsize * out_ouis_len, - GError ** error) + gsize *out_ouis_len, + GError **error) { - gs_free char * s_free = NULL; - char * s, *s_next; - struct ether_addr mask; + gs_free char *s_free = NULL; + char *s, *s_next; + struct ether_addr mask; gs_unref_array GArray *ouis = NULL; g_return_val_if_fail(!error || !*error, FALSE); @@ -4694,7 +4706,7 @@ guint _nm_utils_strstrdictkey_hash(gconstpointer a) { const NMUtilsStrStrDictKey *k = a; - const char * p; + const char *p; NMHashState h; nm_hash_init(&h, 76642997u); @@ -4777,7 +4789,7 @@ _nm_utils_strstrdictkey_create(const char *v1, const char *v2) } static gboolean -validate_dns_option(const char * name, +validate_dns_option(const char *name, gboolean numeric, gboolean ipv6, const NMUtilsDNSOptionDesc *option_descs) @@ -4813,16 +4825,16 @@ validate_dns_option(const char * name, * %FALSE otherwise */ gboolean -_nm_utils_dns_option_validate(const char * option, - char ** out_name, - long * out_value, +_nm_utils_dns_option_validate(const char *option, + char **out_name, + long *out_value, gboolean ipv6, const NMUtilsDNSOptionDesc *option_descs) { gs_free char *option0_free = NULL; - const char * option0; - const char * option1; - const char * delim; + const char *option0; + const char *option1; + const char *delim; long option1_num; g_return_val_if_fail(option != NULL, FALSE); @@ -5013,7 +5025,7 @@ gboolean nm_utils_is_json_object(const char *str, GError **error) { nm_auto_decref_json nm_json_t *json = NULL; - const NMJsonVt * vt; + const NMJsonVt *vt; nm_json_error_t jerror; g_return_val_if_fail(!error || !*error, FALSE); @@ -5097,7 +5109,7 @@ _nmtst_variant_attribute_spec_assert_sorted(const NMVariantAttributeSpec *const const NMVariantAttributeSpec * _nm_variant_attribute_spec_find_binary_search(const NMVariantAttributeSpec *const *array, gsize len, - const char * name) + const char *name) { gssize idx; @@ -5132,16 +5144,16 @@ _nm_variant_attribute_spec_find_binary_search(const NMVariantAttributeSpec *cons * Since: 1.8 */ GHashTable * -nm_utils_parse_variant_attributes(const char * string, +nm_utils_parse_variant_attributes(const char *string, char attr_separator, char key_value_separator, gboolean ignore_unknown, const NMVariantAttributeSpec *const *spec, - GError ** error) + GError **error) { - gs_unref_hashtable GHashTable * ht = NULL; - const char * ptr = string, *start = NULL, *sep; - GVariant * variant; + gs_unref_hashtable GHashTable *ht = NULL; + const char *ptr = string, *start = NULL, *sep; + GVariant *variant; const NMVariantAttributeSpec *const *s; g_return_val_if_fail(string, NULL); @@ -5460,11 +5472,11 @@ nm_utils_base64secret_decode(const char *base64_key, gsize required_key_len, gui gboolean nm_utils_base64secret_normalize(const char *base64_key, gsize required_key_len, - char ** out_base64_key_norm) + char **out_base64_key_norm) { gs_free guint8 *buf_free = NULL; guint8 buf_static[200]; - guint8 * buf; + guint8 *buf; if (required_key_len > sizeof(buf_static)) { buf_free = g_new(guint8, required_key_len); @@ -5488,7 +5500,7 @@ _nm_utils_bridge_vlans_to_dbus(_NM_SETT_INFO_PROP_TO_DBUS_FCN_ARGS _nm_nil) gs_unref_ptrarray GPtrArray *vlans = NULL; GVariantBuilder builder; guint i; - const char * property_name = property_info->name; + const char *property_name = property_info->name; nm_assert(property_name); @@ -5497,7 +5509,7 @@ _nm_utils_bridge_vlans_to_dbus(_NM_SETT_INFO_PROP_TO_DBUS_FCN_ARGS _nm_nil) if (vlans) { for (i = 0; i < vlans->len; i++) { - NMBridgeVlan * vlan = vlans->pdata[i]; + NMBridgeVlan *vlan = vlans->pdata[i]; GVariantBuilder vlan_builder; guint16 vid_start, vid_end; @@ -5529,7 +5541,7 @@ _nm_utils_bridge_vlans_from_dbus(_NM_SETT_INFO_PROP_FROM_DBUS_FCN_ARGS _nm_nil) { gs_unref_ptrarray GPtrArray *vlans = NULL; GVariantIter vlan_iter; - GVariant * vlan_var; + GVariant *vlan_var; g_return_val_if_fail(g_variant_is_of_type(value, G_VARIANT_TYPE("aa{sv}")), FALSE); @@ -5537,7 +5549,7 @@ _nm_utils_bridge_vlans_from_dbus(_NM_SETT_INFO_PROP_FROM_DBUS_FCN_ARGS _nm_nil) g_variant_iter_init(&vlan_iter, value); while (g_variant_iter_next(&vlan_iter, "@a{sv}", &vlan_var)) { _nm_unused gs_unref_variant GVariant *var_unref = vlan_var; - NMBridgeVlan * vlan; + NMBridgeVlan *vlan; guint16 vid_start, vid_end; gboolean pvid = FALSE, untagged = FALSE; @@ -5587,13 +5599,13 @@ _nm_utils_bridge_compare_vlans(GPtrArray *vlans_a, GPtrArray *vlans_b) } gboolean -_nm_utils_bridge_vlan_verify_list(GPtrArray * vlans, +_nm_utils_bridge_vlan_verify_list(GPtrArray *vlans, gboolean check_normalizable, - GError ** error, + GError **error, const char *setting, const char *property) { - guint i; + guint i; gs_unref_hashtable GHashTable *h = NULL; gboolean pvid_found = FALSE; diff --git a/src/libnm-core-impl/nm-vpn-editor-plugin.c b/src/libnm-core-impl/nm-vpn-editor-plugin.c index 468ddcea..225f25ef 100644 --- a/src/libnm-core-impl/nm-vpn-editor-plugin.c +++ b/src/libnm-core-impl/nm-vpn-editor-plugin.c @@ -141,7 +141,7 @@ void nm_vpn_editor_plugin_set_plugin_info(NMVpnEditorPlugin *plugin, NMVpnPluginInfo *plugin_info) { NMVpnEditorPluginInterface *interface; - NMVpnEditorPluginPrivate * priv; + NMVpnEditorPluginPrivate *priv; g_return_if_fail(NM_IS_VPN_EDITOR_PLUGIN(plugin)); @@ -192,7 +192,7 @@ nm_vpn_editor_plugin_set_plugin_info(NMVpnEditorPlugin *plugin, NMVpnPluginInfo gsize nm_vpn_editor_plugin_get_vt(NMVpnEditorPlugin *plugin, NMVpnEditorPluginVT *vt, gsize vt_size) { - const NMVpnEditorPluginVT * p_vt = NULL; + const NMVpnEditorPluginVT *p_vt = NULL; gsize p_vt_size = 0; NMVpnEditorPluginInterface *interface; @@ -218,23 +218,23 @@ nm_vpn_editor_plugin_get_vt(NMVpnEditorPlugin *plugin, NMVpnEditorPluginVT *vt, /*****************************************************************************/ static NMVpnEditorPlugin * -_nm_vpn_editor_plugin_load(const char * plugin_name, +_nm_vpn_editor_plugin_load(const char *plugin_name, gboolean do_file_checks, - const char * check_service, + const char *check_service, int check_owner, NMUtilsCheckFilePredicate check_file, gpointer user_data, - GError ** error) + GError **error) { - void * dl_module = NULL; - gboolean loaded_before; - NMVpnEditorPluginFactory factory = NULL; + void *dl_module = NULL; + gboolean loaded_before; + NMVpnEditorPluginFactory factory = NULL; gs_unref_object NMVpnEditorPlugin *editor_plugin = NULL; - gs_free char * plugin_filename_free = NULL; - const char * plugin_filename; - gs_free_error GError *factory_error = NULL; - gs_free char * plug_name = NULL; - gs_free char * plug_service = NULL; + gs_free char *plugin_filename_free = NULL; + const char *plugin_filename; + gs_free_error GError *factory_error = NULL; + gs_free char *plug_name = NULL; + gs_free char *plug_service = NULL; g_return_val_if_fail(plugin_name && *plugin_name, NULL); @@ -385,12 +385,12 @@ _nm_vpn_editor_plugin_load(const char * plugin_name, * Since: 1.2 */ NMVpnEditorPlugin * -nm_vpn_editor_plugin_load_from_file(const char * plugin_name, - const char * check_service, +nm_vpn_editor_plugin_load_from_file(const char *plugin_name, + const char *check_service, int check_owner, NMUtilsCheckFilePredicate check_file, gpointer user_data, - GError ** error) + GError **error) { return _nm_vpn_editor_plugin_load(plugin_name, TRUE, @@ -484,9 +484,9 @@ nm_vpn_editor_plugin_import(NMVpnEditorPlugin *plugin, const char *path, GError gboolean nm_vpn_editor_plugin_export(NMVpnEditorPlugin *plugin, - const char * path, - NMConnection * connection, - GError ** error) + const char *path, + NMConnection *connection, + GError **error) { g_return_val_if_fail(NM_IS_VPN_EDITOR_PLUGIN(plugin), FALSE); diff --git a/src/libnm-core-impl/nm-vpn-plugin-info.c b/src/libnm-core-impl/nm-vpn-plugin-info.c index 2ffb7774..473063fb 100644 --- a/src/libnm-core-impl/nm-vpn-plugin-info.c +++ b/src/libnm-core-impl/nm-vpn-plugin-info.c @@ -25,11 +25,11 @@ enum { }; typedef struct { - char * filename; - char * name; - char * service; - char * auth_dialog; - char ** aliases; + char *filename; + char *name; + char *service; + char *auth_dialog; + char **aliases; GKeyFile *keyfile; /* It is convenient for nm_vpn_plugin_info_lookup_property() to return a const char *, @@ -96,14 +96,14 @@ nm_vpn_plugin_info_validate_filename(const char *filename) } static gboolean -nm_vpn_plugin_info_check_file_full(const char * filename, +nm_vpn_plugin_info_check_file_full(const char *filename, gboolean check_absolute, gboolean do_validate_filename, gint64 check_owner, NMUtilsCheckFilePredicate check_file, gpointer user_data, - struct stat * out_st, - GError ** error) + struct stat *out_st, + GError **error) { if (!filename || !*filename) { g_set_error(error, NM_VPN_PLUGIN_ERROR, NM_VPN_PLUGIN_ERROR_FAILED, _("missing filename")); @@ -153,13 +153,13 @@ nm_vpn_plugin_info_check_file_full(const char * filename, * Since: 1.2 */ gboolean -_nm_vpn_plugin_info_check_file(const char * filename, +_nm_vpn_plugin_info_check_file(const char *filename, gboolean check_absolute, gboolean do_validate_filename, gint64 check_owner, NMUtilsCheckFilePredicate check_file, gpointer user_data, - GError ** error) + GError **error) { return nm_vpn_plugin_info_check_file_full(filename, check_absolute, @@ -244,16 +244,16 @@ _nm_vpn_plugin_info_get_default_dir_user() * Returns: (transfer full) (element-type NMVpnPluginInfo): list of loaded plugin infos. */ GSList * -_nm_vpn_plugin_info_list_load_dir(const char * dirname, +_nm_vpn_plugin_info_list_load_dir(const char *dirname, gboolean do_validate_filename, gint64 check_owner, NMUtilsCheckFilePredicate check_file, gpointer user_data) { - GDir * dir; + GDir *dir; const char *fn; - GArray * array; - GSList * res = NULL; + GArray *array; + GSList *res = NULL; guint i; g_return_val_if_fail(dirname, NULL); @@ -316,8 +316,8 @@ nm_vpn_plugin_info_list_load() { int i; gint64 uid; - GSList * list = NULL; - GSList * infos, *info; + GSList *list = NULL; + GSList *infos, *info; const char *const dir[] = { /* We load plugins from NM_VPN_PLUGIN_DIR *and* DEFAULT_DIR*, with * preference to the former. @@ -370,7 +370,7 @@ NMVpnPluginInfo * nm_vpn_plugin_info_new_search_file(const char *name, const char *service) { NMVpnPluginInfo *info; - GSList * infos; + GSList *infos; if (!name && !service) g_return_val_if_reached(NULL); @@ -402,7 +402,7 @@ _check_no_conflict(NMVpnPluginInfo *i1, NMVpnPluginInfo *i2, GError **error) for (i = 0; i < G_N_ELEMENTS(check_list); i++) { gs_free NMUtilsStrStrDictKey *k = NULL; - const char * s1, *s2; + const char *s1, *s2; k = _nm_utils_strstrdictkey_create(check_list[i].group, check_list[i].key); s1 = g_hash_table_lookup(priv1->keys, k); @@ -440,7 +440,7 @@ _check_no_conflict(NMVpnPluginInfo *i1, NMVpnPluginInfo *i2, GError **error) gboolean nm_vpn_plugin_info_list_add(GSList **list, NMVpnPluginInfo *plugin_info, GError **error) { - GSList * iter; + GSList *iter; const char *name; g_return_val_if_fail(list, FALSE); @@ -619,7 +619,7 @@ char * nm_vpn_plugin_info_list_find_service_type(GSList *list, const char *name) { NMVpnPluginInfo *info; - char * n; + char *n; if (!name) g_return_val_if_reached(NULL); @@ -685,12 +685,12 @@ _service_type_get_default_abbreviation(const char *service_type) * Since: 1.4 */ char ** -nm_vpn_plugin_info_list_get_service_types(GSList * list, +nm_vpn_plugin_info_list_get_service_types(GSList *list, gboolean only_existing, gboolean with_abbreviations) { - GSList * iter; - GPtrArray * l; + GSList *iter; + GPtrArray *l; guint i, j; const char *n; @@ -953,7 +953,7 @@ nm_vpn_plugin_info_get_aliases(NMVpnPluginInfo *self) const char * nm_vpn_plugin_info_lookup_property(NMVpnPluginInfo *self, const char *group, const char *key) { - NMVpnPluginInfoPrivate *priv; + NMVpnPluginInfoPrivate *priv; gs_free NMUtilsStrStrDictKey *k = NULL; g_return_val_if_fail(NM_IS_VPN_PLUGIN_INFO(self), NULL); @@ -997,7 +997,7 @@ void nm_vpn_plugin_info_set_editor_plugin(NMVpnPluginInfo *self, NMVpnEditorPlugin *plugin) { NMVpnPluginInfoPrivate *priv; - NMVpnEditorPlugin * old; + NMVpnEditorPlugin *old; g_return_if_fail(NM_IS_VPN_PLUGIN_INFO(self)); g_return_if_fail(!plugin || G_IS_OBJECT(plugin)); @@ -1033,7 +1033,7 @@ NMVpnEditorPlugin * nm_vpn_plugin_info_load_editor_plugin(NMVpnPluginInfo *self, GError **error) { NMVpnPluginInfoPrivate *priv; - const char * plugin_filename; + const char *plugin_filename; g_return_val_if_fail(NM_IS_VPN_PLUGIN_INFO(self), NULL); @@ -1121,9 +1121,9 @@ nm_vpn_plugin_info_init(NMVpnPluginInfo *plugin) static gboolean init_sync(GInitable *initable, GCancellable *cancellable, GError **error) { - NMVpnPluginInfo * self = NM_VPN_PLUGIN_INFO(initable); + NMVpnPluginInfo *self = NM_VPN_PLUGIN_INFO(initable); NMVpnPluginInfoPrivate *priv = NM_VPN_PLUGIN_INFO_GET_PRIVATE(self); - gs_strfreev char ** groups = NULL; + gs_strfreev char **groups = NULL; guint i, j; if (!priv->keyfile) { @@ -1258,7 +1258,7 @@ nm_vpn_plugin_info_new_with_data(const char *filename, GKeyFile *keyfile, GError static void dispose(GObject *object) { - NMVpnPluginInfo * self = NM_VPN_PLUGIN_INFO(object); + NMVpnPluginInfo *self = NM_VPN_PLUGIN_INFO(object); NMVpnPluginInfoPrivate *priv = NM_VPN_PLUGIN_INFO_GET_PRIVATE(self); g_clear_object(&priv->editor_plugin); @@ -1269,7 +1269,7 @@ dispose(GObject *object) static void finalize(GObject *object) { - NMVpnPluginInfo * self = NM_VPN_PLUGIN_INFO(object); + NMVpnPluginInfo *self = NM_VPN_PLUGIN_INFO(object); NMVpnPluginInfoPrivate *priv = NM_VPN_PLUGIN_INFO_GET_PRIVATE(self); g_free(priv->name); diff --git a/src/libnm-core-impl/tests/test-compare.c b/src/libnm-core-impl/tests/test-compare.c index 3716399a..77d2e17b 100644 --- a/src/libnm-core-impl/tests/test-compare.c +++ b/src/libnm-core-impl/tests/test-compare.c @@ -37,7 +37,7 @@ compare_ints(void) static void compare_strings(void) { - GVariant * value1, *value2; + GVariant *value1, *value2; const char *str1 = "hello"; const char *str2 = "world"; @@ -58,7 +58,7 @@ compare_strings(void) static void compare_strv(void) { - GVariant * value1, *value2; + GVariant *value1, *value2; const char *const strv1[] = {"foo", "bar", "baz", NULL}; const char *const strv2[] = {"foo", "bar", "bar", NULL}; const char *const strv3[] = {"foo", "bar", NULL}; @@ -123,7 +123,7 @@ compare_arrays(void) static void compare_str_hash(void) { - GVariant * value1, *value2; + GVariant *value1, *value2; GVariantBuilder builder; g_variant_builder_init(&builder, G_VARIANT_TYPE("a{ss}")); @@ -165,7 +165,7 @@ compare_str_hash(void) static void compare_ip6_addresses(void) { - GVariant * value1, *value2; + GVariant *value1, *value2; struct in6_addr addr1; struct in6_addr addr2; struct in6_addr addr3; diff --git a/src/libnm-core-impl/tests/test-crypto.c b/src/libnm-core-impl/tests/test-crypto.c index 1c072f71..6a6e7fbc 100644 --- a/src/libnm-core-impl/tests/test-crypto.c +++ b/src/libnm-core-impl/tests/test-crypto.c @@ -80,10 +80,10 @@ out: static void test_cert(gconstpointer test_data) { - gs_free char * path = NULL; + gs_free char *path = NULL; gs_unref_bytes GBytes *cert = NULL; NMCryptoFileFormat format = NM_CRYPTO_FILE_FORMAT_UNKNOWN; - GError * error = NULL; + GError *error = NULL; gboolean success; path = g_build_filename(TEST_CERT_DIR, (const char *) test_data, NULL); @@ -101,10 +101,10 @@ test_load_private_key(const char *path, const char *decrypted_path, int expected_error) { - NMCryptoKeyType key_type = NM_CRYPTO_KEY_TYPE_UNKNOWN; - gboolean is_encrypted = FALSE; - gs_unref_bytes GBytes *array = NULL; - GError * error = NULL; + NMCryptoKeyType key_type = NM_CRYPTO_KEY_TYPE_UNKNOWN; + gboolean is_encrypted = FALSE; + gs_unref_bytes GBytes *array = NULL; + GError *error = NULL; g_assert(nm_utils_file_is_private_key(path, &is_encrypted)); g_assert(is_encrypted); @@ -144,7 +144,7 @@ test_load_pkcs12(const char *path, const char *password, int expected_error) { NMCryptoFileFormat format = NM_CRYPTO_FILE_FORMAT_UNKNOWN; gboolean is_encrypted = FALSE; - GError * error = NULL; + GError *error = NULL; g_assert(nm_utils_file_is_private_key(path, NULL)); @@ -165,7 +165,7 @@ test_load_pkcs12_no_password(const char *path) { NMCryptoFileFormat format = NM_CRYPTO_FILE_FORMAT_UNKNOWN; gboolean is_encrypted = FALSE; - GError * error = NULL; + GError *error = NULL; g_assert(nm_utils_file_is_private_key(path, NULL)); @@ -180,7 +180,7 @@ static void test_is_pkcs12(const char *path, gboolean expect_fail) { gboolean is_pkcs12; - GError * error = NULL; + GError *error = NULL; is_pkcs12 = nm_crypto_is_pkcs12_file(path, &error); @@ -199,7 +199,7 @@ test_load_pkcs8(const char *path, const char *password, int expected_error) { NMCryptoFileFormat format = NM_CRYPTO_FILE_FORMAT_UNKNOWN; gboolean is_encrypted = FALSE; - GError * error = NULL; + GError *error = NULL; g_assert(nm_utils_file_is_private_key(path, NULL)); @@ -218,11 +218,11 @@ test_load_pkcs8(const char *path, const char *password, int expected_error) static void test_encrypt_private_key(const char *path, const char *password) { - NMCryptoKeyType key_type = NM_CRYPTO_KEY_TYPE_UNKNOWN; + NMCryptoKeyType key_type = NM_CRYPTO_KEY_TYPE_UNKNOWN; gs_unref_bytes GBytes *array = NULL; gs_unref_bytes GBytes *encrypted = NULL; gs_unref_bytes GBytes *re_decrypted = NULL; - GError * error = NULL; + GError *error = NULL; array = nmtst_crypto_decrypt_openssl_private_key(path, password, &key_type, &error); nmtst_assert_success(array, error); @@ -281,7 +281,7 @@ test_key_decrypted(gconstpointer test_data) { const char *file = (const char *) test_data; gboolean is_encrypted = FALSE; - char * path; + char *path; path = g_build_filename(TEST_CERT_DIR, file, NULL); @@ -404,7 +404,7 @@ NMTST_DEFINE(); int main(int argc, char **argv) { - GError * error = NULL; + GError *error = NULL; gboolean success; int ret; diff --git a/src/libnm-core-impl/tests/test-general.c b/src/libnm-core-impl/tests/test-general.c index 5c831cb7..d0f85a9f 100644 --- a/src/libnm-core-impl/tests/test-general.c +++ b/src/libnm-core-impl/tests/test-general.c @@ -13,12 +13,13 @@ #include <linux/if_ether.h> #include <linux/if_infiniband.h> -#include "libnm-std-aux/c-list-util.h" -#include "libnm-glib-aux/nm-uuid.h" +#include "libnm-base/nm-base.h" #include "libnm-glib-aux/nm-enum-utils.h" -#include "libnm-glib-aux/nm-str-buf.h" #include "libnm-glib-aux/nm-json-aux.h" -#include "libnm-base/nm-base.h" +#include "libnm-glib-aux/nm-ref-string.h" +#include "libnm-glib-aux/nm-str-buf.h" +#include "libnm-glib-aux/nm-uuid.h" +#include "libnm-std-aux/c-list-util.h" #include "libnm-systemd-shared/nm-sd-utils-shared.h" #include "nm-utils.h" @@ -110,8 +111,8 @@ static void test_wired_wake_on_lan_enum(void) { nm_auto_unref_gtypeclass GFlagsClass *flags_class = NULL; - gs_unref_hashtable GHashTable *vals = g_hash_table_new(nm_direct_hash, NULL); - guint i; + gs_unref_hashtable GHashTable *vals = g_hash_table_new(nm_direct_hash, NULL); + guint i; G_STATIC_ASSERT_EXPR(sizeof(NMSettingWiredWakeOnLan) == sizeof(_NMSettingWiredWakeOnLan)); G_STATIC_ASSERT_EXPR(sizeof(NMSettingWiredWakeOnLan) < sizeof(gint64)); @@ -161,8 +162,8 @@ static void test_wireless_wake_on_wlan_enum(void) { nm_auto_unref_gtypeclass GFlagsClass *flags_class = NULL; - gs_unref_hashtable GHashTable *vals = g_hash_table_new(nm_direct_hash, NULL); - guint i; + gs_unref_hashtable GHashTable *vals = g_hash_table_new(nm_direct_hash, NULL); + guint i; G_STATIC_ASSERT_EXPR(sizeof(NMSettingWirelessWakeOnWLan) == sizeof(_NMSettingWirelessWakeOnWLan)); @@ -215,8 +216,8 @@ static void test_device_wifi_capabilities(void) { nm_auto_unref_gtypeclass GFlagsClass *flags_class = NULL; - gs_unref_hashtable GHashTable *vals = g_hash_table_new(nm_direct_hash, NULL); - guint i; + gs_unref_hashtable GHashTable *vals = g_hash_table_new(nm_direct_hash, NULL); + guint i; G_STATIC_ASSERT_EXPR(sizeof(NMDeviceWifiCapabilities) == sizeof(_NMDeviceWifiCapabilities)); G_STATIC_ASSERT_EXPR(sizeof(NMDeviceWifiCapabilities) < sizeof(gint64)); @@ -268,8 +269,8 @@ static void test_80211_mode(void) { nm_auto_unref_gtypeclass GEnumClass *enum_class = NULL; - gs_unref_hashtable GHashTable *vals = g_hash_table_new(nm_direct_hash, NULL); - guint i; + gs_unref_hashtable GHashTable *vals = g_hash_table_new(nm_direct_hash, NULL); + guint i; G_STATIC_ASSERT_EXPR(sizeof(NM80211Mode) == sizeof(_NM80211Mode)); G_STATIC_ASSERT_EXPR(sizeof(NM80211Mode) < sizeof(gint64)); @@ -312,8 +313,8 @@ static void test_vlan_flags(void) { nm_auto_unref_gtypeclass GFlagsClass *flags_class = NULL; - gs_unref_hashtable GHashTable *vals = g_hash_table_new(nm_direct_hash, NULL); - guint i; + gs_unref_hashtable GHashTable *vals = g_hash_table_new(nm_direct_hash, NULL); + guint i; G_STATIC_ASSERT_EXPR(sizeof(NMVlanFlags) == sizeof(_NMVlanFlags)); G_STATIC_ASSERT_EXPR(sizeof(NMVlanFlags) < sizeof(gint64)); @@ -543,9 +544,9 @@ test_nm_g_slice_free_fcn(void) static void _do_test_nm_strsplit_set_f_one(NMUtilsStrsplitSetFlags flags, - const char * str, + const char *str, gsize words_len, - const char *const * exp_words) + const char *const *exp_words) { #define DELIMITERS " \n" #define DELIMITERS_C ' ', '\n' @@ -554,7 +555,7 @@ _do_test_nm_strsplit_set_f_one(NMUtilsStrsplitSetFlags flags, gsize i, j, k; const gboolean f_allow_escaping = NM_FLAGS_HAS(flags, NM_STRSPLIT_SET_FLAGS_ALLOW_ESCAPING); const gboolean f_preserve_empty = NM_FLAGS_HAS(flags, NM_STRSPLIT_SET_FLAGS_PRESERVE_EMPTY); - const char * s1; + const char *s1; gsize initial_offset; gs_strfreev char **words_g = NULL; @@ -750,9 +751,9 @@ _do_test_nm_strsplit_set_f_one(NMUtilsStrsplitSetFlags flags, static void _do_test_nm_strsplit_set_f(NMUtilsStrsplitSetFlags flags, - const char * str, + const char *str, gsize words_len, - const char *const * exp_words) + const char *const *exp_words) { _do_test_nm_strsplit_set_f_one(flags, str, words_len, exp_words); @@ -784,9 +785,9 @@ _do_test_nm_strsplit_set_f(NMUtilsStrsplitSetFlags flags, static void _do_test_nm_strsplit_set_simple(NMUtilsStrsplitSetFlags flags, - const char * str, + const char *str, gsize words_len, - const char *const * exp_words) + const char *const *exp_words) { gs_free const char **tokens = NULL; gsize n_tokens; @@ -1108,7 +1109,7 @@ _escaped_tokens_split(char *str, const char **out_key, const char **out_val) } static void -_escaped_tokens_combine(GString * combined, +_escaped_tokens_combine(GString *combined, const char *key, const char *val, gboolean strict, @@ -1139,9 +1140,9 @@ _escaped_tokens_combine(GString * combined, } static void -_escaped_tokens_check_one_impl(const char * expected_key, - const char * expected_val, - const char * expected_combination, +_escaped_tokens_check_one_impl(const char *expected_key, + const char *expected_val, + const char *expected_combination, const char *const *other, gsize n_other) { @@ -1158,11 +1159,11 @@ _escaped_tokens_check_one_impl(const char * expected_key, for (i = 0; i < n_other + 2u; i++) { nm_auto_free_gstring GString *str0 = NULL; - gs_free const char ** strv_split = NULL; - gs_free char * strv_split0 = NULL; - const char * comb; - const char * key; - const char * val; + gs_free const char **strv_split = NULL; + gs_free char *strv_split0 = NULL; + const char *comb; + const char *key; + const char *val; if (i == 0) comb = expected_combination; @@ -1208,10 +1209,10 @@ test_nm_utils_escaped_tokens(void) int i_run; for (i_run = 0; i_run < 1000; i_run++) { - const guint num_options = nmtst_get_rand_word_length(NULL); - gs_unref_ptrarray GPtrArray *options = g_ptr_array_new_with_free_func(g_free); - nm_auto_free_gstring GString *combined = g_string_new(NULL); - gs_free const char ** strv_split = NULL; + const guint num_options = nmtst_get_rand_word_length(NULL); + gs_unref_ptrarray GPtrArray *options = g_ptr_array_new_with_free_func(g_free); + nm_auto_free_gstring GString *combined = g_string_new(NULL); + gs_free const char **strv_split = NULL; guint i_option; guint i; @@ -1244,8 +1245,8 @@ test_nm_utils_escaped_tokens(void) /* ensure that we can split and parse the options without difference. */ strv_split = nm_utils_escaped_tokens_options_split_list(combined->str); for (i_option = 0; i_option < num_options; i_option++) { - const char * expected_key = options->pdata[2u * i_option + 0u]; - const char * expected_val = options->pdata[2u * i_option + 1u]; + const char *expected_key = options->pdata[2u * i_option + 0u]; + const char *expected_val = options->pdata[2u * i_option + 1u]; gs_free char *s_split = i_option < NM_PTRARRAY_LEN(strv_split) ? g_strdup(strv_split[i_option]) : NULL; const char *key = NULL; @@ -1301,7 +1302,7 @@ test_nm_utils_escaped_tokens(void) */ for (i = 0; i < 1u + 2u * i_option; i++) { gs_free char *str = NULL; - const char * cstr; + const char *cstr; if (i == 0) cstr = combined->str; @@ -1359,7 +1360,7 @@ _do_test_c_list_sort(CListSort *elements, guint n_list, gboolean headless) CList head, *iter, *iter_prev, *lst; guint i; const CListSort *el_prev; - CListSort * el; + CListSort *el; c_list_init(&head); for (i = 0; i < n_list; i++) { @@ -1409,8 +1410,8 @@ _do_test_c_list_sort(CListSort *elements, guint n_list, gboolean headless) static void test_c_list_sort(void) { - const guint N_ELEMENTS = 10000; - guint n_list, repeat; + const guint N_ELEMENTS = 10000; + guint n_list, repeat; gs_free CListSort *elements = NULL; { @@ -1545,11 +1546,11 @@ _dedup_idx_assert(const NMDedupMultiIdxType *idx_type) static void _dedup_idx_obj_id_hash_update(const NMDedupMultiIdxType *idx_type, - const NMDedupMultiObj * obj, - NMHashState * h) + const NMDedupMultiObj *obj, + NMHashState *h) { const DedupIdxType *t; - const DedupObj * o; + const DedupObj *o; t = _dedup_idx_assert(idx_type); o = _dedup_obj_assert(obj); @@ -1560,12 +1561,12 @@ _dedup_idx_obj_id_hash_update(const NMDedupMultiIdxType *idx_type, static gboolean _dedup_idx_obj_id_equal(const NMDedupMultiIdxType *idx_type, - const NMDedupMultiObj * obj_a, - const NMDedupMultiObj * obj_b) + const NMDedupMultiObj *obj_a, + const NMDedupMultiObj *obj_b) { const DedupIdxType *t; - const DedupObj * o_a; - const DedupObj * o_b; + const DedupObj *o_a; + const DedupObj *o_b; t = _dedup_idx_assert(idx_type); o_a = _dedup_obj_assert(obj_a); @@ -1577,11 +1578,11 @@ _dedup_idx_obj_id_equal(const NMDedupMultiIdxType *idx_type, static void _dedup_idx_obj_partition_hash_update(const NMDedupMultiIdxType *idx_type, - const NMDedupMultiObj * obj, - NMHashState * h) + const NMDedupMultiObj *obj, + NMHashState *h) { const DedupIdxType *t; - const DedupObj * o; + const DedupObj *o; t = _dedup_idx_assert(idx_type); o = _dedup_obj_assert(obj); @@ -1591,12 +1592,12 @@ _dedup_idx_obj_partition_hash_update(const NMDedupMultiIdxType *idx_type, static gboolean _dedup_idx_obj_partition_equal(const NMDedupMultiIdxType *idx_type, - const NMDedupMultiObj * obj_a, - const NMDedupMultiObj * obj_b) + const NMDedupMultiObj *obj_a, + const NMDedupMultiObj *obj_b) { const DedupIdxType *t; - const DedupObj * o_a; - const DedupObj * o_b; + const DedupObj *o_a; + const DedupObj *o_b; t = _dedup_idx_assert(idx_type); o_a = _dedup_obj_assert(obj_a); @@ -1622,9 +1623,9 @@ DEDUP_IDX_TYPE_INIT(DedupIdxType *idx_type, guint partition_size, guint val_mod) } static gboolean -_dedup_idx_add(NMDedupMultiIndex * idx, - const DedupIdxType * idx_type, - const DedupObj * obj, +_dedup_idx_add(NMDedupMultiIndex *idx, + const DedupIdxType *idx_type, + const DedupObj *obj, NMDedupMultiIdxMode mode, const NMDedupMultiEntry **out_entry) { @@ -1675,7 +1676,7 @@ _dedup_entry_get_idx_type(const NMDedupMultiEntry *entry) static void _dedup_entry_assert_all(const NMDedupMultiEntry *entry, gssize expected_idx, - const DedupObj *const * expected_obj) + const DedupObj *const *expected_obj) { gsize n, i; CList *iter; @@ -1698,8 +1699,8 @@ _dedup_entry_assert_all(const NMDedupMultiEntry *entry, i = 0; c_list_for_each (iter, &entry->head->lst_entries_head) { const NMDedupMultiEntry *entry_current = c_list_entry(iter, NMDedupMultiEntry, lst_entries); - const DedupObj * obj_current; - const DedupIdxType * idx_type = _dedup_entry_get_idx_type(entry_current); + const DedupObj *obj_current; + const DedupIdxType *idx_type = _dedup_entry_get_idx_type(entry_current); obj_current = _dedup_entry_assert(entry_current); g_assert(obj_current); @@ -1719,10 +1720,10 @@ _dedup_entry_assert_all(const NMDedupMultiEntry *entry, static void test_dedup_multi(void) { - NMDedupMultiIndex * idx; + NMDedupMultiIndex *idx; DedupIdxType IDX_20_3_a_stack; const DedupIdxType *const IDX_20_3_a = DEDUP_IDX_TYPE_INIT(&IDX_20_3_a_stack, 20, 3); - const NMDedupMultiEntry * entry1; + const NMDedupMultiEntry *entry1; idx = nm_dedup_multi_index_new(); @@ -1800,7 +1801,7 @@ static void test_setting_vpn_items(void) { gs_unref_object NMConnection *connection = NULL; - NMSettingVpn * s_vpn; + NMSettingVpn *s_vpn; connection = nmtst_create_minimal_connection("vpn-items", NULL, NM_SETTING_VPN_SETTING_NAME, NULL); @@ -1919,17 +1920,17 @@ test_setting_vpn_items(void) static void test_setting_vpn_update_secrets(void) { - NMConnection * connection; - NMSettingVpn * s_vpn; + NMConnection *connection; + NMSettingVpn *s_vpn; GVariantBuilder settings_builder, vpn_builder, secrets_builder; - GVariant * settings; + GVariant *settings; gboolean success; - GError * error = NULL; - const char * tmp; - const char * key1 = "foobar"; - const char * key2 = "blahblah"; - const char * val1 = "value1"; - const char * val2 = "value2"; + GError *error = NULL; + const char *tmp; + const char *key1 = "foobar"; + const char *key2 = "blahblah"; + const char *val1 = "value1"; + const char *val2 = "value2"; connection = nm_simple_connection_new(); s_vpn = (NMSettingVpn *) nm_setting_vpn_new(); @@ -1970,7 +1971,7 @@ test_setting_vpn_update_secrets(void) #define TO_DEL_NUM 50 typedef struct { NMSettingVpn *s_vpn; - char * to_del[TO_DEL_NUM]; + char *to_del[TO_DEL_NUM]; guint called; } IterInfo; @@ -1998,7 +1999,7 @@ test_setting_vpn_modify_during_foreach(void) { NMSettingVpn *s_vpn; IterInfo info; - char * key, *val; + char *key, *val; int i, u = 0; s_vpn = (NMSettingVpn *) nm_setting_vpn_new(); @@ -2040,13 +2041,13 @@ static void test_setting_ip4_config_labels(void) { NMSettingIPConfig *s_ip4; - NMIPAddress * addr; - GVariant * label; - GPtrArray * addrs; - char ** labels; - NMConnection * conn; - GVariant * dict, *dict2, *setting_dict, *value; - GError * error = NULL; + NMIPAddress *addr; + GVariant *label; + GPtrArray *addrs; + char **labels; + NMConnection *conn; + GVariant *dict, *dict2, *setting_dict, *value; + GError *error = NULL; s_ip4 = (NMSettingIPConfig *) nm_setting_ip4_config_new(); g_object_set(G_OBJECT(s_ip4), @@ -2242,11 +2243,11 @@ static void test_setting_ip4_config_address_data(void) { NMSettingIPConfig *s_ip4; - NMIPAddress * addr; - GPtrArray * addrs; - NMConnection * conn; - GVariant * dict, *setting_dict, *value; - GError * error = NULL; + NMIPAddress *addr; + GPtrArray *addrs; + NMConnection *conn; + GVariant *dict, *setting_dict, *value; + GError *error = NULL; s_ip4 = (NMSettingIPConfig *) nm_setting_ip4_config_new(); g_object_set(G_OBJECT(s_ip4), @@ -2412,7 +2413,7 @@ static void test_setting_gsm_apn_spaces(void) { gs_unref_object NMSettingGsm *s_gsm = NULL; - const char * tmp; + const char *tmp; s_gsm = (NMSettingGsm *) nm_setting_gsm_new(); g_assert(s_gsm); @@ -2558,7 +2559,7 @@ static void test_setting_to_dbus_all(void) { NMSettingWirelessSecurity *s_wsec; - GVariant * dict; + GVariant *dict; s_wsec = make_test_wsec_setting("setting-to-dbus-all"); @@ -2578,7 +2579,7 @@ static void test_setting_to_dbus_no_secrets(void) { NMSettingWirelessSecurity *s_wsec; - GVariant * dict; + GVariant *dict; s_wsec = make_test_wsec_setting("setting-to-dbus-no-secrets"); @@ -2603,7 +2604,7 @@ static void test_setting_to_dbus_only_secrets(void) { NMSettingWirelessSecurity *s_wsec; - GVariant * dict; + GVariant *dict; s_wsec = make_test_wsec_setting("setting-to-dbus-only-secrets"); @@ -2625,9 +2626,9 @@ test_setting_to_dbus_only_secrets(void) static void test_setting_to_dbus_transform(void) { - NMSetting * s_wired; - GVariant * dict, *val; - const char * test_mac_address = "11:22:33:44:55:66"; + NMSetting *s_wired; + GVariant *dict, *val; + const char *test_mac_address = "11:22:33:44:55:66"; const guint8 *dbus_mac_address; guint8 cmp_mac_address[ETH_ALEN]; gsize len; @@ -2660,7 +2661,7 @@ static void test_setting_to_dbus_enum(void) { NMSetting *s_ip6, *s_wsec, *s_serial; - GVariant * dict, *val; + GVariant *dict, *val; /* enum */ s_ip6 = nm_setting_ip6_config_new(); @@ -2730,9 +2731,9 @@ test_setting_to_dbus_enum(void) static void test_connection_to_dbus_setting_name(void) { - NMConnection * connection; + NMConnection *connection; NMSettingWirelessSecurity *s_wsec; - GVariant * dict; + GVariant *dict; connection = nm_simple_connection_new(); s_wsec = make_test_wsec_setting("connection-to-dbus-setting-name"); @@ -2781,11 +2782,11 @@ test_connection_to_dbus_setting_name(void) static void test_connection_to_dbus_deprecated_props(void) { - NMConnection * connection; - NMSetting * s_wireless; - GBytes * ssid; + NMConnection *connection; + NMSetting *s_wireless; + GBytes *ssid; NMSettingWirelessSecurity *s_wsec; - GVariant * dict, *wireless_dict, *sec_val; + GVariant *dict, *wireless_dict, *sec_val; connection = nmtst_create_minimal_connection("test-connection-to-dbus-deprecated-props", NULL, @@ -2839,7 +2840,7 @@ static void test_setting_new_from_dbus(void) { NMSettingWirelessSecurity *s_wsec; - GVariant * dict; + GVariant *dict; s_wsec = make_test_wsec_setting("setting-new-from-dbus"); dict = _nm_setting_to_dbus(NM_SETTING(s_wsec), NULL, NM_CONNECTION_SERIALIZE_ALL, NULL); @@ -2863,12 +2864,12 @@ test_setting_new_from_dbus(void) static void test_setting_new_from_dbus_transform(void) { - NMSetting * s_wired; - GVariant * dict; + NMSetting *s_wired; + GVariant *dict; GVariantBuilder builder; - const char * test_mac_address = "11:22:33:44:55:66"; + const char *test_mac_address = "11:22:33:44:55:66"; guint8 dbus_mac_address[ETH_ALEN]; - GError * error = NULL; + GError *error = NULL; nm_utils_hwaddr_aton(test_mac_address, dbus_mac_address, ETH_ALEN); @@ -2898,12 +2899,12 @@ test_setting_new_from_dbus_transform(void) static void test_setting_new_from_dbus_enum(void) { - NMSettingIP6Config * s_ip6; + NMSettingIP6Config *s_ip6; NMSettingWirelessSecurity *s_wsec; - NMSettingSerial * s_serial; - GVariant * dict; + NMSettingSerial *s_serial; + GVariant *dict; GVariantBuilder builder; - GError * error = NULL; + GError *error = NULL; /* enum */ g_variant_builder_init(&builder, NM_VARIANT_TYPE_SETTING); @@ -2977,12 +2978,12 @@ test_setting_new_from_dbus_enum(void) static void test_setting_new_from_dbus_bad(void) { - NMSetting * setting; + NMSetting *setting; NMConnection *conn; - GBytes * ssid; - GPtrArray * addrs; - GVariant * orig_dict, *dict; - GError * error = NULL; + GBytes *ssid; + GPtrArray *addrs; + GVariant *orig_dict, *dict; + GError *error = NULL; /* We want to test: * - ordinary scalar properties @@ -3166,8 +3167,8 @@ static NMConnection * new_test_connection(void) { NMConnection *connection; - NMSetting * setting; - char * uuid; + NMSetting *setting; + char *uuid; guint64 timestamp = time(NULL); connection = nm_simple_connection_new(); @@ -3204,7 +3205,7 @@ new_test_connection(void) } static GVariant * -new_connection_dict(char ** out_uuid, +new_connection_dict(char **out_uuid, const char **out_expected_id, const char **out_expected_ip6_method) { @@ -3264,14 +3265,14 @@ new_connection_dict(char ** out_uuid, static void test_connection_replace_settings(void) { - NMConnection * connection; - GVariant * new_settings; - GError * error = NULL; + NMConnection *connection; + GVariant *new_settings; + GError *error = NULL; gboolean success; NMSettingConnection *s_con; - NMSettingIPConfig * s_ip6; - char * uuid = NULL; - const char * expected_id = NULL, *expected_method = NULL; + NMSettingIPConfig *s_ip6; + char *uuid = NULL; + const char *expected_id = NULL, *expected_method = NULL; connection = new_test_connection(); @@ -3303,12 +3304,12 @@ test_connection_replace_settings(void) static void test_connection_replace_settings_from_connection(void) { - NMConnection * connection, *replacement; + NMConnection *connection, *replacement; NMSettingConnection *s_con; - NMSetting * setting; - GBytes * ssid; - char * uuid = NULL; - const char * expected_id = "Awesome connection"; + NMSetting *setting; + GBytes *ssid; + char *uuid = NULL; + const char *expected_id = "Awesome connection"; connection = new_test_connection(); g_assert(connection); @@ -3365,10 +3366,10 @@ test_connection_replace_settings_from_connection(void) static void test_connection_replace_settings_bad(void) { - NMConnection * connection, *new_connection; - GVariant * new_settings; + NMConnection *connection, *new_connection; + GVariant *new_settings; GVariantBuilder builder, setting_builder; - GError * error = NULL; + GError *error = NULL; gboolean success; NMSettingConnection *s_con; @@ -3426,13 +3427,13 @@ test_connection_replace_settings_bad(void) static void test_connection_new_from_dbus(void) { - NMConnection * connection; - GVariant * new_settings; - GError * error = NULL; + NMConnection *connection; + GVariant *new_settings; + GError *error = NULL; NMSettingConnection *s_con; - NMSettingIPConfig * s_ip6; - char * uuid = NULL; - const char * expected_id = NULL, *expected_method = NULL; + NMSettingIPConfig *s_ip6; + char *uuid = NULL; + const char *expected_id = NULL, *expected_method = NULL; new_settings = new_connection_dict(&uuid, &expected_id, &expected_method); g_assert(new_settings); @@ -3484,8 +3485,8 @@ test_setting_connection_permissions_helpers(void) NMSettingConnection *s_con; gboolean success; char buf[9] = {0x61, 0x62, 0x63, 0xff, 0xfe, 0xfd, 0x23, 0x01, 0x00}; - char ** perms; - const char * expected_perm = "user:" TEST_UNAME ":"; + char **perms; + const char *expected_perm = "user:" TEST_UNAME ":"; s_con = NM_SETTING_CONNECTION(nm_setting_connection_new()); @@ -3552,13 +3553,13 @@ test_setting_connection_permissions_helpers(void) static void add_permission_property(NMSettingConnection *s_con, - const char * ptype, - const char * pitem, + const char *ptype, + const char *pitem, int pitem_len, - const char * detail) + const char *detail) { GString *str; - char * perms[2]; + char *perms[2]; str = g_string_sized_new(50); if (ptype) @@ -3598,12 +3599,12 @@ test_setting_connection_permissions_property(void) { \ NMSettingConnection *_s_con = (s_con); \ guint _idx = (idx); \ - const char * _ptype; \ - const char * _pitem; \ - const char * _detail; \ - const char ** _p_ptype = nmtst_get_rand_bool() ? &_ptype : NULL; \ - const char ** _p_pitem = nmtst_get_rand_bool() ? &_pitem : NULL; \ - const char ** _p_detail = nmtst_get_rand_bool() ? &_detail : NULL; \ + const char *_ptype; \ + const char *_pitem; \ + const char *_detail; \ + const char **_p_ptype = nmtst_get_rand_bool() ? &_ptype : NULL; \ + const char **_p_pitem = nmtst_get_rand_bool() ? &_pitem : NULL; \ + const char **_p_detail = nmtst_get_rand_bool() ? &_detail : NULL; \ \ g_assert_cmpint(_idx, <, nm_setting_connection_get_num_permissions(_s_con)); \ g_assert( \ @@ -3690,7 +3691,7 @@ test_connection_compare_same(void) static void test_connection_compare_key_only_in_a(void) { - NMConnection * a, *b; + NMConnection *a, *b; NMSettingConnection *s_con; a = new_test_connection(); @@ -3720,7 +3721,7 @@ test_connection_compare_setting_only_in_a(void) static void test_connection_compare_key_only_in_b(void) { - NMConnection * a, *b; + NMConnection *a, *b; NMSettingConnection *s_con; a = new_test_connection(); @@ -3792,8 +3793,8 @@ ensure_diffs(GHashTable *diffs, const DiffSetting *check, gsize n_check) static void test_connection_diff_a_only(void) { - NMConnection * connection; - GHashTable * out_diffs = NULL; + NMConnection *connection; + GHashTable *out_diffs = NULL; gboolean same; const DiffSetting settings[] = { {NM_SETTING_CONNECTION_SETTING_NAME, @@ -3892,7 +3893,7 @@ static void test_connection_diff_same(void) { NMConnection *a, *b; - GHashTable * out_diffs = NULL; + GHashTable *out_diffs = NULL; gboolean same; a = new_test_connection(); @@ -3908,8 +3909,8 @@ test_connection_diff_same(void) static void test_connection_diff_different(void) { - NMConnection * a, *b; - GHashTable * out_diffs = NULL; + NMConnection *a, *b; + GHashTable *out_diffs = NULL; NMSettingIPConfig *s_ip4; gboolean same; const DiffSetting settings[] = { @@ -3945,9 +3946,9 @@ test_connection_diff_different(void) static void test_connection_diff_no_secrets(void) { - NMConnection * a, *b; - GHashTable * out_diffs = NULL; - NMSetting * s_pppoe; + NMConnection *a, *b; + GHashTable *out_diffs = NULL; + NMSetting *s_pppoe; gboolean same; const DiffSetting settings[] = { {NM_SETTING_PPPOE_SETTING_NAME, @@ -3990,13 +3991,13 @@ test_connection_diff_no_secrets(void) static void test_connection_diff_inferrable(void) { - NMConnection * a, *b; - GHashTable * out_diffs = NULL; + NMConnection *a, *b; + GHashTable *out_diffs = NULL; gboolean same; NMSettingConnection *s_con; - NMSettingWired * s_wired; - NMSettingIPConfig * s_ip4; - char * uuid; + NMSettingWired *s_wired; + NMSettingIPConfig *s_ip4; + char *uuid; const DiffSetting settings[] = { {NM_SETTING_CONNECTION_SETTING_NAME, { @@ -4053,7 +4054,7 @@ static void add_generic_settings(NMConnection *connection, const char *ctype) { NMSetting *setting; - char * uuid; + char *uuid; uuid = nm_utils_uuid_generate(); @@ -4083,11 +4084,11 @@ static void test_connection_good_base_types(void) { NMConnection *connection; - NMSetting * setting; + NMSetting *setting; gboolean success; - GError * error = NULL; - GBytes * ssid; - const char * bdaddr = "11:22:33:44:55:66"; + GError *error = NULL; + GBytes *ssid; + const char *bdaddr = "11:22:33:44:55:66"; /* Try a basic wired connection */ connection = nm_simple_connection_new(); @@ -4193,9 +4194,9 @@ static void test_connection_bad_base_types(void) { NMConnection *connection; - NMSetting * setting; + NMSetting *setting; gboolean success; - GError * error = NULL; + GError *error = NULL; /* Test various non-base connection types to make sure they are rejected; * using a fake 'wired' connection so the rest of it verifies @@ -4303,8 +4304,8 @@ test_setting_compare_addresses(void) { gs_unref_object NMSetting *s1 = NULL, *s2 = NULL; gboolean success; - NMIPAddress * a; - GHashTable * result = NULL; + NMIPAddress *a; + GHashTable *result = NULL; s1 = nm_setting_ip4_config_new(); s2 = nm_setting_ip4_config_new(); @@ -4335,8 +4336,8 @@ test_setting_compare_routes(void) { gs_unref_object NMSetting *s1 = NULL, *s2 = NULL; gboolean success; - NMIPRoute * r; - GHashTable * result = NULL; + NMIPRoute *r; + GHashTable *result = NULL; s1 = nm_setting_ip4_config_new(); s2 = nm_setting_ip4_config_new(); @@ -4367,7 +4368,7 @@ test_setting_compare_wired_cloned_mac_address(void) { gs_unref_object NMSetting *old = NULL, *new = NULL; gboolean success; - gs_free char * str1 = NULL; + gs_free char *str1 = NULL; old = nm_setting_wired_new(); g_object_set(old, NM_SETTING_WIRED_CLONED_MAC_ADDRESS, "stable", NULL); @@ -4411,7 +4412,7 @@ test_setting_compare_wireless_cloned_mac_address(void) { gs_unref_object NMSetting *old = NULL, *new = NULL; gboolean success; - gs_free char * str1 = NULL; + gs_free char *str1 = NULL; old = nm_setting_wireless_new(); g_object_set(old, NM_SETTING_WIRELESS_CLONED_MAC_ADDRESS, "stable", NULL); @@ -4501,8 +4502,8 @@ test_data_compare_secrets_new(NMSettingSecretFlags secret_flags, } static void -_test_compare_secrets_check_diff(NMSetting * a, - NMSetting * b, +_test_compare_secrets_check_diff(NMSetting *a, + NMSetting *b, NMSettingCompareFlags flags, gboolean exp_same_psk, gboolean exp_same_psk_flags) @@ -4617,11 +4618,11 @@ _test_compare_secrets_check_diff(NMSetting * a, static void test_setting_compare_secrets(gconstpointer test_data) { - const TestDataCompareSecrets *data = test_data; - gs_unref_object NMConnection *conn_old = NULL; - gs_unref_object NMConnection *conn_new = NULL; - gs_unref_object NMSetting *old = NULL; - gs_unref_object NMSetting *new = NULL; + const TestDataCompareSecrets *data = test_data; + gs_unref_object NMConnection *conn_old = NULL; + gs_unref_object NMConnection *conn_new = NULL; + gs_unref_object NMSetting *old = NULL; + gs_unref_object NMSetting *new = NULL; /* Make sure that a connection with transient/unsaved secrets compares * successfully to the same connection without those secrets. @@ -4700,8 +4701,8 @@ static void test_setting_compare_vpn_secrets(gconstpointer test_data) { const TestDataCompareSecrets *data = test_data; - gs_unref_object NMSetting *old = NULL, *new = NULL; - gboolean success; + gs_unref_object NMSetting *old = NULL, *new = NULL; + gboolean success; /* Make sure that a connection with transient/unsaved secrets compares * successfully to the same connection without those secrets. @@ -4773,15 +4774,15 @@ test_hwaddr_aton_malformed(void) static void test_hwaddr_equal(void) { - const char * string = "00:1a:2b:03:44:05"; - const char * upper_string = "00:1A:2B:03:44:05"; - const char * bad_string = "0:1a:2b:3:44:5"; + const char *string = "00:1a:2b:03:44:05"; + const char *upper_string = "00:1A:2B:03:44:05"; + const char *bad_string = "0:1a:2b:3:44:5"; const guint8 binary[ETH_ALEN] = {0x00, 0x1A, 0x2B, 0x03, 0x44, 0x05}; - const char * other_string = "1a:2b:03:44:05:00"; + const char *other_string = "1a:2b:03:44:05:00"; const guint8 other_binary[ETH_ALEN] = {0x1A, 0x2B, 0x03, 0x44, 0x05, 0x00}; - const char * long_string = "00:1a:2b:03:44:05:06:07"; + const char *long_string = "00:1a:2b:03:44:05:06:07"; const guint8 long_binary[8] = {0x00, 0x1A, 0x2B, 0x03, 0x44, 0x05, 0x06, 0x07}; - const char * null_string = "00:00:00:00:00:00"; + const char *null_string = "00:00:00:00:00:00"; const guint8 null_binary[ETH_ALEN] = {0x00, 0x00, 0x00, 0x00, 0x00, 0x00}; g_assert(nm_utils_hwaddr_matches(string, -1, string, -1)); @@ -4860,7 +4861,7 @@ test_hwaddr_canonical(void) const char *short_string = "0:1a:2b:3:44:5"; const char *hyphen_string = "00-1a-2b-03-44-05"; const char *invalid_string = "00:1A:2B"; - char * canonical; + char *canonical; canonical = nm_utils_hwaddr_canonical(string, ETH_ALEN); g_assert_cmpstr(canonical, ==, string); @@ -5032,10 +5033,10 @@ test_connection_changed_signal(void) static void test_setting_connection_changed_signal(void) { - NMConnection * connection; + NMConnection *connection; gboolean changed = FALSE; NMSettingConnection *s_con; - gs_free char * uuid = NULL; + gs_free char *uuid = NULL; connection = nm_simple_connection_new(); g_signal_connect(connection, @@ -5069,7 +5070,7 @@ test_setting_connection_changed_signal(void) static void test_setting_bond_changed_signal(void) { - NMConnection * connection; + NMConnection *connection; gboolean changed = FALSE; NMSettingBond *s_bond; @@ -5092,12 +5093,12 @@ test_setting_bond_changed_signal(void) static void test_setting_ip4_changed_signal(void) { - NMConnection * connection; + NMConnection *connection; gboolean changed = FALSE; NMSettingIPConfig *s_ip4; - NMIPAddress * addr; - NMIPRoute * route; - GError * error = NULL; + NMIPAddress *addr; + NMIPRoute *route; + GError *error = NULL; connection = nm_simple_connection_new(); g_signal_connect(connection, @@ -5168,12 +5169,12 @@ test_setting_ip4_changed_signal(void) static void test_setting_ip6_changed_signal(void) { - NMConnection * connection; + NMConnection *connection; gboolean changed = FALSE; NMSettingIPConfig *s_ip6; - NMIPAddress * addr; - NMIPRoute * route; - GError * error = NULL; + NMIPAddress *addr; + NMIPRoute *route; + GError *error = NULL; connection = nm_simple_connection_new(); g_signal_connect(connection, @@ -5238,7 +5239,7 @@ test_setting_ip6_changed_signal(void) static void test_setting_vlan_changed_signal(void) { - NMConnection * connection; + NMConnection *connection; gboolean changed = FALSE; NMSettingVlan *s_vlan; @@ -5300,7 +5301,7 @@ test_setting_vpn_changed_signal(void) static void test_setting_wired_changed_signal(void) { - NMConnection * connection; + NMConnection *connection; gboolean changed = FALSE; NMSettingWired *s_wired; @@ -5323,7 +5324,7 @@ test_setting_wired_changed_signal(void) static void test_setting_wireless_changed_signal(void) { - NMConnection * connection; + NMConnection *connection; gboolean changed = FALSE; NMSettingWireless *s_wifi; @@ -5344,7 +5345,7 @@ test_setting_wireless_changed_signal(void) static void test_setting_wireless_security_changed_signal(void) { - NMConnection * connection; + NMConnection *connection; gboolean changed = FALSE; NMSettingWirelessSecurity *s_wsec; @@ -5411,7 +5412,7 @@ test_setting_wireless_security_changed_signal(void) static void test_setting_802_1x_changed_signal(void) { - NMConnection * connection; + NMConnection *connection; gboolean changed = FALSE; NMSetting8021x *s_8021x; @@ -5505,13 +5506,13 @@ test_connection_normalize_uuid(void) static void test_connection_normalize_virtual_iface_name(void) { - NMConnection * con = NULL; + NMConnection *con = NULL; NMSettingConnection *s_con; - NMSettingVlan * s_vlan; - GVariant * connection_dict, *setting_dict, *var; - GError * error = NULL; - const char * IFACE_NAME = "iface"; - const char * IFACE_VIRT = "iface-X"; + NMSettingVlan *s_vlan; + GVariant *connection_dict, *setting_dict, *var; + GError *error = NULL; + const char *IFACE_NAME = "iface"; + const char *IFACE_VIRT = "iface-X"; con = nmtst_create_minimal_connection("test1", "22001632-bbb4-4616-b277-363dce3dfb5b", @@ -5605,11 +5606,11 @@ _test_connection_normalize_type_normalizable_setting( const char *type, void (*prepare_normalizable_fcn)(NMConnection *con)) { - NMSettingConnection *s_con; - NMSetting * s_base; - GType base_type; + NMSettingConnection *s_con; + NMSetting *s_base; + GType base_type; gs_unref_object NMConnection *con = NULL; - gs_free char * id = g_strdup_printf("%s[%s]", G_STRFUNC, type); + gs_free char *id = g_strdup_printf("%s[%s]", G_STRFUNC, type); base_type = nm_setting_lookup_type(type); g_assert(base_type != G_TYPE_INVALID); @@ -5640,10 +5641,10 @@ _test_connection_normalize_type_normalizable_setting( static void _test_connection_normalize_type_unnormalizable_setting(const char *type) { - NMSettingConnection *s_con; - GType base_type; + NMSettingConnection *s_con; + GType base_type; gs_unref_object NMConnection *con = NULL; - gs_free char * id = g_strdup_printf("%s[%s]", G_STRFUNC, type); + gs_free char *id = g_strdup_printf("%s[%s]", G_STRFUNC, type); base_type = nm_setting_lookup_type(type); g_assert(base_type != G_TYPE_INVALID); @@ -5666,11 +5667,11 @@ static void _test_connection_normalize_type_normalizable_type(const char *type, NMSetting *(*add_setting_fcn)(NMConnection *con)) { - NMSettingConnection *s_con; - NMSetting * s_base; - GType base_type; + NMSettingConnection *s_con; + NMSetting *s_base; + GType base_type; gs_unref_object NMConnection *con = NULL; - gs_free char * id = g_strdup_printf("%s[%s]", G_STRFUNC, type); + gs_free char *id = g_strdup_printf("%s[%s]", G_STRFUNC, type); base_type = nm_setting_lookup_type(type); g_assert(base_type != G_TYPE_INVALID); @@ -5738,7 +5739,7 @@ _add_setting_fcn_bluetooth(NMConnection *con) static NMSetting * _add_setting_fcn_bond(NMConnection *con) { - NMSetting * setting; + NMSetting *setting; NMSettingConnection *s_con; setting = g_object_new(NM_TYPE_SETTING_BOND, NULL); @@ -5755,7 +5756,7 @@ _add_setting_fcn_bond(NMConnection *con) static NMSetting * _add_setting_fcn_bridge(NMConnection *con) { - NMSetting * setting; + NMSetting *setting; NMSettingConnection *s_con; setting = g_object_new(NM_TYPE_SETTING_BRIDGE, NULL); @@ -5797,9 +5798,9 @@ _add_setting_fcn_infiniband(NMConnection *con) static NMSetting * _add_setting_fcn_olpc_mesh(NMConnection *con) { - NMSetting * setting; + NMSetting *setting; const char *ssid_data = "ssid-test"; - GBytes * ssid; + GBytes *ssid; ssid = g_bytes_new(ssid_data, strlen(ssid_data)); setting = g_object_new(NM_TYPE_SETTING_OLPC_MESH, @@ -5817,7 +5818,7 @@ _add_setting_fcn_olpc_mesh(NMConnection *con) static NMSetting * _add_setting_fcn_team(NMConnection *con) { - NMSetting * setting; + NMSetting *setting; NMSettingConnection *s_con; setting = g_object_new(NM_TYPE_SETTING_TEAM, NULL); @@ -5871,9 +5872,9 @@ _add_setting_fcn_wimax(NMConnection *con) static NMSetting * _add_setting_fcn_wireless(NMConnection *con) { - NMSetting * setting; + NMSetting *setting; const char *ssid_data = "ssid-test"; - GBytes * ssid; + GBytes *ssid; ssid = g_bytes_new(ssid_data, strlen(ssid_data)); setting = g_object_new(NM_TYPE_SETTING_WIRELESS, NM_SETTING_WIRELESS_SSID, ssid, NULL); @@ -5939,7 +5940,7 @@ static void test_connection_normalize_slave_type_1(void) { gs_unref_object NMConnection *con = NULL; - NMSettingConnection * s_con; + NMSettingConnection *s_con; con = nmtst_create_minimal_connection("test_connection_normalize_slave_type_1", "cc4cd5df-45dc-483e-b291-6b76c2338ecb", @@ -5975,7 +5976,7 @@ static void test_connection_normalize_slave_type_2(void) { gs_unref_object NMConnection *con = NULL; - NMSettingConnection * s_con; + NMSettingConnection *s_con; con = nmtst_create_minimal_connection("test_connection_normalize_slave_type_2", "40bea008-ca72-439a-946b-e65f827656f9", @@ -6013,7 +6014,7 @@ static void test_connection_normalize_infiniband_mtu(void) { gs_unref_object NMConnection *con = NULL; - NMSettingInfiniband * s_infini; + NMSettingInfiniband *s_infini; guint mtu_regular = nmtst_rand_select(2044, 2045, 65520); con = nmtst_create_minimal_connection("test_connection_normalize_infiniband_mtu", @@ -6073,9 +6074,9 @@ static void test_connection_normalize_gateway_never_default(void) { gs_unref_object NMConnection *con = NULL; - NMSettingIPConfig * s_ip4, *s_ip6; - NMIPAddress * addr; - gs_free_error GError *error = NULL; + NMSettingIPConfig *s_ip4, *s_ip6; + NMIPAddress *addr; + gs_free_error GError *error = NULL; con = nmtst_create_minimal_connection("test1", NULL, NM_SETTING_WIRED_SETTING_NAME, NULL); nmtst_assert_connection_verifies_and_normalizable(con); @@ -6124,7 +6125,7 @@ static void test_connection_normalize_may_fail(void) { gs_unref_object NMConnection *con = NULL; - NMSettingIPConfig * s_ip4, *s_ip6; + NMSettingIPConfig *s_ip4, *s_ip6; con = nmtst_create_minimal_connection("test2", NULL, NM_SETTING_WIRED_SETTING_NAME, NULL); nmtst_assert_connection_verifies_and_normalizable(con); @@ -6166,9 +6167,9 @@ static void test_connection_normalize_shared_addresses(void) { gs_unref_object NMConnection *con = NULL; - NMSettingIPConfig * s_ip4, *s_ip6; - NMIPAddress * addr; - gs_free_error GError *error = NULL; + NMSettingIPConfig *s_ip4, *s_ip6; + NMIPAddress *addr; + gs_free_error GError *error = NULL; con = nmtst_create_minimal_connection("test1", NULL, NM_SETTING_WIRED_SETTING_NAME, NULL); nmtst_assert_connection_verifies_and_normalizable(con); @@ -6217,10 +6218,10 @@ test_connection_normalize_shared_addresses(void) static void test_connection_normalize_ovs_interface_type_system(gconstpointer test_data) { - const guint TEST_CASE = GPOINTER_TO_UINT(test_data); - gs_unref_object NMConnection *con = NULL; - NMSettingConnection * s_con; - NMSettingOvsInterface * s_ovs_if; + const guint TEST_CASE = GPOINTER_TO_UINT(test_data); + gs_unref_object NMConnection *con = NULL; + NMSettingConnection *s_con; + NMSettingOvsInterface *s_ovs_if; con = nmtst_create_minimal_connection("test_connection_normalize_ovs_interface_type_system", NULL, @@ -6370,13 +6371,13 @@ test_connection_normalize_ovs_interface_type_system(gconstpointer test_data) static void test_connection_normalize_ovs_interface_type_ovs_interface(gconstpointer test_data) { - const guint TEST_CASE = GPOINTER_TO_UINT(test_data); - gs_unref_object NMConnection *con = NULL; - NMSettingConnection * s_con; - NMSettingOvsInterface * s_ovs_if; - NMSettingOvsPatch * s_ovs_patch; - NMSettingIP4Config * s_ip4; - NMSettingIP6Config * s_ip6; + const guint TEST_CASE = GPOINTER_TO_UINT(test_data); + gs_unref_object NMConnection *con = NULL; + NMSettingConnection *s_con; + NMSettingOvsInterface *s_ovs_if; + NMSettingOvsPatch *s_ovs_patch; + NMSettingIP4Config *s_ip4; + NMSettingIP6Config *s_ip6; con = nmtst_create_minimal_connection( "test_connection_normalize_ovs_interface_type_ovs_interface", @@ -6602,16 +6603,16 @@ test_connection_normalize_ovs_interface_type_ovs_interface(gconstpointer test_da static void test_setting_ip4_gateway(void) { - NMConnection * conn; + NMConnection *conn; NMSettingIPConfig *s_ip4; - NMIPAddress * addr; - GVariant * conn_dict, *ip4_dict, *value; + NMIPAddress *addr; + GVariant *conn_dict, *ip4_dict, *value; GVariantIter iter; - GVariant * addr_var; + GVariant *addr_var; guint32 addr_vals_0[] = {htonl(0xc0a8010a), 0x00000018, htonl(0x00000000)}; guint32 addr_vals_1[] = {htonl(0xc0a8010b), 0x00000018, htonl(0xc0a80101)}; GVariantBuilder addrs_builder; - GError * error = NULL; + GError *error = NULL; nmtst_assert_ip4_address(addr_vals_0[0], "192.168.1.10"); @@ -6713,12 +6714,12 @@ test_setting_ip4_gateway(void) static void test_setting_ip6_gateway(void) { - NMConnection * conn; + NMConnection *conn; NMSettingIPConfig *s_ip6; - NMIPAddress * addr; - GVariant * conn_dict, *ip6_dict, *value; + NMIPAddress *addr; + GVariant *conn_dict, *ip6_dict, *value; GVariantIter iter; - GVariant * gateway_var; + GVariant *gateway_var; GVariantBuilder addrs_builder; guint8 addr_bytes_0[] = {0xab, 0xcd, @@ -6768,7 +6769,7 @@ test_setting_ip6_gateway(void) 0x00, 0x00, 0x01}; - GError * error = NULL; + GError *error = NULL; /* When serializing on the daemon side, ipv6.gateway is copied to the first * entry of ipv6.addresses @@ -6872,7 +6873,7 @@ test_setting_ip6_gateway(void) } typedef struct { - const char * str; + const char *str; const guint8 expected[20]; const guint expected_len; } HexItem; @@ -6881,10 +6882,10 @@ static void test_setting_compare_default_strv(void) { gs_unref_object NMConnection *c1 = NULL, *c2 = NULL; - char ** strv; - NMSettingIPConfig * s_ip2, *s_ip1; + char **strv; + NMSettingIPConfig *s_ip2, *s_ip1; gboolean compare; - GHashTable * out_settings = NULL; + GHashTable *out_settings = NULL; c1 = nmtst_create_minimal_connection("test_compare_default_strv", NULL, @@ -6951,8 +6952,8 @@ static void _sock_addr_endpoint(const char *endpoint, const char *host, gint32 port) { nm_auto_unref_sockaddrendpoint NMSockAddrEndpoint *ep = NULL; - const char * s_endpoint; - const char * s_host; + const char *s_endpoint; + const char *s_host; gint32 s_port; SockAddrUnion sockaddr = {}; @@ -6993,8 +6994,8 @@ static void _sock_addr_endpoint_fixed(const char *endpoint, const char *host, guint16 port, guint scope_id) { nm_auto_unref_sockaddrendpoint NMSockAddrEndpoint *ep = NULL; - const char * s_endpoint; - const char * s_host; + const char *s_endpoint; + const char *s_host; gint32 s_port; int addr_family; NMIPAddr addrbin; @@ -7130,8 +7131,8 @@ _do_strquote(const char *str, gsize buf_len, const char *expected) { char canary = (char) nmtst_get_rand_uint32(); gs_free char *buf_full = g_malloc(buf_len + 2); - char * buf = &buf_full[1]; - const char * b; + char *buf = &buf_full[1]; + const char *b; buf[-1] = canary; buf[buf_len] = canary; @@ -7932,8 +7933,8 @@ test_nm_utils_ascii_str_to_int64_do(const char *str, int exp_errno, gint64 exp_val) { - const char * sign = ""; - const char * val; + const char *sign = ""; + const char *val; static const char *whitespaces[] = { "", " ", @@ -7972,7 +7973,7 @@ test_nm_utils_ascii_str_to_int64_do(const char *str, for (ws_post = whitespaces; *ws_post; ws_post++) { for (null = nulls; *null; null++) { for (i = 0;; i++) { - char * s; + char *s; const char *str_base = ""; if (base == 16) { @@ -8145,8 +8146,8 @@ test_nm_utils_strstrdictkey(void) .v1 = _v1, .v2 = _v2, .v_static = _nm_utils_strstrdictkey_static(_v1, _v2), \ } const struct { - const char * v1; - const char * v2; + const char *v1; + const char *v2; NMUtilsStrStrDictKey *v_static; } * val1, *val2, values[] = { @@ -8210,11 +8211,11 @@ test_nm_ptrarray_len(void) #define _PTRARRAY_LEN0(T) \ G_STMT_START \ { \ - T ** vnull = NULL; \ - T *const * vnull1 = NULL; \ + T **vnull = NULL; \ + T *const *vnull1 = NULL; \ T *const *const vnull2 = NULL; \ - T * v0[] = {NULL}; \ - T *const * v01 = v0; \ + T *v0[] = {NULL}; \ + T *const *v01 = v0; \ T *const *const v02 = v0; \ T **const v03 = v0; \ \ @@ -8241,13 +8242,13 @@ test_nm_ptrarray_len(void) { \ T x[5] = {0}; \ \ - T * v1[] = {&x[0], NULL}; \ - T *const * v11 = v1; \ + T *v1[] = {&x[0], NULL}; \ + T *const *v11 = v1; \ T *const *const v12 = v1; \ T **const v13 = v1; \ \ - T * v2[] = {&x[0], &x[1], NULL}; \ - T *const * v21 = v2; \ + T *v2[] = {&x[0], &x[1], NULL}; \ + T *const *v21 = v2; \ T *const *const v22 = v2; \ T **const v23 = v2; \ \ @@ -8273,14 +8274,14 @@ test_nm_ptrarray_len(void) /*****************************************************************************/ static void -test_nm_utils_dns_option_validate_do(char * option, +test_nm_utils_dns_option_validate_do(char *option, gboolean ipv6, const NMUtilsDNSOptionDesc *descs, gboolean exp_result, - char * exp_name, + char *exp_name, gboolean exp_value) { - char * name; + char *name; long value = 0; gboolean result; @@ -8556,7 +8557,7 @@ test_nm_utils_is_power_of_two(void) { guint64 xyes, xno; int i, j; - GRand * rand = nmtst_get_rand(); + GRand *rand = nmtst_get_rand(); int numbits; g_assert(!nm_utils_is_power_of_two(0)); @@ -8636,8 +8637,8 @@ _test_find_binary_search_cmp(gconstpointer a, gconstpointer b, gpointer dummy) static void _test_find_binary_search_do(const int *array, gsize len) { - gsize i; - gssize idx, idx2, idx_first, idx_last; + gsize i; + gssize idx, idx2, idx_first, idx_last; gs_free gconstpointer *parray = g_new(gconstpointer, len); const int NEEDLE = 0; gconstpointer pneedle = GINT_TO_POINTER(NEEDLE); @@ -8884,7 +8885,7 @@ test_nm_utils_ptrarray_find_binary_search_with_duplicates(void) static void _test_nm_utils_enum_to_str_do_full(GType type, int flags, - const char * exp_str, + const char *exp_str, const NMUtilsEnumValueInfo *value_infos) { gs_free char *str = NULL; @@ -8914,10 +8915,10 @@ _test_nm_utils_enum_to_str_do_full(GType type, static void _test_nm_utils_enum_from_str_do_full(GType type, - const char * str, + const char *str, gboolean exp_result, int exp_flags, - const char * exp_err_token, + const char *exp_err_token, const NMUtilsEnumValueInfo *value_infos) { int flags; @@ -8962,7 +8963,7 @@ static void _test_nm_utils_enum_get_values_do(GType type, int from, int to, const char *exp_str) { gs_free const char **strv = NULL; - gs_free char * str = NULL; + gs_free char *str = NULL; g_assert(exp_str); @@ -9132,9 +9133,9 @@ static void _do_test_utils_str_utf8safe_unescape(const char *str, const char *expected, gsize expected_len) { gsize l; - const char * s; + const char *s; gs_free gpointer buf_free_1 = NULL; - gs_free char * str_free_1 = NULL; + gs_free char *str_free_1 = NULL; s = nm_utils_buf_utf8safe_unescape(str, NM_UTILS_STR_UTF8_SAFE_FLAG_NONE, &l, &buf_free_1); g_assert_cmpint(expected_len, ==, l); @@ -9174,14 +9175,14 @@ _do_test_utils_str_utf8safe_unescape(const char *str, const char *expected, gsiz _do_test_utils_str_utf8safe_unescape("" str "", expected, NM_STRLEN(expected)) static void -_do_test_utils_str_utf8safe(const char * str, +_do_test_utils_str_utf8safe(const char *str, gsize str_len, - const char * expected, + const char *expected, NMUtilsStrUtf8SafeFlags flags) { - const char * str_safe; - const char * buf_safe; - const char * s; + const char *str_safe; + const char *buf_safe; + const char *s; gs_free char *str_free_1 = NULL; gs_free char *str_free_2 = NULL; gs_free char *str_free_3 = NULL; @@ -9623,8 +9624,8 @@ static void test_route_attributes_parse(void) { GHashTable *ht; - GError * error = NULL; - GVariant * variant; + GError *error = NULL; + GVariant *variant; ht = nm_utils_parse_variant_attributes("mtu=1400 src=1.2.3.4 cwnd=14", ' ', @@ -9689,7 +9690,7 @@ static void test_route_attributes_format(void) { gs_unref_hashtable GHashTable *ht = NULL; - char * str; + char *str; ht = g_hash_table_new_full(nm_str_hash, g_str_equal, NULL, (GDestroyNotify) g_variant_unref); @@ -9918,9 +9919,9 @@ test_ethtool_offload(void) /*****************************************************************************/ typedef struct { - GMainLoop * loop1; + GMainLoop *loop1; GMainContext *c2; - GSource * extra_sources[2]; + GSource *extra_sources[2]; bool got_signal[5]; int fd_2; } IntegData; @@ -9971,7 +9972,7 @@ static gboolean _test_integrate_cb_idle_2(gpointer user_data) { IntegData *d = user_data; - GSource * extra_source; + GSource *extra_source; g_assert(d->got_signal[1]); g_assert(d->got_signal[2]); @@ -9995,7 +9996,7 @@ static gboolean _test_integrate_cb_idle_1(gpointer user_data) { IntegData *d = user_data; - GSource * extra_source; + GSource *extra_source; g_assert(d->got_signal[2]); g_assert(!d->extra_sources[0]); @@ -10032,9 +10033,9 @@ _test_integrate_maincontext_cb_idle1(gpointer user_data) static void test_integrate_maincontext(gconstpointer test_data) { - const guint TEST_IDX = GPOINTER_TO_UINT(test_data); - GMainContext * c1 = g_main_context_default(); - nm_auto_unref_gmaincontext GMainContext *c2 = g_main_context_new(); + const guint TEST_IDX = GPOINTER_TO_UINT(test_data); + GMainContext *c1 = g_main_context_default(); + nm_auto_unref_gmaincontext GMainContext *c2 = g_main_context_new(); nm_auto_destroy_and_unref_gsource GSource *integ_source = NULL; integ_source = nm_utils_g_main_context_create_integrate_source(c2); @@ -10056,11 +10057,11 @@ test_integrate_maincontext(gconstpointer test_data) nm_auto_destroy_and_unref_gsource GSource *timeout_source_1 = NULL; nm_auto_destroy_and_unref_gsource GSource *idle_source_1 = NULL; nm_auto_destroy_and_unref_gsource GSource *fd_source_1 = NULL; - nm_auto_unref_gmainloop GMainLoop *loop1 = NULL; - nm_auto_close int fd_1 = -1; - nm_auto_close int fd_2 = -1; - IntegData d; - int i; + nm_auto_unref_gmainloop GMainLoop *loop1 = NULL; + nm_auto_close int fd_1 = -1; + nm_auto_close int fd_2 = -1; + IntegData d; + int i; main_timeout_source = g_timeout_source_new(3000); g_source_set_callback(main_timeout_source, nmtst_g_source_assert_not_called, NULL, NULL); @@ -10134,14 +10135,14 @@ test_nm_ip_addr_zero(void) static void test_connection_ovs_ifname(gconstpointer test_data) { - const guint TEST_CASE = GPOINTER_TO_UINT(test_data); + const guint TEST_CASE = GPOINTER_TO_UINT(test_data); gs_unref_object NMConnection *con = NULL; - NMSettingConnection * s_con = NULL; - NMSettingOvsBridge * s_ovs_bridge = NULL; - NMSettingOvsPort * s_ovs_port = NULL; - NMSettingOvsInterface * s_ovs_iface = NULL; - NMSettingOvsPatch * s_ovs_patch = NULL; - const char * ovs_iface_type = NULL; + NMSettingConnection *s_con = NULL; + NMSettingOvsBridge *s_ovs_bridge = NULL; + NMSettingOvsPort *s_ovs_port = NULL; + NMSettingOvsInterface *s_ovs_iface = NULL; + NMSettingOvsPatch *s_ovs_patch = NULL; + const char *ovs_iface_type = NULL; switch (TEST_CASE) { case 1: @@ -10345,10 +10346,10 @@ static char * _strsplit_quoted_join_strv_rand(const char *const *strv) { NMStrBuf strbuf = NM_STR_BUF_INIT(nmtst_get_rand_uint32() % 200, nmtst_get_rand_bool()); - char * result; + char *result; gsize l; gsize l2; - gsize * p_l2 = nmtst_get_rand_bool() ? &l2 : NULL; + gsize *p_l2 = nmtst_get_rand_bool() ? &l2 : NULL; gsize i; g_assert(strv); @@ -10419,14 +10420,14 @@ next_maybe_quote: } static void -_strsplit_quoted_assert_strv(const char * topic, - const char * str, +_strsplit_quoted_assert_strv(const char *topic, + const char *str, const char *const *strv1, const char *const *strv2) { nm_auto_str_buf NMStrBuf s1 = {}; nm_auto_str_buf NMStrBuf s2 = {}; - gs_free char * str_escaped = NULL; + gs_free char *str_escaped = NULL; int i; g_assert(str); @@ -10504,7 +10505,7 @@ test_strsplit_quoted(void) for (i_run = 0; i_run < 1000; i_run++) { gs_strfreev char **strv = NULL; - gs_free char * str = NULL; + gs_free char *str = NULL; /* create random strv array and join them carefully so that splitting * them will yield the original value. */ @@ -10530,7 +10531,7 @@ test_nm_property_variant_to_gvalue(void) #define _test_variant_to_gvalue_bad(variant, gtype) \ G_STMT_START \ { \ - gs_unref_variant GVariant * _variant = (variant); \ + gs_unref_variant GVariant *_variant = (variant); \ GType _gtype = (gtype); \ nm_auto_unset_gvalue GValue _gvalue = G_VALUE_INIT; \ \ @@ -10542,10 +10543,10 @@ test_nm_property_variant_to_gvalue(void) #define _test_variant_to_gvalue(variant, gtype, check) \ G_STMT_START \ { \ - gs_unref_variant GVariant * _variant = (variant); \ + gs_unref_variant GVariant *_variant = (variant); \ GType _gtype = (gtype); \ nm_auto_unset_gvalue GValue _gvalue = G_VALUE_INIT; \ - _nm_unused GValue *const gg = &_gvalue; \ + _nm_unused GValue *const gg = &_gvalue; \ \ g_value_init(&_gvalue, _gtype); \ g_assert_cmpint(_nm_property_variant_to_gvalue(_variant, &_gvalue), ==, TRUE); \ @@ -10666,6 +10667,146 @@ test_vpn_connection_state_reason(void) /*****************************************************************************/ +static void +test_system_encodings(void) +{ + const int N_RUN = 10000; + int i_run; + + g_assert(nmtst_system_encodings_for_lang("") == NULL); + g_assert(nmtst_system_encodings_for_lang("zh") == NULL); + g_assert(nmtst_system_encodings_for_lang("zh_cx") == NULL); + +#define LL(lang, ...) \ + G_STMT_START \ + { \ + const char *const _lang = "" lang ""; \ + \ + nmtst_assert_strv(nmtst_system_encodings_for_lang(_lang), __VA_ARGS__); \ + \ + if (strlen(_lang) == 2) { \ + gs_free char *_lang2 = g_strdup_printf("%s%s", _lang, "x"); \ + \ + nmtst_assert_strv(nmtst_system_encodings_for_lang(_lang2), __VA_ARGS__); \ + } \ + } \ + G_STMT_END + + LL("zh_cn", "euc-cn", "gb2312", "gb18030"); + LL("zh_hk", "big5", "euc-tw", "big5-hkcs"); + LL("zh_mo", "big5", "euc-tw"); + LL("zh_sg", "euc-cn", "gb2312", "gb18030"); + LL("zh_tw", "big5", "euc-tw"); + + LL("ar", "iso-8859-6", "windows-1256"); + LL("be", "koi8-r", "windows-1251", "iso-8859-5"); + LL("bg", "windows-1251", "koi8-r", "iso-8859-5"); + LL("cs", "iso-8859-2", "windows-1250"); + LL("el", "iso-8859-7", "windows-1253"); + LL("et", "iso-8859-4", "windows-1257"); + LL("he", "iso-8859-8", "windows-1255"); + LL("hr", "iso-8859-2", "windows-1250"); + LL("hu", "iso-8859-2", "windows-1250"); + LL("iw", "iso-8859-8", "windows-1255"); + LL("ja", "euc-jp", "shift_jis", "iso-2022-jp"); + LL("ko", "euc-kr", "iso-2022-kr", "johab"); + LL("lt", "iso-8859-4", "windows-1257"); + LL("lv", "iso-8859-4", "windows-1257"); + LL("mk", "koi8-r", "windows-1251", "iso-8859-5"); + LL("pl", "iso-8859-2", "windows-1250"); + LL("ro", "iso-8859-2", "windows-1250"); + LL("ru", "koi8-r", "windows-1251", "iso-8859-5"); + LL("sh", "iso-8859-2", "windows-1250"); + LL("sk", "iso-8859-2", "windows-1250"); + LL("sl", "iso-8859-2", "windows-1250"); + LL("sr", "koi8-r", "windows-1251", "iso-8859-5"); + LL("th", "iso-8859-11", "windows-874"); + LL("tr", "iso-8859-9", "windows-1254"); + LL("uk", "koi8-u", "koi8-r", "windows-1251"); + + g_assert(nmtst_system_encodings_get_default()); + g_assert(nmtst_system_encodings_get()); + + for (i_run = 0; i_run < N_RUN; i_run++) { + char buf[7]; + int n_buf; + int i_buf; + const char *const *e; + + if (i_run < N_RUN / 3) + n_buf = 2; + else if (i_run < 2 * N_RUN / 3) + n_buf = 5; + else + n_buf = nmtst_get_rand_uint32() % G_N_ELEMENTS(buf); + + for (i_buf = 0; i_buf < n_buf; i_buf++) { + do { + buf[i_buf] = (char) nmtst_get_rand_uint32(); + } while (buf[i_buf] == '\0'); + } + g_assert(i_buf < G_N_ELEMENTS(buf)); + buf[i_buf] = '\0'; + + g_assert_cmpint(n_buf, <, G_N_ELEMENTS(buf)); + g_assert_cmpint(strlen(buf), ==, n_buf); + + e = nmtst_system_encodings_for_lang(buf); + if (e) + g_assert_cmpint(n_buf, >=, 2); + } +} + +/*****************************************************************************/ + +static void +test_direct_string_is_refstr(void) +{ + gs_unref_object NMSetting *s1 = NULL; + gs_unref_object NMSetting *s2 = NULL; + const char *TEST_STR = "adfdsff"; + NMRefString *rstr0; + NMRefString *rstr = NULL; + + g_assert(!nmtst_ref_string_find(TEST_STR)); + + s1 = nm_setting_connection_new(); + g_object_set(s1, + NM_SETTING_CONNECTION_ID, + "uuidtest", + NM_SETTING_CONNECTION_UUID, + nm_uuid_generate_random_str_a(), + NM_SETTING_CONNECTION_TYPE, + TEST_STR, + NULL); + + rstr0 = nmtst_ref_string_find(TEST_STR); + g_assert(rstr0); + + if (nmtst_get_rand_bool()) { + rstr = nm_ref_string_new(TEST_STR); + g_assert(rstr); + g_assert(rstr == rstr0); + g_assert(rstr->str + == nm_setting_connection_get_connection_type((NMSettingConnection *) s1)); + } + + s2 = nm_setting_duplicate(s1); + g_assert(rstr0->str == nm_setting_connection_get_connection_type((NMSettingConnection *) s2)); + + g_clear_object(&s1); + if (nmtst_get_rand_bool()) + g_clear_object(&s2); + else { + g_object_set(s2, NM_SETTING_CONNECTION_TYPE, nmtst_get_rand_bool() ? "hallo" : NULL, NULL); + } + nm_ref_string_unref(rstr); + + g_assert(!nmtst_ref_string_find(TEST_STR)); +} + +/*****************************************************************************/ + NMTST_DEFINE(); int @@ -11008,5 +11149,8 @@ main(int argc, char **argv) g_test_add_func("/core/general/test_vpn_connection_state_reason", test_vpn_connection_state_reason); + g_test_add_func("/core/general/test_system_encodings", test_system_encodings); + g_test_add_func("/core/general/test_direct_string_is_refstr", test_direct_string_is_refstr); + return g_test_run(); } diff --git a/src/libnm-core-impl/tests/test-keyfile.c b/src/libnm-core-impl/tests/test-keyfile.c index db193379..9bd13ffc 100644 --- a/src/libnm-core-impl/tests/test-keyfile.c +++ b/src/libnm-core-impl/tests/test-keyfile.c @@ -26,15 +26,15 @@ /*****************************************************************************/ static void -do_test_encode_key_full(GKeyFile * kf, +do_test_encode_key_full(GKeyFile *kf, const char *name, const char *key, const char *key_decode_encode) { gs_free char *to_free1 = NULL; gs_free char *to_free2 = NULL; - const char * key2; - const char * name2; + const char *key2; + const char *name2; g_assert(key); @@ -105,7 +105,7 @@ test_encode_key(void) G_STMT_START \ { \ NMConnection **_con = (con); \ - GKeyFile ** _keyfile = (keyfile); \ + GKeyFile **_keyfile = (keyfile); \ \ g_clear_object(_con); \ nm_clear_pointer(_keyfile, g_key_file_unref); \ @@ -129,7 +129,7 @@ _assert_gbytes(GBytes *bytes, gconstpointer data, gssize len) static GKeyFile * _keyfile_load_from_data(const char *str) { - GError * error = NULL; + GError *error = NULL; gboolean success; GKeyFile *keyfile; @@ -146,7 +146,7 @@ _keyfile_load_from_data(const char *str) static GKeyFile * _nm_keyfile_write(NMConnection *connection, NMKeyfileWriteHandler handler, void *user_data) { - GError * error = NULL; + GError *error = NULL; GKeyFile *kf; g_assert(NM_IS_CONNECTION(connection)); @@ -158,13 +158,13 @@ _nm_keyfile_write(NMConnection *connection, NMKeyfileWriteHandler handler, void } static NMConnection * -_nm_keyfile_read(GKeyFile * keyfile, - const char * keyfile_name, +_nm_keyfile_read(GKeyFile *keyfile, + const char *keyfile_name, NMKeyfileReadHandler read_handler, - void * read_data, + void *read_data, gboolean needs_normalization) { - GError * error = NULL; + GError *error = NULL; NMConnection *con; gs_free char *filename = NULL; gs_free char *base_dir = NULL; @@ -208,18 +208,18 @@ _nm_keyfile_read(GKeyFile * keyfile, } static void -_keyfile_convert(NMConnection ** con, - GKeyFile ** keyfile, - const char * keyfile_name, +_keyfile_convert(NMConnection **con, + GKeyFile **keyfile, + const char *keyfile_name, NMKeyfileReadHandler read_handler, - void * read_data, + void *read_data, NMKeyfileWriteHandler write_handler, - void * write_data, + void *write_data, gboolean needs_normalization) { - NMConnection * c0; - GKeyFile * k0; - gs_unref_object NMConnection *c0_k1_c2 = NULL, *k0_c1 = NULL, *k0_c1_k2_c3 = NULL; + NMConnection *c0; + GKeyFile *k0; + gs_unref_object NMConnection *c0_k1_c2 = NULL, *k0_c1 = NULL, *k0_c1_k2_c3 = NULL; nm_auto_unref_keyfile GKeyFile *k0_c1_k2 = NULL, *c0_k1 = NULL, *c0_k1_c2_k3 = NULL; /* convert from @con to @keyfile and check that we can make @@ -263,7 +263,7 @@ _keyfile_convert(NMConnection ** con, nmtst_assert_resolve_relative_path_equals(p1, p2); if (strcmp(p1, p2) != 0) { - gs_free char * puri = NULL; + gs_free char *puri = NULL; gs_unref_bytes GBytes *pfile = NULL; g_assert(p1[0] != '/' && p2[0] == '/'); @@ -310,14 +310,14 @@ _keyfile_convert(NMConnection ** con, /*****************************************************************************/ static void -_test_8021x_cert_check(NMConnection * con, +_test_8021x_cert_check(NMConnection *con, NMSetting8021xCKScheme expected_scheme, - const void * value, + const void *value, gssize val_len) { - GKeyFile * keyfile = NULL; + GKeyFile *keyfile = NULL; NMSetting8021x *s_8021x; - gs_free char * kval = NULL; + gs_free char *kval = NULL; _keyfile_convert(&con, &keyfile, "/_test_8021x_cert_check/foo", NULL, NULL, NULL, NULL, FALSE); @@ -335,7 +335,7 @@ _test_8021x_cert_check(NMConnection * con, g_assert(kval); g_assert_cmpstr(kval, ==, value); } else if (expected_scheme == NM_SETTING_802_1X_CK_SCHEME_BLOB) { - GBytes * blob = nm_setting_802_1x_get_ca_cert_blob(s_8021x); + GBytes *blob = nm_setting_802_1x_get_ca_cert_blob(s_8021x); gs_free char *file_blob = NULL; if (val_len == -1) { @@ -363,7 +363,7 @@ _test_8021x_cert_check(NMConnection * con, static void _test_8021x_cert_check_blob_full(NMConnection *con, const void *data, gsize len) { - GBytes * bytes; + GBytes *bytes; NMSetting8021x *s_8021x = nm_connection_get_setting_802_1x(con); bytes = g_bytes_new(data, len); @@ -380,10 +380,10 @@ _test_8021x_cert_check_blob_full(NMConnection *con, const void *data, gsize len) static void _test_8021x_cert_from_files(const char *cert, const char *key) { - NMSetting8021x *s_8021x; + NMSetting8021x *s_8021x; gs_unref_object NMConnection *con = nmtst_create_minimal_connection("test-cert", NULL, NM_SETTING_WIRED_SETTING_NAME, NULL); - GError * error = NULL; + GError *error = NULL; gboolean success; NMSetting8021xCKScheme scheme = NM_SETTING_802_1X_CK_SCHEME_PATH; gs_free char *full_TEST_WIRED_TLS_CA_CERT = nmtst_file_resolve_relative_path(cert, NULL); @@ -456,9 +456,9 @@ test_8021x_cert_tpm2key(void) static void test_8021x_cert_read(void) { - GKeyFile * keyfile = NULL; - gs_unref_object NMConnection *con = NULL; - NMSetting8021x * s_8021x; + GKeyFile *keyfile = NULL; + gs_unref_object NMConnection *con = NULL; + NMSetting8021x *s_8021x; con = nmtst_create_connection_from_keyfile("[connection]\n" "type=ethernet", @@ -649,9 +649,9 @@ test_8021x_cert_read(void) static void test_team_conf_read_valid(void) { - GKeyFile * keyfile = NULL; - gs_unref_object NMConnection *con = NULL; - NMSettingTeam * s_team; + GKeyFile *keyfile = NULL; + gs_unref_object NMConnection *con = NULL; + NMSettingTeam *s_team; con = nmtst_create_connection_from_keyfile("[connection]\n" "type=team\n" @@ -671,9 +671,9 @@ test_team_conf_read_valid(void) static void test_team_conf_read_invalid(void) { - GKeyFile * keyfile = NULL; - gs_unref_object NMConnection *con = NULL; - NMSettingTeam * s_team; + GKeyFile *keyfile = NULL; + gs_unref_object NMConnection *con = NULL; + NMSettingTeam *s_team; if (!nm_json_vt()) { g_test_skip("team test requires JSON validation"); @@ -701,8 +701,8 @@ static void test_user_1(void) { nm_auto_unref_keyfile GKeyFile *keyfile = NULL; - gs_unref_object NMConnection *con = NULL; - NMSettingUser * s_user; + gs_unref_object NMConnection *con = NULL; + NMSettingUser *s_user; con = nmtst_create_connection_from_keyfile("[connection]\n" "id=t\n" @@ -728,7 +728,7 @@ test_user_1(void) #define _USER_SET_DATA(s_user, key, val) \ G_STMT_START \ { \ - GError * _error = NULL; \ + GError *_error = NULL; \ gboolean _success; \ \ _success = nm_setting_user_set_data((s_user), (key), (val), &_error); \ @@ -771,8 +771,8 @@ static void test_vpn_1(void) { nm_auto_unref_keyfile GKeyFile *keyfile = NULL; - gs_unref_object NMConnection *con = NULL; - NMSettingVpn * s_vpn; + gs_unref_object NMConnection *con = NULL; + NMSettingVpn *s_vpn; con = nmtst_create_connection_from_keyfile("[connection]\n" "id=t\n" @@ -797,19 +797,19 @@ static void test_bridge_vlans(void) { nm_auto_unref_keyfile GKeyFile *keyfile = NULL; - gs_unref_object NMConnection *con = NULL; - NMSettingBridge * s_bridge; - NMBridgeVlan * vlan; - guint16 vid, vid_end; + gs_unref_object NMConnection *con = NULL; + NMSettingBridge *s_bridge; + NMBridgeVlan *vlan; + guint16 vid, vid_end; con = nmtst_create_connection_from_keyfile("[connection]\n" - "id=t\n" - "type=bridge\n" - "interface-name=br4\n" - "\n" - "[bridge]\n" - "vlans=900 , 1 pvid untagged, 100-123 untagged\n" - "", + "id=t\n" + "type=bridge\n" + "interface-name=br4\n" + "\n" + "[bridge]\n" + "vlans=900 , 1 pvid untagged, 100-123 untagged\n" + "", "/test_bridge_port/vlans"); s_bridge = NM_SETTING_BRIDGE(nm_connection_get_setting(con, NM_TYPE_SETTING_BRIDGE)); g_assert(s_bridge); @@ -846,21 +846,21 @@ static void test_bridge_port_vlans(void) { nm_auto_unref_keyfile GKeyFile *keyfile = NULL; - gs_unref_object NMConnection *con = NULL; - NMSettingBridgePort * s_port; - NMBridgeVlan * vlan; - guint16 vid_start, vid_end; + gs_unref_object NMConnection *con = NULL; + NMSettingBridgePort *s_port; + NMBridgeVlan *vlan; + guint16 vid_start, vid_end; con = nmtst_create_connection_from_keyfile("[connection]\n" - "id=t\n" - "type=dummy\n" - "interface-name=dummy1\n" - "master=br0\n" - "slave-type=bridge\n" - "\n" - "[bridge-port]\n" - "vlans=4094 pvid , 10-20 untagged\n" - "", + "id=t\n" + "type=dummy\n" + "interface-name=dummy1\n" + "master=br0\n" + "slave-type=bridge\n" + "\n" + "[bridge-port]\n" + "vlans=4094 pvid , 10-20 untagged\n" + "", "/test_bridge_port/vlans"); s_port = NM_SETTING_BRIDGE_PORT(nm_connection_get_setting(con, NM_TYPE_SETTING_BRIDGE_PORT)); g_assert(s_port); diff --git a/src/libnm-core-impl/tests/test-secrets.c b/src/libnm-core-impl/tests/test-secrets.c index 41dcc4b3..2fa3f105 100644 --- a/src/libnm-core-impl/tests/test-secrets.c +++ b/src/libnm-core-impl/tests/test-secrets.c @@ -46,14 +46,14 @@ _assert_hints_has(GPtrArray *hints, const char *item) static NMConnection * make_tls_connection(const char *detail, NMSetting8021xCKScheme scheme) { - NMConnection * connection; + NMConnection *connection; NMSettingConnection *s_con; - NMSetting8021x * s_8021x; - NMSettingWired * s_wired; - NMSettingIP4Config * s_ip4; - char * uuid; + NMSetting8021x *s_8021x; + NMSettingWired *s_wired; + NMSettingIP4Config *s_ip4; + char *uuid; gboolean success; - GError * error = NULL; + GError *error = NULL; connection = nm_simple_connection_new(); @@ -129,8 +129,8 @@ static void test_need_tls_secrets_path(void) { NMConnection *connection; - const char * setting_name; - GPtrArray * hints = NULL; + const char *setting_name; + GPtrArray *hints = NULL; connection = make_tls_connection("need-tls-secrets-path-key", NM_SETTING_802_1X_CK_SCHEME_PATH); @@ -155,8 +155,8 @@ static void test_need_tls_secrets_blob(void) { NMConnection *connection; - const char * setting_name; - GPtrArray * hints = NULL; + const char *setting_name; + GPtrArray *hints = NULL; connection = make_tls_connection("need-tls-secrets-blob-key", NM_SETTING_802_1X_CK_SCHEME_BLOB); @@ -180,14 +180,14 @@ test_need_tls_secrets_blob(void) static NMConnection * make_tls_phase2_connection(const char *detail, NMSetting8021xCKScheme scheme) { - NMConnection * connection; + NMConnection *connection; NMSettingConnection *s_con; - NMSetting8021x * s_8021x; - NMSettingWired * s_wired; - NMSettingIP4Config * s_ip4; - char * uuid; + NMSetting8021x *s_8021x; + NMSettingWired *s_wired; + NMSettingIP4Config *s_ip4; + char *uuid; gboolean success; - GError * error = NULL; + GError *error = NULL; connection = nm_simple_connection_new(); @@ -264,8 +264,8 @@ static void test_need_tls_phase2_secrets_path(void) { NMConnection *connection; - const char * setting_name; - GPtrArray * hints = NULL; + const char *setting_name; + GPtrArray *hints = NULL; connection = make_tls_phase2_connection("need-tls-phase2-secrets-path-key", NM_SETTING_802_1X_CK_SCHEME_PATH); @@ -291,8 +291,8 @@ static void test_need_tls_phase2_secrets_blob(void) { NMConnection *connection; - const char * setting_name; - GPtrArray * hints = NULL; + const char *setting_name; + GPtrArray *hints = NULL; connection = make_tls_phase2_connection("need-tls-phase2-secrets-blob-key", NM_SETTING_802_1X_CK_SCHEME_BLOB); @@ -317,13 +317,13 @@ test_need_tls_phase2_secrets_blob(void) static NMConnection * wifi_connection_new(void) { - NMConnection * connection; - NMSettingConnection * s_con; - NMSettingWireless * s_wifi; + NMConnection *connection; + NMSettingConnection *s_con; + NMSettingWireless *s_wifi; NMSettingWirelessSecurity *s_wsec; unsigned char tmpssid[] = {0x31, 0x33, 0x33, 0x37}; - char * uuid; - GBytes * ssid; + char *uuid; + GBytes *ssid; connection = nm_simple_connection_new(); g_assert(connection); @@ -386,13 +386,13 @@ build_wep_secrets(const char *wepkey) static void test_update_secrets_wifi_single_setting(void) { - NMConnection * connection; + NMConnection *connection; NMSettingWirelessSecurity *s_wsec; - GVariant * secrets; - GError * error = NULL; + GVariant *secrets; + GError *error = NULL; gboolean success; - const char * wepkey = "11111111111111111111111111"; - const char * tmp; + const char *wepkey = "11111111111111111111111111"; + const char *tmp; /* Test update with a hashed setting of 802-11-wireless secrets */ @@ -420,14 +420,14 @@ test_update_secrets_wifi_single_setting(void) static void test_update_secrets_wifi_full_hash(void) { - NMConnection * connection; + NMConnection *connection; NMSettingWirelessSecurity *s_wsec; GVariantBuilder builder; - GVariant * all; - GError * error = NULL; + GVariant *all; + GError *error = NULL; gboolean success; - const char * wepkey = "11111111111111111111111111"; - const char * tmp; + const char *wepkey = "11111111111111111111111111"; + const char *tmp; /* Test update with a hashed connection containing only 802-11-wireless * setting and secrets. @@ -464,10 +464,10 @@ static void test_update_secrets_wifi_bad_setting_name(void) { NMConnection *connection; - GVariant * secrets; - GError * error = NULL; + GVariant *secrets; + GError *error = NULL; gboolean success; - const char * wepkey = "11111111111111111111111111"; + const char *wepkey = "11111111111111111111111111"; /* Test that passing an invalid setting name to * nm_connection_update_secrets() fails with the correct error. @@ -489,12 +489,12 @@ test_update_secrets_wifi_bad_setting_name(void) static void test_update_secrets_whole_connection(void) { - NMConnection * connection; + NMConnection *connection; NMSettingWirelessSecurity *s_wsec; - GVariant * secrets; - GError * error = NULL; + GVariant *secrets; + GError *error = NULL; gboolean success; - const char * wepkey = "11111111111111111111111111"; + const char *wepkey = "11111111111111111111111111"; /* Test calling nm_connection_update_secrets() with an entire hashed * connection including non-secrets. @@ -527,8 +527,8 @@ static void test_update_secrets_whole_connection_empty_hash(void) { gs_unref_object NMConnection *connection = NULL; - GVariant * secrets; - GError * error = NULL; + GVariant *secrets; + GError *error = NULL; gboolean success; /* Test that updating secrets with an empty connection hash returns success */ @@ -550,15 +550,15 @@ test_update_secrets_whole_connection_empty_hash(void) static void test_update_secrets_whole_connection_bad_setting(void) { - NMConnection * connection; + NMConnection *connection; NMSettingWirelessSecurity *s_wsec; - GVariant * secrets, *copy, *setting_hash; - const char * setting_name; + GVariant *secrets, *copy, *setting_hash; + const char *setting_name; GVariantBuilder conn_builder; GVariantIter conn_iter; - GError * error = NULL; + GError *error = NULL; gboolean success; - const char * wepkey = "11111111111111111111111111"; + const char *wepkey = "11111111111111111111111111"; /* Test that sending a hashed connection containing an invalid setting * name fails with the right error. @@ -601,8 +601,8 @@ static void test_update_secrets_whole_connection_empty_base_setting(void) { NMConnection *connection; - GVariant * secrets, *setting; - GError * error = NULL; + GVariant *secrets, *setting; + GError *error = NULL; gboolean success; /* Test that a hashed connection which does not have any hashed secrets @@ -632,10 +632,10 @@ static void test_update_secrets_null_setting_name_with_setting_hash(void) { NMConnection *connection; - GVariant * secrets; - GError * error = NULL; + GVariant *secrets; + GError *error = NULL; gboolean success; - const char * wepkey = "11111111111111111111111111"; + const char *wepkey = "11111111111111111111111111"; /* Ensure that a NULL setting name and only a hashed setting fails */ diff --git a/src/libnm-core-impl/tests/test-setting.c b/src/libnm-core-impl/tests/test-setting.c index 7444f2c1..d6ac37b4 100644 --- a/src/libnm-core-impl/tests/test-setting.c +++ b/src/libnm-core-impl/tests/test-setting.c @@ -48,8 +48,8 @@ _connection_new_from_dbus_strict(GVariant *dict, gboolean normalize) gs_unref_object NMConnection *con_n_0 = NULL; gs_unref_object NMConnection *con_n_s = NULL; gs_unref_object NMConnection *con_n_e = NULL; - gs_free_error GError *error = NULL; - guint i; + gs_free_error GError *error = NULL; + guint i; g_assert(g_variant_is_of_type(dict, NM_VARIANT_TYPE_CONNECTION)); @@ -128,7 +128,7 @@ test_nm_meta_setting_types_by_priority(void) for (i = 0; i < _NM_META_SETTING_TYPE_NUM; i++) { const NMMetaSettingType meta_type = nm_meta_setting_types_by_priority[i]; const NMMetaSettingInfo *setting_info; - NMSetting * setting; + NMSetting *setting; g_assert(_NM_INT_NOT_NEGATIVE(meta_type)); g_assert(meta_type < _NM_META_SETTING_TYPE_NUM); @@ -203,7 +203,7 @@ compare_blob_data(const char *test, const char *key_path, GBytes *key) { gs_free char *contents = NULL; gsize len = 0; - GError * error = NULL; + GError *error = NULL; gboolean success; g_assert(key && g_bytes_get_size(key) > 0); @@ -237,13 +237,13 @@ check_scheme_path(GBytes *value, const char *path) static void test_private_key_import(const char *path, const char *password, NMSetting8021xCKScheme scheme) { - NMSetting8021x * s_8021x; + NMSetting8021x *s_8021x; gboolean success; NMSetting8021xCKFormat format = NM_SETTING_802_1X_CK_FORMAT_UNKNOWN; NMSetting8021xCKFormat tmp_fmt; - GError * error = NULL; - GBytes * tmp_key = NULL, *client_cert = NULL; - const char * pw; + GError *error = NULL; + GBytes *tmp_key = NULL, *client_cert = NULL; + const char *pw; s_8021x = (NMSetting8021x *) nm_setting_802_1x_new(); g_assert(s_8021x); @@ -293,7 +293,7 @@ static void _do_test_connection_uuid(NMConnection *con, const char *uuid, const char *expected_uuid) { NMSettingConnection *s_con; - gs_free char * uuid_old = NULL; + gs_free char *uuid_old = NULL; gboolean success; gboolean is_normalized; char uuid_normalized[37]; @@ -407,17 +407,17 @@ test_connection_uuid(void) /*****************************************************************************/ static void -test_phase2_private_key_import(const char * path, - const char * password, +test_phase2_private_key_import(const char *path, + const char *password, NMSetting8021xCKScheme scheme) { - NMSetting8021x * s_8021x; + NMSetting8021x *s_8021x; gboolean success; NMSetting8021xCKFormat format = NM_SETTING_802_1X_CK_FORMAT_UNKNOWN; NMSetting8021xCKFormat tmp_fmt; - GError * error = NULL; - GBytes * tmp_key = NULL, *client_cert = NULL; - const char * pw; + GError *error = NULL; + GBytes *tmp_key = NULL, *client_cert = NULL; + const char *pw; s_8021x = (NMSetting8021x *) nm_setting_802_1x_new(); g_assert(s_8021x); @@ -465,11 +465,11 @@ test_phase2_private_key_import(const char * path, static void test_wrong_password_keeps_data(const char *path, const char *password) { - NMSetting8021x * s_8021x; + NMSetting8021x *s_8021x; gboolean success; NMSetting8021xCKFormat format = NM_SETTING_802_1X_CK_FORMAT_UNKNOWN; - GError * error = NULL; - const char * pw; + GError *error = NULL; + const char *pw; s_8021x = (NMSetting8021x *) nm_setting_802_1x_new(); g_assert(s_8021x); @@ -506,11 +506,11 @@ test_wrong_password_keeps_data(const char *path, const char *password) static void test_clear_private_key(const char *path, const char *password) { - NMSetting8021x * s_8021x; + NMSetting8021x *s_8021x; gboolean success; NMSetting8021xCKFormat format = NM_SETTING_802_1X_CK_FORMAT_UNKNOWN; - GError * error = NULL; - const char * pw; + GError *error = NULL; + const char *pw; s_8021x = (NMSetting8021x *) nm_setting_802_1x_new(); g_assert(s_8021x); @@ -547,11 +547,11 @@ test_clear_private_key(const char *path, const char *password) static void test_wrong_phase2_password_keeps_data(const char *path, const char *password) { - NMSetting8021x * s_8021x; + NMSetting8021x *s_8021x; gboolean success; NMSetting8021xCKFormat format = NM_SETTING_802_1X_CK_FORMAT_UNKNOWN; - GError * error = NULL; - const char * pw; + GError *error = NULL; + const char *pw; s_8021x = (NMSetting8021x *) nm_setting_802_1x_new(); g_assert(s_8021x); @@ -588,11 +588,11 @@ test_wrong_phase2_password_keeps_data(const char *path, const char *password) static void test_clear_phase2_private_key(const char *path, const char *password) { - NMSetting8021x * s_8021x; + NMSetting8021x *s_8021x; gboolean success; NMSetting8021xCKFormat format = NM_SETTING_802_1X_CK_FORMAT_UNKNOWN; - GError * error = NULL; - const char * pw; + GError *error = NULL; + const char *pw; s_8021x = (NMSetting8021x *) nm_setting_802_1x_new(); g_assert(s_8021x); @@ -683,8 +683,8 @@ static void _test_verify_options(gboolean expected_result, const char *const *options) { gs_unref_object NMConnection *con = NULL; - NMSettingBond * s_bond; - const char *const * option; + NMSettingBond *s_bond; + const char *const *option; g_assert(NM_PTRARRAY_LEN(options) % 2 == 0); @@ -777,7 +777,7 @@ static void test_bond_compare_options(gboolean exp_res, const char **opts1, const char **opts2) { gs_unref_object NMSettingBond *s_bond1 = NULL, *s_bond2 = NULL; - const char ** p; + const char **p; s_bond1 = (NMSettingBond *) nm_setting_bond_new(); g_assert(s_bond1); @@ -830,10 +830,10 @@ static void test_bond_normalize_options(const char **opts1, const char **opts2) { gs_unref_object NMConnection *con = NULL; - NMSettingBond * s_bond; - GError * error = NULL; + NMSettingBond *s_bond; + GError *error = NULL; gboolean success; - const char ** p; + const char **p; int num = 0; create_bond_connection(&con, &s_bond); @@ -880,7 +880,7 @@ static void test_dummy_normalize(void) { gs_unref_object NMConnection *connection = NULL; - NMSettingConnection * s_con; + NMSettingConnection *s_con; connection = nm_simple_connection_new(); s_con = NM_SETTING_CONNECTION(nm_setting_connection_new()); @@ -911,7 +911,7 @@ static void test_dcb_flags_valid(void) { gs_unref_object NMSettingDcb *s_dcb = NULL; - GError * error = NULL; + GError *error = NULL; gboolean success; guint i; @@ -969,7 +969,7 @@ static void test_dcb_flags_invalid(void) { gs_unref_object NMSettingDcb *s_dcb = NULL; - GError * error = NULL; + GError *error = NULL; gboolean success; s_dcb = (NMSettingDcb *) nm_setting_dcb_new(); @@ -1039,7 +1039,7 @@ static void test_dcb_app_priorities(void) { gs_unref_object NMSettingDcb *s_dcb = NULL; - GError * error = NULL; + GError *error = NULL; gboolean success; s_dcb = (NMSettingDcb *) nm_setting_dcb_new(); @@ -1107,7 +1107,7 @@ static void test_dcb_priorities_valid(void) { gs_unref_object NMSettingDcb *s_dcb = NULL; - GError * error = NULL; + GError *error = NULL; gboolean success; guint i; @@ -1166,7 +1166,7 @@ static void test_dcb_bandwidth_sums(void) { gs_unref_object NMSettingDcb *s_dcb = NULL; - GError * error = NULL; + GError *error = NULL; gboolean success; s_dcb = (NMSettingDcb *) nm_setting_dcb_new(); @@ -1225,17 +1225,17 @@ _test_team_config_sync(const char *team_config, int notify_peers_interval, int mcast_rejoin_count, int mcast_rejoin_interval, - char * runner, - char * runner_hwaddr_policy, /* activebackup */ - GPtrArray * runner_tx_hash, /* lacp, loadbalance */ - char * runner_tx_balancer, /* lacp, loadbalance */ + char *runner, + char *runner_hwaddr_policy, /* activebackup */ + GPtrArray *runner_tx_hash, /* lacp, loadbalance */ + char *runner_tx_balancer, /* lacp, loadbalance */ int runner_tx_balancer_interval, /* lacp, loadbalance */ gboolean runner_active, /* lacp */ gboolean runner_fast_rate, /* lacp */ int runner_sys_prio, /* lacp */ int runner_min_ports, /* lacp */ - char * runner_agg_select_policy, /* lacp */ - GPtrArray * link_watchers) + char *runner_agg_select_policy, /* lacp */ + GPtrArray *link_watchers) { gs_unref_object NMSettingTeam *s_team = NULL; guint i, j; @@ -1634,7 +1634,7 @@ _test_team_port_config_sync(const char *team_port_config, gboolean sticky, int lacp_prio, int lacp_key, - GPtrArray * link_watchers) + GPtrArray *link_watchers) { gs_unref_object NMSettingTeamPort *s_team_port = NULL; guint i, j; @@ -1812,8 +1812,8 @@ test_team_setting(void) G_VARIANT_TYPE_VARDICT, "{'config': <'{\"link_watch\": {\"name\": \"ethtool\"}}'>, 'interface-name': <'nm-team'>, " "'link-watchers': <[{'name': <'ethtool'>}]>}"); - gs_free_error GError *error = NULL; - gs_unref_object NMSetting * setting = NULL; + gs_free_error GError *error = NULL; + gs_unref_object NMSetting *setting = NULL; nm_auto_unref_team_link_watcher NMTeamLinkWatcher *watcher1 = nm_team_link_watcher_new_nsna_ping(1, 3, 4, "bbb", NULL); nm_auto_unref_team_link_watcher NMTeamLinkWatcher *watcher2 = @@ -1939,16 +1939,16 @@ _setting_ethtool_get_feature(NMSettingEthtool *s_ethtool, const char *opt_name) static void test_ethtool_features(void) { - gs_unref_object NMConnection *con = NULL; - gs_unref_object NMConnection *con2 = NULL; - gs_unref_object NMConnection *con3 = NULL; - gs_unref_variant GVariant *variant = NULL; - gs_free_error GError *error = NULL; + gs_unref_object NMConnection *con = NULL; + gs_unref_object NMConnection *con2 = NULL; + gs_unref_object NMConnection *con3 = NULL; + gs_unref_variant GVariant *variant = NULL; + gs_free_error GError *error = NULL; nm_auto_unref_keyfile GKeyFile *keyfile = NULL; - NMSettingConnection * s_con; - NMSettingEthtool * s_ethtool; - NMSettingEthtool * s_ethtool2; - NMSettingEthtool * s_ethtool3; + NMSettingConnection *s_con; + NMSettingEthtool *s_ethtool; + NMSettingEthtool *s_ethtool2; + NMSettingEthtool *s_ethtool3; con = nmtst_create_minimal_connection("ethtool-1", NULL, NM_SETTING_WIRED_SETTING_NAME, &s_con); s_ethtool = NM_SETTING_ETHTOOL(nm_setting_ethtool_new()); @@ -2024,16 +2024,16 @@ test_ethtool_features(void) static void test_ethtool_coalesce(void) { - gs_unref_object NMConnection *con = NULL; - gs_unref_object NMConnection *con2 = NULL; - gs_unref_object NMConnection *con3 = NULL; - gs_unref_variant GVariant *variant = NULL; - gs_free_error GError *error = NULL; + gs_unref_object NMConnection *con = NULL; + gs_unref_object NMConnection *con2 = NULL; + gs_unref_object NMConnection *con3 = NULL; + gs_unref_variant GVariant *variant = NULL; + gs_free_error GError *error = NULL; nm_auto_unref_keyfile GKeyFile *keyfile = NULL; - NMSettingConnection * s_con; - NMSettingEthtool * s_ethtool; - NMSettingEthtool * s_ethtool2; - NMSettingEthtool * s_ethtool3; + NMSettingConnection *s_con; + NMSettingEthtool *s_ethtool; + NMSettingEthtool *s_ethtool2; + NMSettingEthtool *s_ethtool3; guint32 u32; con = nmtst_create_minimal_connection("ethtool-coalesce", @@ -2120,16 +2120,16 @@ test_ethtool_coalesce(void) static void test_ethtool_ring(void) { - gs_unref_object NMConnection *con = NULL; - gs_unref_object NMConnection *con2 = NULL; - gs_unref_object NMConnection *con3 = NULL; - gs_unref_variant GVariant *variant = NULL; - gs_free_error GError *error = NULL; + gs_unref_object NMConnection *con = NULL; + gs_unref_object NMConnection *con2 = NULL; + gs_unref_object NMConnection *con3 = NULL; + gs_unref_variant GVariant *variant = NULL; + gs_free_error GError *error = NULL; nm_auto_unref_keyfile GKeyFile *keyfile = NULL; - NMSettingConnection * s_con; - NMSettingEthtool * s_ethtool; - NMSettingEthtool * s_ethtool2; - NMSettingEthtool * s_ethtool3; + NMSettingConnection *s_con; + NMSettingEthtool *s_ethtool; + NMSettingEthtool *s_ethtool2; + NMSettingEthtool *s_ethtool3; guint32 out_value; con = nmtst_create_minimal_connection("ethtool-ring", @@ -2214,16 +2214,16 @@ test_ethtool_ring(void) static void test_ethtool_pause(void) { - gs_unref_object NMConnection *con = NULL; - gs_unref_object NMConnection *con2 = NULL; - gs_unref_object NMConnection *con3 = NULL; - gs_unref_variant GVariant *variant = NULL; - gs_free_error GError *error = NULL; + gs_unref_object NMConnection *con = NULL; + gs_unref_object NMConnection *con2 = NULL; + gs_unref_object NMConnection *con3 = NULL; + gs_unref_variant GVariant *variant = NULL; + gs_free_error GError *error = NULL; nm_auto_unref_keyfile GKeyFile *keyfile = NULL; - NMSettingConnection * s_con; - NMSettingEthtool * s_ethtool; - NMSettingEthtool * s_ethtool2; - NMSettingEthtool * s_ethtool3; + NMSettingConnection *s_con; + NMSettingEthtool *s_ethtool; + NMSettingEthtool *s_ethtool2; + NMSettingEthtool *s_ethtool3; gboolean out_value; con = nmtst_create_minimal_connection("ethtool-pause", @@ -2311,8 +2311,8 @@ static void test_sriov_vf(void) { NMSriovVF *vf1, *vf2; - GError * error = NULL; - char * str; + GError *error = NULL; + char *str; vf1 = nm_sriov_vf_new(1); nm_sriov_vf_set_attribute(vf1, @@ -2369,10 +2369,10 @@ test_sriov_vf_dup(void) static void test_sriov_vf_vlan(void) { - NMSriovVF * vf; - const guint * vlan_ids; + NMSriovVF *vf; + const guint *vlan_ids; guint num; - GError * error = NULL; + GError *error = NULL; gs_free char *str = NULL; vf = nm_sriov_vf_new(19); @@ -2430,10 +2430,10 @@ static void test_sriov_setting(void) { gs_unref_object NMConnection *con = NULL; - NMSettingConnection * s_con; - NMSettingSriov * s_sriov = NULL; - NMSriovVF * vf1, *vf2, *vf3; - GError * error = NULL; + NMSettingConnection *s_con; + NMSettingSriov *s_sriov = NULL; + NMSriovVF *vf1, *vf2, *vf3; + GError *error = NULL; gboolean success; con = nm_simple_connection_new(); @@ -2491,7 +2491,7 @@ typedef struct { static void _test_sriov_parse_vlan_one(const char *string, gboolean exp_res, VlanData *data, guint data_length) { - NMSriovVF * vf; + NMSriovVF *vf; gboolean res; guint i, num_vlans; const guint *vlan_ids; @@ -2550,9 +2550,9 @@ static void test_bridge_vlans(void) { NMBridgeVlan *v1, *v2; - GError * error = NULL; + GError *error = NULL; guint16 vid_start, vid_end; - char * str; + char *str; v1 = nm_bridge_vlan_from_str("1 foobar", &error); nmtst_assert_no_success(v1, error); @@ -2641,8 +2641,8 @@ static void _test_verify_options_bridge(gboolean expected_result, const char *const *options) { gs_unref_object NMConnection *con = NULL; - NMSettingBridge * s_bridge; - const char *const * option; + NMSettingBridge *s_bridge; + const char *const *option; g_assert(NM_PTRARRAY_LEN(options) % 2 == 0); @@ -2729,9 +2729,9 @@ static void test_tc_config_qdisc(void) { NMTCQdisc *qdisc1, *qdisc2; - char * str; - GError * error = NULL; - GVariant * variant; + char *str; + GError *error = NULL; + GVariant *variant; qdisc1 = nm_tc_qdisc_new("fq_codel", TC_H_ROOT, &error); nmtst_assert_success(qdisc1, error); @@ -2844,8 +2844,8 @@ static void test_tc_config_action(void) { NMTCAction *action1, *action2; - char * str; - GError * error = NULL; + char *str; + GError *error = NULL; action1 = nm_tc_action_new("drop", &error); nmtst_assert_success(action1, error); @@ -2897,10 +2897,10 @@ test_tc_config_action(void) static void test_tc_config_tfilter_matchall_sdata(void) { - NMTCAction * action1; + NMTCAction *action1; NMTCTfilter *tfilter1, *tfilter2; - char * str; - GError * error = NULL; + char *str; + GError *error = NULL; tfilter1 = nm_tc_tfilter_new("matchall", TC_H_MAKE(0x1234u << 16, 0x0000u), &error); nmtst_assert_success(tfilter1, error); @@ -2948,12 +2948,12 @@ test_tc_config_tfilter_matchall_sdata(void) static void test_tc_config_tfilter_matchall_mirred(void) { - NMTCAction * action; - NMTCTfilter * tfilter1; - GError * error = NULL; + NMTCAction *action; + NMTCTfilter *tfilter1; + GError *error = NULL; gs_strfreev char **attr_names = NULL; - gs_free char * str; - GVariant * variant; + gs_free char *str = NULL; + GVariant *variant; tfilter1 = nm_utils_tc_tfilter_from_str("parent ffff: matchall action mirred ingress mirror dev eth0", @@ -2995,8 +2995,8 @@ static void test_tc_config_setting_valid(void) { gs_unref_object NMSettingTCConfig *s_tc = NULL; - NMTCQdisc * qdisc1, *qdisc2; - GError * error = NULL; + NMTCQdisc *qdisc1, *qdisc2; + GError *error = NULL; s_tc = (NMSettingTCConfig *) nm_setting_tc_config_new(); @@ -3028,12 +3028,12 @@ test_tc_config_setting_duplicates(void) { gs_unref_ptrarray GPtrArray *qdiscs = NULL; gs_unref_ptrarray GPtrArray *tfilters = NULL; - NMSettingConnection * s_con; - NMConnection * con; - NMSetting * s_tc; - NMTCQdisc * qdisc; - NMTCTfilter * tfilter; - GError * error = NULL; + NMSettingConnection *s_con; + NMConnection *con; + NMSetting *s_tc; + NMTCQdisc *qdisc; + NMTCTfilter *tfilter; + GError *error = NULL; con = nmtst_create_minimal_connection("dummy", NULL, NM_SETTING_DUMMY_SETTING_NAME, &s_con); g_object_set(s_con, NM_SETTING_CONNECTION_INTERFACE_NAME, "dummy1", NULL); @@ -3088,12 +3088,12 @@ static void test_tc_config_dbus(void) { NMConnection *connection1, *connection2; - NMSetting * s_tc; - NMTCQdisc * qdisc1, *qdisc2; - NMTCTfilter * tfilter1, *tfilter2; - NMTCAction * action; - GVariant * dbus, *tc_dbus, *var1, *var2; - GError * error = NULL; + NMSetting *s_tc; + NMTCQdisc *qdisc1, *qdisc2; + NMTCTfilter *tfilter1, *tfilter2; + NMTCAction *action; + GVariant *dbus, *tc_dbus, *var1, *var2; + GError *error = NULL; gboolean success; connection1 = @@ -3183,13 +3183,13 @@ test_tc_config_dbus(void) static void _rndt_wired_add_s390_options(NMSettingWired *s_wired, char **out_keyfile_entries) { - gsize n_opts; - gsize i, j; - const char *const * option_names; - gs_free const char **opt_keys = NULL; - gs_strfreev char ** opt_vals = NULL; - gs_free bool * opt_found = NULL; - GString * keyfile_entries; + gsize n_opts; + gsize i, j; + const char *const *option_names; + gs_free const char **opt_keys = NULL; + gs_strfreev char **opt_vals = NULL; + gs_free bool *opt_found = NULL; + GString *keyfile_entries; nm_auto_free_gstring GString *str_tmp = NULL; option_names = nm_setting_wired_get_valid_s390_options(nmtst_get_rand_bool() ? NULL : s_wired); @@ -3288,9 +3288,9 @@ _rndt_wg_peers_create(void) NMWireGuardPeer *peer; guint8 public_key_buf[NM_WIREGUARD_PUBLIC_KEY_LEN]; guint8 preshared_key_buf[NM_WIREGUARD_SYMMETRIC_KEY_LEN]; - gs_free char * public_key = NULL; - gs_free char * preshared_key = NULL; - gs_free char * s_endpoint = NULL; + gs_free char *public_key = NULL; + gs_free char *preshared_key = NULL; + gs_free char *s_endpoint = NULL; guint i_aip, n_aip; /* we don't bother to create a valid curve25519 public key. Of course, libnm cannot @@ -3358,11 +3358,11 @@ _rndt_wg_peers_to_keyfile(GPtrArray *wg_peers, gboolean strict, char **out_str) nm_gstring_prepare(&gstr); for (i = 0; i < wg_peers->len; i++) { const NMWireGuardPeer *peer = wg_peers->pdata[i]; - gs_free char * s_endpoint = NULL; - gs_free char * s_preshared_key = NULL; - gs_free char * s_preshared_key_flags = NULL; - gs_free char * s_persistent_keepalive = NULL; - gs_free char * s_allowed_ips = NULL; + gs_free char *s_endpoint = NULL; + gs_free char *s_preshared_key = NULL; + gs_free char *s_preshared_key_flags = NULL; + gs_free char *s_persistent_keepalive = NULL; + gs_free char *s_allowed_ips = NULL; if (nm_wireguard_peer_get_endpoint(peer)) s_endpoint = g_strdup_printf("endpoint=%s\n", nm_wireguard_peer_get_endpoint(peer)); @@ -3421,7 +3421,7 @@ _rndt_wg_peers_to_keyfile(GPtrArray *wg_peers, gboolean strict, char **out_str) static void _rndt_wg_peers_assert_equal(NMSettingWireGuard *s_wg, - GPtrArray * peers, + GPtrArray *peers, gboolean consider_persistent_secrets, gboolean consider_all_secrets, gboolean expect_no_secrets) @@ -3476,8 +3476,8 @@ _rndt_wg_peers_fix_secrets(NMSettingWireGuard *s_wg, GPtrArray *peers) g_assert_cmpint(peers->len, ==, nm_setting_wireguard_get_peers_len(s_wg)); for (i = 0; i < peers->len; i++) { - const NMWireGuardPeer *a = peers->pdata[i]; - const NMWireGuardPeer *b = nm_setting_wireguard_get_peer(s_wg, i); + const NMWireGuardPeer *a = peers->pdata[i]; + const NMWireGuardPeer *b = nm_setting_wireguard_get_peer(s_wg, i); nm_auto_unref_wgpeer NMWireGuardPeer *b_clone = NULL; g_assert(a); @@ -3538,23 +3538,23 @@ test_roundtrip_conversion(gconstpointer test_data) nmtst_rand_select(NM_SETTING_SECRET_FLAG_NONE, NM_SETTING_SECRET_FLAG_NOT_SAVED, NM_SETTING_SECRET_FLAG_AGENT_OWNED); - const guint WG_LISTEN_PORT = nmtst_rand_select(0u, nmtst_get_rand_uint32() % 0x10000); - const guint WG_FWMARK = nmtst_rand_select(0u, nmtst_get_rand_uint32()); - gs_unref_ptrarray GPtrArray *kf_data_arr = g_ptr_array_new_with_free_func(g_free); - gs_unref_ptrarray GPtrArray * wg_peers = NULL; + const guint WG_LISTEN_PORT = nmtst_rand_select(0u, nmtst_get_rand_uint32() % 0x10000); + const guint WG_FWMARK = nmtst_rand_select(0u, nmtst_get_rand_uint32()); + gs_unref_ptrarray GPtrArray *kf_data_arr = g_ptr_array_new_with_free_func(g_free); + gs_unref_ptrarray GPtrArray *wg_peers = NULL; const NMConnectionSerializationFlags dbus_serialization_flags[] = { NM_CONNECTION_SERIALIZE_ALL, NM_CONNECTION_SERIALIZE_WITH_NON_SECRET, NM_CONNECTION_SERIALIZE_WITH_SECRETS, }; - guint dbus_serialization_flags_idx; - gs_unref_object NMConnection *con = NULL; - gs_free_error GError *error = NULL; - gs_free char * tmp_str = NULL; - guint kf_data_idx; - NMSettingConnection * s_con = NULL; - NMSettingWired * s_eth = NULL; - NMSettingWireGuard * s_wg = NULL; + guint dbus_serialization_flags_idx; + gs_unref_object NMConnection *con = NULL; + gs_free_error GError *error = NULL; + gs_free char *tmp_str = NULL; + guint kf_data_idx; + NMSettingConnection *s_con = NULL; + NMSettingWired *s_eth = NULL; + NMSettingWireGuard *s_wg = NULL; union { struct { NMSettingIPConfig *s_6; @@ -3849,8 +3849,8 @@ test_roundtrip_conversion(gconstpointer test_data) /* check that reading any of kf_data_arr yields the same result that we expect. */ for (kf_data_idx = 0; kf_data_idx < kf_data_arr->len; kf_data_idx++) { gs_unref_object NMConnection *con2 = NULL; - NMSettingWireGuard * s_wg2 = NULL; - NMSettingWired * s_eth2 = NULL; + NMSettingWireGuard *s_wg2 = NULL; + NMSettingWired *s_eth2 = NULL; con2 = nmtst_create_connection_from_keyfile(kf_data_arr->pdata[kf_data_idx], "/no/where/file.nmconnection"); @@ -3918,9 +3918,9 @@ test_roundtrip_conversion(gconstpointer test_data) dbus_serialization_flags_idx++) { NMConnectionSerializationFlags flag = dbus_serialization_flags[dbus_serialization_flags_idx]; - gs_unref_variant GVariant *con_var = NULL; - gs_unref_object NMConnection *con2 = NULL; - NMSettingWireGuard * s_wg2 = NULL; + gs_unref_variant GVariant *con_var = NULL; + gs_unref_object NMConnection *con2 = NULL; + NMSettingWireGuard *s_wg2 = NULL; con_var = nm_connection_to_dbus(con, flag); g_assert(g_variant_is_of_type(con_var, NM_VARIANT_TYPE_CONNECTION)); @@ -3963,12 +3963,12 @@ test_roundtrip_conversion(gconstpointer test_data) static NMIPRoutingRule * _rr_from_str_get_impl(const char *str, const char *const *aliases) { - nm_auto_unref_ip_routing_rule NMIPRoutingRule *rr = NULL; - gs_free_error GError * error = NULL; - gboolean vbool; - int addr_family; - int i; - NMIPRoutingRuleAsStringFlags to_string_flags; + nm_auto_unref_ip_routing_rule NMIPRoutingRule *rr = NULL; + gs_free_error GError *error = NULL; + gboolean vbool; + int addr_family; + int i; + NMIPRoutingRuleAsStringFlags to_string_flags; rr = nm_ip_routing_rule_from_string(str, NM_IP_ROUTING_RULE_AS_STRING_FLAGS_VALIDATE, @@ -3985,10 +3985,10 @@ _rr_from_str_get_impl(const char *str, const char *const *aliases) to_string_flags = NM_IP_ROUTING_RULE_AS_STRING_FLAGS_AF_INET6; for (i = 0; TRUE; i++) { - nm_auto_unref_ip_routing_rule NMIPRoutingRule *rr2 = NULL; - gs_free char * str1 = NULL; - gs_unref_variant GVariant *variant1 = NULL; - const char * cstr1; + nm_auto_unref_ip_routing_rule NMIPRoutingRule *rr2 = NULL; + gs_free char *str1 = NULL; + gs_unref_variant GVariant *variant1 = NULL; + const char *cstr1; switch (i) { case 0: @@ -4084,7 +4084,7 @@ test_routing_rule(gconstpointer test_data) nm_auto_unref_ip_routing_rule NMIPRoutingRule *rr1 = NULL; gboolean success; char ifname_buf[16]; - gs_free_error GError *error = NULL; + gs_free_error GError *error = NULL; _rr_from_str("priority 5 from 0.0.0.0 table 1", " from 0.0.0.0 priority 5 lookup 1 "); _rr_from_str("priority 5 from 0.0.0.0/0 table 4"); @@ -4190,7 +4190,7 @@ test_parse_tc_handle(void) G_STMT_START \ { \ gs_free_error GError *_error = NULL; \ - GError ** _perror = nmtst_get_rand_bool() ? &_error : NULL; \ + GError **_perror = nmtst_get_rand_bool() ? &_error : NULL; \ guint32 _v; \ const guint32 _v_exp = (exp); \ \ @@ -4247,12 +4247,12 @@ test_parse_tc_handle(void) static void test_empty_setting(void) { - gs_unref_object NMConnection *con = NULL; - gs_unref_object NMConnection *con2 = NULL; - NMSettingBluetooth * s_bt; - NMSettingGsm * s_gsm; - nm_auto_unref_keyfile GKeyFile *kf = NULL; - gs_free_error GError *error = NULL; + gs_unref_object NMConnection *con = NULL; + gs_unref_object NMConnection *con2 = NULL; + NMSettingBluetooth *s_bt; + NMSettingGsm *s_gsm; + nm_auto_unref_keyfile GKeyFile *kf = NULL; + gs_free_error GError *error = NULL; con = nmtst_create_minimal_connection("bt-empty-gsm", "dca3192a-f2dc-48eb-b806-d0ff788f122c", @@ -4307,7 +4307,7 @@ _PROP_IDX_OWNER(GHashTable *h_property_types, const NMSettInfoPropertType *prope const NMSettInfoSetting *sett_info_settings = nmtst_sett_info_settings(); const NMSettInfoSetting *sis; const NMMetaSettingInfo *msi; - GArray * arr; + GArray *arr; guint idx; NMMetaSettingType meta_type; guint prop_idx; @@ -4341,8 +4341,8 @@ _PROP_IDX_OWNER(GHashTable *h_property_types, const NMSettInfoPropertType *prope static void test_setting_metadata(void) { - const NMSettInfoSetting *sett_info_settings = nmtst_sett_info_settings(); - NMMetaSettingType meta_type; + const NMSettInfoSetting *sett_info_settings = nmtst_sett_info_settings(); + NMMetaSettingType meta_type; gs_unref_hashtable GHashTable *h_property_types = NULL; G_STATIC_ASSERT(_NM_META_SETTING_TYPE_NUM == NM_META_SETTING_TYPE_UNKNOWN); @@ -4351,7 +4351,7 @@ test_setting_metadata(void) g_hash_table_new_full(nm_direct_hash, NULL, NULL, (GDestroyNotify) g_array_unref); for (meta_type = 0; meta_type < _NM_META_SETTING_TYPE_NUM; meta_type++) { - const NMMetaSettingInfo *msi = &nm_meta_setting_infos[meta_type]; + const NMMetaSettingInfo *msi = &nm_meta_setting_infos[meta_type]; nm_auto_unref_gtypeclass NMSettingClass *klass = NULL; GType gtype; @@ -4382,17 +4382,17 @@ test_setting_metadata(void) g_assert(sett_info_settings); for (meta_type = 0; meta_type < _NM_META_SETTING_TYPE_NUM; meta_type++) { - const NMSettInfoSetting *sis = &sett_info_settings[meta_type]; - const NMMetaSettingInfo *msi = &nm_meta_setting_infos[meta_type]; + const NMSettInfoSetting *sis = &sett_info_settings[meta_type]; + const NMMetaSettingInfo *msi = &nm_meta_setting_infos[meta_type]; gs_unref_hashtable GHashTable *h_properties = NULL; GType gtype; - gs_unref_object NMSetting *setting = NULL; - guint prop_idx; - gs_free GParamSpec **property_specs = NULL; - guint n_property_specs; - guint n_param_spec; - guint i; - guint j; + gs_unref_object NMSetting *setting = NULL; + guint prop_idx; + gs_free GParamSpec **property_specs = NULL; + guint n_property_specs; + guint n_param_spec; + guint i; + guint j; g_assert(sis); @@ -4427,9 +4427,11 @@ test_setting_metadata(void) for (prop_idx = 0; prop_idx < sis->property_infos_len; prop_idx++) { const NMSettInfoProperty *sip = &sis->property_infos[prop_idx]; - GArray * property_types_data; + GArray *property_types_data; guint prop_idx_val; gboolean can_set_including_default = FALSE; + gboolean can_have_direct_hook = FALSE; + int n_special_options; g_assert(sip->name); @@ -4490,6 +4492,22 @@ test_setting_metadata(void) g_assert_cmpint(pspec->maximum, <=, (guint64) G_MAXUINT32); can_set_including_default = TRUE; + } else if (sip->property_type->direct_type == NM_VALUE_TYPE_INT64) { + const GParamSpecInt64 *pspec; + + g_assert(sip->property_type == &nm_sett_info_propert_type_direct_int64); + g_assert(g_variant_type_equal(sip->property_type->dbus_type, "x")); + g_assert(sip->property_type->to_dbus_fcn + == _nm_setting_property_to_dbus_fcn_direct); + g_assert(sip->param_spec); + g_assert(sip->param_spec->value_type == G_TYPE_INT64); + + pspec = NM_G_PARAM_SPEC_CAST_INT64(sip->param_spec); + g_assert_cmpint(pspec->minimum, <=, pspec->maximum); + g_assert_cmpint(pspec->default_value, >=, pspec->minimum); + g_assert_cmpint(pspec->default_value, <=, pspec->maximum); + + can_set_including_default = TRUE; } else if (sip->property_type->direct_type == NM_VALUE_TYPE_UINT64) { const GParamSpecUInt64 *pspec; @@ -4555,6 +4573,7 @@ test_setting_metadata(void) g_assert(g_variant_type_equal(sip->property_type->dbus_type, "s")); g_assert(sip->property_type->to_dbus_fcn == _nm_setting_property_to_dbus_fcn_direct); + can_have_direct_hook = TRUE; } g_assert(sip->param_spec); g_assert(sip->param_spec->value_type == G_TYPE_STRING); @@ -4569,6 +4588,13 @@ test_setting_metadata(void) if (sip->direct_set_string_ascii_strdown) g_assert(sip->property_type->direct_type == NM_VALUE_TYPE_STRING); + if (sip->direct_set_string_strip) + g_assert(sip->property_type->direct_type == NM_VALUE_TYPE_STRING); + if (sip->direct_string_is_refstr) { + g_assert(sip->property_type->direct_type == NM_VALUE_TYPE_STRING); + g_assert(sip->param_spec); + g_assert(!NM_FLAGS_HAS(sip->param_spec->flags, NM_SETTING_PARAM_SECRET)); + } if (sip->direct_set_string_mac_address_len != 0) { g_assert(NM_IN_SET(sip->property_type, @@ -4577,10 +4603,38 @@ test_setting_metadata(void) g_assert(sip->property_type->direct_type == NM_VALUE_TYPE_STRING); } - g_assert(((sip->direct_set_string_mac_address_len != 0) - + (!!sip->direct_set_string_ascii_strdown) - + (sip->direct_set_string_ip_address_addr_family != 0)) - <= 1); + if (!can_have_direct_hook) + g_assert(!sip->direct_hook.set_string_fcn); + + n_special_options = (sip->direct_set_string_mac_address_len != 0) + + (!!sip->direct_set_string_strip) + + (!!sip->direct_set_string_ascii_strdown) + + (sip->direct_set_string_ip_address_addr_family != 0) + + (!!sip->direct_string_is_refstr); + + G_STATIC_ASSERT_EXPR(AF_UNSPEC + 1 != 0); + g_assert(NM_IN_SET((int) sip->direct_set_string_ip_address_addr_family, + 0, + AF_UNSPEC + 1, + AF_INET + 1, + AF_INET6 + 1)); + + if (sip->direct_set_string_ip_address_addr_family == 0) + g_assert(!sip->direct_set_string_ip_address_addr_family_map_zero_to_null); + + /* currently, we have no cases where special options are mixed. There is no problem to support + * that, but as it's not needed, don't do it for now. */ + g_assert_cmpint(n_special_options, <=, 1); + + if (n_special_options > 0) { + /* currently, special options are only relevant for string properties. */ + g_assert(sip->property_type->direct_type == NM_VALUE_TYPE_STRING); + } + + if (sip->param_spec && NM_FLAGS_HAS(sip->param_spec->flags, NM_SETTING_PARAM_SECRET)) { + /* Currently, special options are not supported for secrets. */ + g_assert_cmpint(n_special_options, ==, 0); + } if (!sip->property_type->to_dbus_fcn) { /* it's allowed to have no to_dbus_fcn(), to ignore a property. But such @@ -4589,12 +4643,6 @@ test_setting_metadata(void) } else if (sip->property_type->to_dbus_fcn == _nm_setting_property_to_dbus_fcn_gprop) { g_assert(sip->param_spec); switch (sip->property_type->typdata_to_dbus.gprop_type) { - case NM_SETTING_PROPERTY_TO_DBUS_FCN_GPROP_TYPE_ENUM: - g_assert(g_type_is_a(sip->param_spec->value_type, G_TYPE_ENUM)); - goto check_done; - case NM_SETTING_PROPERTY_TO_DBUS_FCN_GPROP_TYPE_FLAGS: - g_assert(g_type_is_a(sip->param_spec->value_type, G_TYPE_FLAGS)); - goto check_done; case NM_SETTING_PROPERTY_TO_DBUS_FCN_GPROP_TYPE_GARRAY_UINT: g_assert(sip->param_spec->value_type == G_TYPE_ARRAY); goto check_done; @@ -4709,9 +4757,10 @@ check_done:; NULL); g_assert(!NM_G_PARAM_SPEC_GET_DEFAULT_STRING(sip->param_spec)); - if (nm_streq(sip->name, NM_SETTING_NAME)) + if (nm_streq(sip->name, NM_SETTING_NAME)) { g_assert_cmpstr(g_value_get_string(&val), ==, msi->setting_name); - else + g_assert(sip->property_type == &nm_sett_info_propert_type_setting_name); + } else g_assert_cmpstr(g_value_get_string(&val), ==, NULL); } @@ -4856,23 +4905,6 @@ check_done:; != 0) continue; - if ((pt == &nm_sett_info_propert_type_plain_i - && pt_2 == &nm_sett_info_propert_type_deprecated_ignore_i) - || (pt_2 == &nm_sett_info_propert_type_plain_i - && pt == &nm_sett_info_propert_type_deprecated_ignore_i) - || (pt == &nm_sett_info_propert_type_plain_u - && pt_2 == &nm_sett_info_propert_type_deprecated_ignore_u) - || (pt_2 == &nm_sett_info_propert_type_plain_u - && pt == &nm_sett_info_propert_type_deprecated_ignore_u)) { - /* These are known to be duplicated. This is the case for - * "gsm.network-type" and plain properties like "802-11-wireless-security.fils" ("i" D-Bus type) - * "gsm.allowed-bands" and plain properties like "802-11-olpc-mesh.channel" ("u" D-Bus type) - * While the content/behaviour of the property types are identical, their purpose - * is different. So allow them. - */ - continue; - } - /* the property-types with same content should all be shared. Here we have two that * are the same content, but different instances. Bug. */ g_error("The identical property type for D-Bus type \"%s\" is used by: %s and %s. " @@ -4892,7 +4924,7 @@ static void test_setting_connection_secondaries_verify(void) { gs_unref_object NMConnection *con = NULL; - NMSettingConnection * s_con; + NMSettingConnection *s_con; guint i_run; guint i_word; @@ -4900,7 +4932,7 @@ test_setting_connection_secondaries_verify(void) nmtst_connection_normalize(con); for (i_run = 0; i_run < 100; i_run++) { - guint word_len = nmtst_get_rand_word_length(NULL); + guint word_len = nmtst_get_rand_word_length(NULL); gs_unref_ptrarray GPtrArray *arr = NULL; gs_unref_ptrarray GPtrArray *arr_norm = NULL; gboolean was_normalized; @@ -4930,10 +4962,10 @@ test_setting_connection_secondaries_verify(void) G_STMT_START \ { \ NMSettingConnection *const _s_con = (s_con); \ - const char *const * _expected = (expected); \ - GArray * _secondaries; \ + const char *const *_expected = (expected); \ + GArray *_secondaries; \ const guint _expected_len = NM_PTRARRAY_LEN(_expected); \ - gs_strfreev char ** _sec_strv = NULL; \ + gs_strfreev char **_sec_strv = NULL; \ guint _i; \ \ g_assert(_expected); \ @@ -5011,8 +5043,8 @@ static void test_6lowpan_1(void) { gs_unref_object NMConnection *con = NULL; - NMSetting6Lowpan * s_6low; - gs_free char * value = NULL; + NMSetting6Lowpan *s_6low; + gs_free char *value = NULL; con = nmtst_create_minimal_connection("test-sec", NULL, NM_SETTING_6LOWPAN_SETTING_NAME, NULL); diff --git a/src/libnm-core-impl/tests/test-settings-defaults.c b/src/libnm-core-impl/tests/test-settings-defaults.c index b9db7107..ade28c53 100644 --- a/src/libnm-core-impl/tests/test-settings-defaults.c +++ b/src/libnm-core-impl/tests/test-settings-defaults.c @@ -27,7 +27,7 @@ test_defaults(GType type, const char *name) { GParamSpec **property_specs; guint n_property_specs; - GObject * setting; + GObject *setting; int i; setting = g_object_new(type, NULL); @@ -39,7 +39,7 @@ test_defaults(GType type, const char *name) GParamSpec *prop_spec = property_specs[i]; GValue value = G_VALUE_INIT; GValue defvalue = G_VALUE_INIT; - char * actual, *expected; + char *actual, *expected; gboolean ok = FALSE; /* Ignore non-fundamental types since they won't really have |