all: use NM_CACHED_QUARK_FCN() instead of G_DEFINE_QUARK()

I think NM_CACHED_QUARK_FCN() is better because:

- the implementation is in our hand, meaning it is clear that
  putting a "static" before NM_CACHED_QUARK_FCN() is guaranteed to
  work -- without relying on G_DEFINE_QUARK() to be defined in a way
  that this works (in fact, we currently never do that and instead
  make all functions non-static).
- it does not construct function names by appending "_quark".
  Thus you can grep for the entire function name and finding
  the place where it is implemented.
- same with the stings, where the new macro doesn't stringify the
  argument, which is less surpising. Again, now you can grep
  for the string including the double quoting.

(yes, I really use grep to understand the source-code)
This commit is contained in:
Thomas Haller 2017-02-02 21:47:03 +01:00
parent 8538b61eb6
commit 7d6b8bab70
6 changed files with 14 additions and 17 deletions

View file

@ -26,14 +26,14 @@
#include "nm-vpn-dbus-interface.h"
#include "nm-core-internal.h"
G_DEFINE_QUARK (nm-agent-manager-error-quark, nm_agent_manager_error)
G_DEFINE_QUARK (nm-connection-error-quark, nm_connection_error)
G_DEFINE_QUARK (nm-crypto-error-quark, nm_crypto_error)
G_DEFINE_QUARK (nm-device-error-quark, nm_device_error)
G_DEFINE_QUARK (nm-manager-error-quark, nm_manager_error)
G_DEFINE_QUARK (nm-secret-agent-error-quark, nm_secret_agent_error)
G_DEFINE_QUARK (nm-settings-error-quark, nm_settings_error)
G_DEFINE_QUARK (nm-vpn-plugin-error-quark, nm_vpn_plugin_error)
NM_CACHED_QUARK_FCN ("nm-agent-manager-error-quark", nm_agent_manager_error_quark)
NM_CACHED_QUARK_FCN ("nm-connection-error-quark", nm_connection_error_quark)
NM_CACHED_QUARK_FCN ("nm-crypto-error-quark", nm_crypto_error_quark)
NM_CACHED_QUARK_FCN ("nm-device-error-quark", nm_device_error_quark)
NM_CACHED_QUARK_FCN ("nm-manager-error-quark", nm_manager_error_quark)
NM_CACHED_QUARK_FCN ("nm-secret-agent-error-quark", nm_secret_agent_error_quark)
NM_CACHED_QUARK_FCN ("nm-settings-error-quark", nm_settings_error_quark)
NM_CACHED_QUARK_FCN ("nm-vpn-plugin-error-quark", nm_vpn_plugin_error_quark)
static void
register_error_domain (GQuark domain,

View file

@ -37,7 +37,7 @@
static gboolean debug = FALSE;
#define dbgmsg(f,...) if (G_UNLIKELY (debug)) { g_message (f, ## __VA_ARGS__ ); }
G_DEFINE_QUARK (nm-obj-nm, _nm_object_obj_nm);
NM_CACHED_QUARK_FCN ("nm-obj-nm", _nm_object_obj_nm_quark)
static void nm_object_initable_iface_init (GInitableIface *iface);
static void nm_object_async_initable_iface_init (GAsyncInitableIface *iface);

View file

@ -240,7 +240,7 @@ _nm_utils_ascii_str_to_bool (const char *str,
/*****************************************************************************/
G_DEFINE_QUARK (nm-utils-error-quark, nm_utils_error)
NM_CACHED_QUARK_FCN ("nm-utils-error-quark", nm_utils_error_quark)
void
nm_utils_error_set_cancelled (GError **error,

View file

@ -77,8 +77,7 @@ typedef struct {
GArray *methods;
} NMExportedObjectClassInfo;
GQuark nm_exported_object_class_info_quark (void);
G_DEFINE_QUARK (NMExportedObjectClassInfo, nm_exported_object_class_info)
static NM_CACHED_QUARK_FCN ("NMExportedObjectClassInfo", nm_exported_object_class_info_quark)
/*****************************************************************************/
@ -388,8 +387,7 @@ nm_exported_object_meta_marshal (GClosure *closure, GValue *return_value,
g_free (local_param_values);
}
GQuark _skeleton_data_quark (void);
G_DEFINE_QUARK (skeleton-data, _skeleton_data);
static NM_CACHED_QUARK_FCN ("skeleton-data", _skeleton_data_quark)
typedef struct {
GBinding **prop_bindings;

View file

@ -233,8 +233,7 @@ NM_DEFINE_SINGLETON_INSTANCE (NMManager);
/*****************************************************************************/
GQuark autoconnect_root_quark (void);
G_DEFINE_QUARK (autoconnect-root, autoconnect_root);
static NM_CACHED_QUARK_FCN ("autoconnect-root", autoconnect_root_quark)
static void active_connection_state_changed (NMActiveConnection *active,
GParamSpec *pspec,

View file

@ -63,7 +63,7 @@ G_DEFINE_TYPE (NMSupplicantManager, nm_supplicant_manager, G_TYPE_OBJECT)
/*****************************************************************************/
G_DEFINE_QUARK (nm-supplicant-error-quark, nm_supplicant_error);
NM_CACHED_QUARK_FCN ("nm-supplicant-error-quark", nm_supplicant_error_quark)
/*****************************************************************************/