[Pkg-telepathy-commits] [telepathy-glib-1] 199/212: Use #define'd constants for interface-added, interface-removed signals
Simon McVittie
smcv at debian.org
Wed May 14 12:09:15 UTC 2014
This is an automated email from the git hooks/post-receive script.
smcv pushed a commit to branch debian
in repository telepathy-glib-1.
commit 2941ce2adbc9cc3970328a751f0451f49f32e647
Author: Simon McVittie <simon.mcvittie at collabora.co.uk>
Date: Tue Apr 22 11:29:14 2014 +0100
Use #define'd constants for interface-added, interface-removed signals
Xavier suggested that an enum would be clearer than +1 and -1. However,
since these constants are only ever used in a pointer-typed parameter,
it seems clearer still to #define their GINT_TO_POINTER form.
I deliberately avoided 0 because casting a literal 0 to a pointer type
is special (it produces a null pointer constant, which in theory is
not necessarily all-bits-zero, although in practice any reasonable
architecture uses all-bits-zero to avoid breaking people's assumptions
about calloc()).
Reviewed-by: Xavier Claessens <xavier.claessens at collabora.com>
Bug: https://bugs.freedesktop.org/show_bug.cgi?id=77189
---
telepathy-glib/base-connection.c | 14 +++++++++-----
1 file changed, 9 insertions(+), 5 deletions(-)
diff --git a/telepathy-glib/base-connection.c b/telepathy-glib/base-connection.c
index 4fc1f13..76cd50f 100644
--- a/telepathy-glib/base-connection.c
+++ b/telepathy-glib/base-connection.c
@@ -643,16 +643,20 @@ _tp_base_connection_set_handle_repo (TpBaseConnection *self,
self->priv->handles[entity_type] = g_object_ref (handle_repo);
}
+/* User data for interface-added and interface-removed signals, with vaguely
+ * mnemonic values */
+#define INTERFACE_ADDED (GINT_TO_POINTER(1))
+#define INTERFACE_REMOVED (GINT_TO_POINTER(-1))
+
static void
tp_base_connection_interface_changed_cb (TpBaseConnection *self,
GDBusInterface *interface,
gpointer user_data)
{
GDBusInterfaceInfo *info = g_dbus_interface_get_info (interface);
- gint what_happened = GPOINTER_TO_INT (user_data);
- const gchar *verb = (what_happened == 1 ? "add" : "remove");
+ const gchar *verb = (user_data == INTERFACE_ADDED ? "add" : "remove");
- g_assert (what_happened == 1 || what_happened == -1);
+ g_assert (user_data == INTERFACE_ADDED || user_data == INTERFACE_REMOVED);
if (self->priv->status == TP_CONNECTION_STATUS_CONNECTED)
{
@@ -763,10 +767,10 @@ tp_base_connection_constructed (GObject *object)
g_signal_connect (self, "interface-added",
G_CALLBACK (tp_base_connection_interface_changed_cb),
- GINT_TO_POINTER (+1));
+ INTERFACE_ADDED);
g_signal_connect (self, "interface-removed",
G_CALLBACK (tp_base_connection_interface_changed_cb),
- GINT_TO_POINTER (-1));
+ INTERFACE_REMOVED);
/* We don't have any interfaces yet (except for Connection and Requests)
* so it's OK that the default for _TpGDBusConnection:interfaces is NULL. */
--
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/pkg-telepathy/telepathy-glib-1.git
More information about the Pkg-telepathy-commits
mailing list