[next] telepathy-glib: TpBaseConnection: add a static assertion that guint is guint32
Simon McVittie
smcv at kemper.freedesktop.org
Wed May 7 02:18:23 PDT 2014
Module: telepathy-glib
Branch: next
Commit: 30c0885320258d375468d1b7391f375e6bf6ce99
URL: http://cgit.freedesktop.org/telepathy/telepathy-glib/commit/?id=30c0885320258d375468d1b7391f375e6bf6ce99
Author: Simon McVittie <simon.mcvittie at collabora.co.uk>
Date: Fri Apr 11 15:18:27 2014 +0100
TpBaseConnection: add a static assertion that guint is guint32
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.
Reviewed-by: Xavier Claessens <xavier.claessens at collabora.com>
Bug: https://bugs.freedesktop.org/show_bug.cgi?id=77189
---
telepathy-glib/base-connection.c | 8 ++++++++
1 file changed, 8 insertions(+)
diff --git a/telepathy-glib/base-connection.c b/telepathy-glib/base-connection.c
index f7a13e9..9a5b244 100644
--- a/telepathy-glib/base-connection.c
+++ b/telepathy-glib/base-connection.c
@@ -2961,6 +2961,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);
More information about the telepathy-commits
mailing list