diff options
author | Simon McVittie <simon.mcvittie@collabora.co.uk> | 2014-04-11 15:18:27 +0100 |
---|---|---|
committer | Simon McVittie <simon.mcvittie@collabora.co.uk> | 2014-04-17 14:22:29 +0100 |
commit | 0b57d9e66ca25a5e6684751a23a88b91e719e3c6 (patch) | |
tree | 4eee38a8fece29ca5ca5e73d33ffaa555ddca566 /telepathy-glib | |
parent | 95bab7fbb0eb9769f7c81daa90147d55d3ff189d (diff) |
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.
Diffstat (limited to 'telepathy-glib')
-rw-r--r-- | telepathy-glib/base-connection.c | 8 |
1 files changed, 8 insertions, 0 deletions
diff --git a/telepathy-glib/base-connection.c b/telepathy-glib/base-connection.c index f7a13e952..9a5b24431 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); |