summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSimon McVittie <simon.mcvittie@collabora.co.uk>2014-04-11 15:18:27 +0100
committerSimon McVittie <simon.mcvittie@collabora.co.uk>2014-04-11 15:18:27 +0100
commit560b6e9959957331b9d8f49d5e008576656abab6 (patch)
treef63636d8bcd20718573ad07737358aedff333e21
parente62ae89937cdc7c1775de91db404031b1f79b2bd (diff)
TpBaseConnection: add a static assertion that guint is guint32gdbus-object2
In principle, this could be false, but in the real world, sizeof(int) is a power of 2, computers with 16-bit int are decades obsolete, and if int was 64-bit or larger, there'd be a problem with int16_t and int32_t ('short' can only be one of those). With this static assertion in place, we could even change TpHandle to be guint32, although there isn't necessarily much point.
-rw-r--r--telepathy-glib/base-connection.c8
1 files changed, 8 insertions, 0 deletions
diff --git a/telepathy-glib/base-connection.c b/telepathy-glib/base-connection.c
index 23bd0095a..6ed5dff41 100644
--- a/telepathy-glib/base-connection.c
+++ b/telepathy-glib/base-connection.c
@@ -2962,6 +2962,14 @@ contacts_get_contact_attributes_impl (_TpGDBusConnection *skeleton,
GHashTable *attributes;
GValue value = G_VALUE_INIT;
GVariant *result;
+ /* In principle C does not guarantee that TpHandle (which is an
+ * unsigned int) is exactly 32 bits. In practice, int is 32-bit on
+ * every relevant platform.
+ *
+ * If this assertion fails, the g_variant_get_fixed_array() call
+ * will fail at runtime too, and we'll have to change the code to copy
+ * handles into @array one at a time. */
+ G_STATIC_ASSERT (sizeof (TpHandle) == sizeof (guint32));
_TP_GDBUS_ERROR_IF_NOT_CONNECTED (conn, context);