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-05-07 09:43:43 +0100 |
commit | 30c0885320258d375468d1b7391f375e6bf6ce99 (patch) | |
tree | 4eee38a8fece29ca5ca5e73d33ffaa555ddca566 | |
parent | 5f3d83fba63f853efd63a5c6630abb3316696f52 (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.
Reviewed-by: Xavier Claessens <xavier.claessens@collabora.com>
Bug: https://bugs.freedesktop.org/show_bug.cgi?id=77189
-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); |