diff --git a/src/devices/nm-device-ethernet.c b/src/devices/nm-device-ethernet.c index 5df16df0ea..68080808d5 100644 --- a/src/devices/nm-device-ethernet.c +++ b/src/devices/nm-device-ethernet.c @@ -59,7 +59,7 @@ _LOG_DECLARE_SELF(NMDeviceEthernet); /*****************************************************************************/ -#define WIRED_SECRETS_TRIES "wired-secrets-tries" +static NM_CACHED_QUARK_FCN ("wired-secrets-tries", wired_secret_tries_quark) #define PPPOE_RECONNECT_DELAY 7 #define PPPOE_ENCAP_OVERHEAD 8 /* 2 bytes for PPP, 6 for PPPoE */ @@ -268,7 +268,7 @@ clear_secrets_tries (NMDevice *device) if (req) { connection = nm_act_request_get_applied_connection (req); /* Clear wired secrets tries on success, failure, or when deactivating */ - g_object_set_data (G_OBJECT (connection), WIRED_SECRETS_TRIES, NULL); + g_object_set_qdata (G_OBJECT (connection), wired_secret_tries_quark (), NULL); } } @@ -706,7 +706,7 @@ handle_auth_or_fail (NMDeviceEthernet *self, applied_connection = nm_act_request_get_applied_connection (req); - tries = GPOINTER_TO_UINT (g_object_get_data (G_OBJECT (applied_connection), WIRED_SECRETS_TRIES)); + tries = GPOINTER_TO_UINT (g_object_get_qdata (G_OBJECT (applied_connection), wired_secret_tries_quark ())); if (tries > 3) return NM_ACT_STAGE_RETURN_FAILURE; @@ -719,7 +719,7 @@ handle_auth_or_fail (NMDeviceEthernet *self, wired_secrets_get_secrets (self, setting_name, NM_SECRET_AGENT_GET_SECRETS_FLAG_ALLOW_INTERACTION | (new_secrets ? NM_SECRET_AGENT_GET_SECRETS_FLAG_REQUEST_NEW : 0)); - g_object_set_data (G_OBJECT (applied_connection), WIRED_SECRETS_TRIES, GUINT_TO_POINTER (++tries)); + g_object_set_qdata (G_OBJECT (applied_connection), wired_secret_tries_quark (), GUINT_TO_POINTER (++tries)); } else _LOGI (LOGD_DEVICE, "Cleared secrets, but setting didn't need any secrets."); diff --git a/src/devices/nm-device-factory.c b/src/devices/nm-device-factory.c index 0ce2cb48c5..dbe68048a9 100644 --- a/src/devices/nm-device-factory.c +++ b/src/devices/nm-device-factory.c @@ -32,7 +32,8 @@ #include "nm-utils.h" #define PLUGIN_PREFIX "libnm-device-plugin-" -#define PLUGIN_PATH_TAG "NMManager-plugin-path" + +static NM_CACHED_QUARK_FCN ("NMManager-plugin-path", plugin_path_quark) /*****************************************************************************/ @@ -350,13 +351,13 @@ _add_factory (NMDeviceFactory *factory, if (found) { nm_log_warn (LOGD_PLATFORM, "Loading device plugin failed: multiple plugins " "for same type (using '%s' instead of '%s')", - (char *) g_object_get_data (G_OBJECT (found), PLUGIN_PATH_TAG), + (char *) g_object_get_qdata (G_OBJECT (found), plugin_path_quark ()), path); return FALSE; } } - g_object_set_data_full (G_OBJECT (factory), PLUGIN_PATH_TAG, g_strdup (path), g_free); + g_object_set_qdata_full (G_OBJECT (factory), plugin_path_quark (), g_strdup (path), g_free); for (i = 0; link_types && link_types[i] > NM_LINK_TYPE_UNKNOWN; i++) g_hash_table_insert (factories_by_link, GUINT_TO_POINTER (link_types[i]), g_object_ref (factory)); for (i = 0; setting_types && setting_types[i]; i++) diff --git a/src/devices/nm-device-macsec.c b/src/devices/nm-device-macsec.c index c511a0e721..33cdb0160f 100644 --- a/src/devices/nm-device-macsec.c +++ b/src/devices/nm-device-macsec.c @@ -90,7 +90,7 @@ G_DEFINE_TYPE (NMDeviceMacsec, nm_device_macsec, NM_TYPE_DEVICE) /******************************************************************/ -#define MACSEC_SECRETS_TRIES "macsec-secrets-tries" +static NM_CACHED_QUARK_FCN ("macsec-secrets-tries", macsec_secrets_tries_quark) static void macsec_secrets_cancel (NMDeviceMacsec *self); @@ -505,7 +505,7 @@ handle_auth_or_fail (NMDeviceMacsec *self, applied_connection = nm_act_request_get_applied_connection (req); - tries = GPOINTER_TO_UINT (g_object_get_data (G_OBJECT (applied_connection), MACSEC_SECRETS_TRIES)); + tries = GPOINTER_TO_UINT (g_object_get_qdata (G_OBJECT (applied_connection), macsec_secrets_tries_quark ())); if (tries > 3) return NM_ACT_STAGE_RETURN_FAILURE; @@ -518,7 +518,7 @@ handle_auth_or_fail (NMDeviceMacsec *self, macsec_secrets_get_secrets (self, setting_name, NM_SECRET_AGENT_GET_SECRETS_FLAG_ALLOW_INTERACTION | (new_secrets ? NM_SECRET_AGENT_GET_SECRETS_FLAG_REQUEST_NEW : 0)); - g_object_set_data (G_OBJECT (applied_connection), MACSEC_SECRETS_TRIES, GUINT_TO_POINTER (++tries)); + g_object_set_qdata (G_OBJECT (applied_connection), macsec_secrets_tries_quark (), GUINT_TO_POINTER (++tries)); } else _LOGI (LOGD_DEVICE, "Cleared secrets, but setting didn't need any secrets."); @@ -768,7 +768,7 @@ clear_secrets_tries (NMDevice *device) if (req) { connection = nm_act_request_get_applied_connection (req); /* Clear macsec secrets tries on success, failure, or when deactivating */ - g_object_set_data (G_OBJECT (connection), MACSEC_SECRETS_TRIES, NULL); + g_object_set_qdata (G_OBJECT (connection), macsec_secrets_tries_quark (), NULL); } } diff --git a/src/devices/nm-device.c b/src/devices/nm-device.c index 68a9e79e40..f2c41e1c0e 100644 --- a/src/devices/nm-device.c +++ b/src/devices/nm-device.c @@ -5517,7 +5517,7 @@ shared4_new_config (NMDevice *self, NMConnection *connection, NMDeviceStateReaso nm_ip4_config_add_address (config, &address); /* Remove the address lock when the object gets disposed */ - g_object_set_data_full (G_OBJECT (config), "shared-ip", + g_object_set_qdata_full (G_OBJECT (config), NM_CACHED_QUARK ("shared-ip"), GUINT_TO_POINTER (address.address), release_shared_ip); diff --git a/src/devices/wifi/nm-device-wifi.c b/src/devices/wifi/nm-device-wifi.c index ed5d2c6252..81df1add1e 100644 --- a/src/devices/wifi/nm-device-wifi.c +++ b/src/devices/wifi/nm-device-wifi.c @@ -63,7 +63,7 @@ _LOG_DECLARE_SELF(NMDeviceWifi); #define SCAN_RAND_MAC_ADDRESS_EXPIRE_MIN 5 -#define WIRELESS_SECRETS_TRIES "wireless-secrets-tries" +static NM_CACHED_QUARK_FCN ("wireless-secrets-tries", wireless_secrets_tries_quark) /*****************************************************************************/ @@ -2255,7 +2255,7 @@ handle_auth_or_fail (NMDeviceWifi *self, applied_connection = nm_act_request_get_applied_connection (req); - tries = GPOINTER_TO_UINT (g_object_get_data (G_OBJECT (applied_connection), WIRELESS_SECRETS_TRIES)); + tries = GPOINTER_TO_UINT (g_object_get_qdata (G_OBJECT (applied_connection), wireless_secrets_tries_quark ())); if (tries > 3) return NM_ACT_STAGE_RETURN_FAILURE; @@ -2267,7 +2267,7 @@ handle_auth_or_fail (NMDeviceWifi *self, wifi_secrets_get_secrets (self, setting_name, NM_SECRET_AGENT_GET_SECRETS_FLAG_ALLOW_INTERACTION | (new_secrets ? NM_SECRET_AGENT_GET_SECRETS_FLAG_REQUEST_NEW : 0)); - g_object_set_data (G_OBJECT (applied_connection), WIRELESS_SECRETS_TRIES, GUINT_TO_POINTER (++tries)); + g_object_set_qdata (G_OBJECT (applied_connection), wireless_secrets_tries_quark (), GUINT_TO_POINTER (++tries)); ret = NM_ACT_STAGE_RETURN_POSTPONE; } else _LOGW (LOGD_DEVICE, "Cleared secrets, but setting didn't need any secrets."); @@ -2895,7 +2895,7 @@ activation_success_handler (NMDevice *device) nm_platform_wifi_indicate_addressing_running (NM_PLATFORM_GET, ifindex, FALSE); /* Clear wireless secrets tries on success */ - g_object_set_data (G_OBJECT (applied_connection), WIRELESS_SECRETS_TRIES, NULL); + g_object_set_qdata (G_OBJECT (applied_connection), wireless_secrets_tries_quark (), NULL); /* There should always be a current AP, either a fake one because we haven't * seen a scan result for the activated AP yet, or a real one from the @@ -2946,7 +2946,7 @@ activation_failure_handler (NMDevice *device) g_assert (applied_connection); /* Clear wireless secrets tries on failure */ - g_object_set_data (G_OBJECT (applied_connection), WIRELESS_SECRETS_TRIES, NULL); + g_object_set_qdata (G_OBJECT (applied_connection), wireless_secrets_tries_quark (), NULL); /* Clear any critical protocol notification in the wifi stack */ nm_platform_wifi_indicate_addressing_running (NM_PLATFORM_GET, nm_device_get_ifindex (device), FALSE); diff --git a/src/nm-manager.c b/src/nm-manager.c index 7dfaa5abf8..569721c69a 100644 --- a/src/nm-manager.c +++ b/src/nm-manager.c @@ -86,7 +86,7 @@ static void device_sleep_cb (NMDevice *device, GParamSpec *pspec, NMManager *self); -#define TAG_ACTIVE_CONNETION_ADD_AND_ACTIVATE "act-con-add-and-activate" +static NM_CACHED_QUARK_FCN ("active-connection-add-and-activate", active_connection_add_and_activate_quark) typedef struct { gboolean user_enabled; @@ -3739,8 +3739,8 @@ _add_and_activate_auth_done (NMActiveConnection *active, if (success) { NMConnection *connection; - connection = g_object_steal_data (G_OBJECT (active), - TAG_ACTIVE_CONNETION_ADD_AND_ACTIVATE); + connection = g_object_steal_qdata (G_OBJECT (active), + active_connection_add_and_activate_quark ()); info = g_slice_new (AddAndActivateInfo); info->manager = self; @@ -3855,10 +3855,10 @@ impl_manager_add_and_activate_connection (NMManager *self, if (!active) goto error; - g_object_set_data_full (G_OBJECT (active), - TAG_ACTIVE_CONNETION_ADD_AND_ACTIVATE, - connection, - g_object_unref); + g_object_set_qdata_full (G_OBJECT (active), + active_connection_add_and_activate_quark (), + connection, + g_object_unref); nm_active_connection_authorize (active, connection, _add_and_activate_auth_done, self, context); g_object_unref (subject); diff --git a/src/ppp/nm-ppp-manager.c b/src/ppp/nm-ppp-manager.c index 1bbe29d46b..bb7821e97b 100644 --- a/src/ppp/nm-ppp-manager.c +++ b/src/ppp/nm-ppp-manager.c @@ -57,7 +57,8 @@ #include "introspection/org.freedesktop.NetworkManager.PPP.h" #define NM_PPPD_PLUGIN PPPD_PLUGIN_DIR "/nm-pppd-plugin.so" -#define PPP_MANAGER_SECRET_TRIES "ppp-manager-secret-tries" + +static NM_CACHED_QUARK_FCN ("ppp-manager-secret-tries", ppp_manager_secret_tries_quark) /*****************************************************************************/ @@ -341,7 +342,7 @@ impl_ppp_manager_need_secrets (NMPPPManager *manager, * appear to ask a few times when they actually don't even care what you * pass back. */ - tries = GPOINTER_TO_UINT (g_object_get_data (G_OBJECT (applied_connection), PPP_MANAGER_SECRET_TRIES)); + tries = GPOINTER_TO_UINT (g_object_get_qdata (G_OBJECT (applied_connection), ppp_manager_secret_tries_quark())); if (tries > 1) flags |= NM_SECRET_AGENT_GET_SECRETS_FLAG_REQUEST_NEW; @@ -352,7 +353,7 @@ impl_ppp_manager_need_secrets (NMPPPManager *manager, hints ? g_ptr_array_index (hints, 0) : NULL, ppp_secrets_cb, manager); - g_object_set_data (G_OBJECT (applied_connection), PPP_MANAGER_SECRET_TRIES, GUINT_TO_POINTER (++tries)); + g_object_set_qdata (G_OBJECT (applied_connection), ppp_manager_secret_tries_quark (), GUINT_TO_POINTER (++tries)); priv->pending_secrets_context = context; if (hints) @@ -389,7 +390,7 @@ set_ip_config_common (NMPPPManager *self, /* Got successful IP config; obviously the secrets worked */ applied_connection = nm_act_request_get_applied_connection (priv->act_req); - g_object_set_data (G_OBJECT (applied_connection), PPP_MANAGER_SECRET_TRIES, NULL); + g_object_set_qdata (G_OBJECT (applied_connection), ppp_manager_secret_tries_quark (), NULL); if (out_mtu) { /* Get any custom MTU */ diff --git a/src/settings/nm-settings.c b/src/settings/nm-settings.c index ca38102480..50b3b77222 100644 --- a/src/settings/nm-settings.c +++ b/src/settings/nm-settings.c @@ -104,7 +104,7 @@ EXPORT(nm_settings_connection_replace_and_commit) #define IFCFG_DIR SYSCONFDIR "/sysconfig/network" #define CONF_DHCP IFCFG_DIR "/dhcp" -#define PLUGIN_MODULE_PATH "plugin-module-path" +static NM_CACHED_QUARK_FCN ("plugin-module-path", plugin_module_path_quark) #if (defined(HOSTNAME_PERSIST_SUSE) + defined(HOSTNAME_PERSIST_SLACKWARE) + defined(HOSTNAME_PERSIST_GENTOO)) > 1 #error "Can only define one of HOSTNAME_PERSIST_*" @@ -120,6 +120,9 @@ EXPORT(nm_settings_connection_replace_and_commit) #define HOSTNAME_FILE HOSTNAME_FILE_DEFAULT #endif +static NM_CACHED_QUARK_FCN ("default-wired-connection", _default_wired_connection_quark) +static NM_CACHED_QUARK_FCN ("default-wired-device", _default_wired_device_quark) + /*****************************************************************************/ NM_GOBJECT_PROPERTIES_DEFINE (NMSettings, @@ -753,7 +756,7 @@ add_plugin (NMSettings *self, NMSettingsPlugin *plugin) NM_SETTINGS_PLUGIN_INFO, &pinfo, NULL); - path = g_object_get_data (G_OBJECT (plugin), PLUGIN_MODULE_PATH); + path = g_object_get_qdata (G_OBJECT (plugin), plugin_module_path_quark ()); _LOGI ("loaded plugin %s: %s%s%s%s", pname, pinfo, NM_PRINT_FMT_QUOTED (path, " (", path, ")", "")); @@ -916,7 +919,7 @@ load_plugin: break; } - g_object_set_data_full (obj, PLUGIN_MODULE_PATH, path, g_free); + g_object_set_qdata_full (obj, plugin_module_path_quark (), path, g_free); path = NULL; if (add_plugin (self, NM_SETTINGS_PLUGIN (obj))) list = g_slist_append (list, obj); @@ -1935,9 +1938,6 @@ have_connection_for_device (NMSettings *self, NMDevice *device) return FALSE; } -#define DEFAULT_WIRED_CONNECTION_TAG "default-wired-connection" -#define DEFAULT_WIRED_DEVICE_TAG "default-wired-device" - static void default_wired_clear_tag (NMSettings *self, NMDevice *device, NMSettingsConnection *connection, @@ -1953,7 +1953,7 @@ default_wired_connection_removed_cb (NMSettingsConnection *connection, NMSetting * wired device to the config file and don't create a new default wired * connection for that device again. */ - device = g_object_get_data (G_OBJECT (connection), DEFAULT_WIRED_DEVICE_TAG); + device = g_object_get_qdata (G_OBJECT (connection), _default_wired_device_quark ()); if (device) default_wired_clear_tag (self, device, connection, TRUE); } @@ -1970,7 +1970,7 @@ default_wired_connection_updated_by_user_cb (NMSettingsConnection *connection, g * considered a default wired connection, and should no longer affect * the no-auto-default configuration option. */ - device = g_object_get_data (G_OBJECT (connection), DEFAULT_WIRED_DEVICE_TAG); + device = g_object_get_qdata (G_OBJECT (connection), _default_wired_device_quark ()); if (device) default_wired_clear_tag (self, device, connection, FALSE); } @@ -1984,11 +1984,11 @@ default_wired_clear_tag (NMSettings *self, g_return_if_fail (NM_IS_SETTINGS (self)); g_return_if_fail (NM_IS_DEVICE (device)); g_return_if_fail (NM_IS_CONNECTION (connection)); - g_return_if_fail (device == g_object_get_data (G_OBJECT (connection), DEFAULT_WIRED_DEVICE_TAG)); - g_return_if_fail (connection == g_object_get_data (G_OBJECT (device), DEFAULT_WIRED_CONNECTION_TAG)); + g_return_if_fail (device == g_object_get_qdata (G_OBJECT (connection), _default_wired_device_quark ())); + g_return_if_fail (connection == g_object_get_qdata (G_OBJECT (device), _default_wired_connection_quark ())); - g_object_set_data (G_OBJECT (connection), DEFAULT_WIRED_DEVICE_TAG, NULL); - g_object_set_data (G_OBJECT (device), DEFAULT_WIRED_CONNECTION_TAG, NULL); + g_object_set_qdata (G_OBJECT (connection), _default_wired_device_quark (), NULL); + g_object_set_qdata (G_OBJECT (device), _default_wired_connection_quark (), NULL); g_signal_handlers_disconnect_by_func (connection, G_CALLBACK (default_wired_connection_removed_cb), self); g_signal_handlers_disconnect_by_func (connection, G_CALLBACK (default_wired_connection_updated_by_user_cb), self); @@ -2015,7 +2015,7 @@ device_realized (NMDevice *device, GParamSpec *pspec, NMSettings *self) * ignore it. */ if ( !nm_device_get_managed (device, FALSE) - || g_object_get_data (G_OBJECT (device), DEFAULT_WIRED_CONNECTION_TAG) + || g_object_get_qdata (G_OBJECT (device), _default_wired_connection_quark ()) || have_connection_for_device (self, device)) return; @@ -2037,8 +2037,8 @@ device_realized (NMDevice *device, GParamSpec *pspec, NMSettings *self) return; } - g_object_set_data (G_OBJECT (added), DEFAULT_WIRED_DEVICE_TAG, device); - g_object_set_data (G_OBJECT (device), DEFAULT_WIRED_CONNECTION_TAG, added); + g_object_set_qdata (G_OBJECT (added), _default_wired_device_quark (), device); + g_object_set_qdata (G_OBJECT (device), _default_wired_connection_quark (), added); g_signal_connect (added, NM_SETTINGS_CONNECTION_UPDATED_INTERNAL, G_CALLBACK (default_wired_connection_updated_by_user_cb), self); @@ -2071,7 +2071,7 @@ nm_settings_device_removed (NMSettings *self, NMDevice *device, gboolean quittin G_CALLBACK (device_realized), self); - connection = g_object_get_data (G_OBJECT (device), DEFAULT_WIRED_CONNECTION_TAG); + connection = g_object_get_qdata (G_OBJECT (device), _default_wired_connection_quark ()); if (connection) { default_wired_clear_tag (self, device, connection, FALSE); diff --git a/src/supplicant/nm-supplicant-interface.c b/src/supplicant/nm-supplicant-interface.c index c913a6960c..70f05e1c9f 100644 --- a/src/supplicant/nm-supplicant-interface.c +++ b/src/supplicant/nm-supplicant-interface.c @@ -37,6 +37,8 @@ #define WPAS_ERROR_INVALID_IFACE WPAS_DBUS_INTERFACE ".InvalidInterface" #define WPAS_ERROR_EXISTS_ERROR WPAS_DBUS_INTERFACE ".InterfaceExists" +static NM_CACHED_QUARK_FCN ("bss-proxy-inited", bss_proxy_inited_quark) + /*****************************************************************************/ enum { @@ -177,8 +179,6 @@ _get_bss_proxy_properties (NMSupplicantInterface *self, GDBusProxy *proxy) return g_variant_builder_end (&builder); } -#define BSS_PROXY_INITED "bss-proxy-inited" - static void on_bss_proxy_acquired (GDBusProxy *proxy, GAsyncResult *result, gpointer user_data) { @@ -201,7 +201,7 @@ on_bss_proxy_acquired (GDBusProxy *proxy, GAsyncResult *result, gpointer user_da if (!props) return; - g_object_set_data (G_OBJECT (proxy), BSS_PROXY_INITED, GUINT_TO_POINTER (TRUE)); + g_object_set_qdata (G_OBJECT (proxy), bss_proxy_inited_quark (), GUINT_TO_POINTER (TRUE)); g_signal_emit (self, signals[NEW_BSS], 0, g_dbus_proxy_get_object_path (proxy), @@ -567,7 +567,7 @@ wpas_iface_scan_done (GDBusProxy *proxy, /* Emit NEW_BSS so that wifi device has the APs (in case it removed them) */ g_hash_table_iter_init (&iter, priv->bss_proxies); while (g_hash_table_iter_next (&iter, (gpointer) &bss_path, (gpointer) &bss_proxy)) { - if (g_object_get_data (G_OBJECT (bss_proxy), BSS_PROXY_INITED)) { + if (g_object_get_qdata (G_OBJECT (bss_proxy), bss_proxy_inited_quark ())) { props = _get_bss_proxy_properties (self, bss_proxy); if (props) { g_signal_emit (self, signals[NEW_BSS], 0,