diff options
author | Philip Withnall <philip.withnall@collabora.co.uk> | 2014-06-30 00:08:08 +0100 |
---|---|---|
committer | Philip Withnall <philip.withnall@collabora.co.uk> | 2014-06-30 00:08:08 +0100 |
commit | c62ff61add96909e6af28d105b6e6d2d9a4dbee0 (patch) | |
tree | d30de66df81b7c4852c0ce94ff72607ebd9cbff6 /tests | |
parent | 234ba46cd95026e763d6a8d7c19cd561c0520ee6 (diff) |
gvariant: Check for use of architecture-dependent types
If the user passes an architecture-dependent type into a GVariant
variadic function, the behaviour will differ between architectures,
which we really do not want — essentially the code would be using the
wrong width integer on one architecture but not another, which would be
hard to track down. This is mostly a problem with ‘long’, which is 32
bits wide on 32-bit systems, and 64 bits wide on 64-bit systems.
This was a problem encountered in the wild in telepathy-gabble. Thanks
to Simon McVittie for suggesting that Tartan check for it.
Diffstat (limited to 'tests')
-rw-r--r-- | tests/gvariant-get.c | 40 |
1 files changed, 40 insertions, 0 deletions
diff --git a/tests/gvariant-get.c b/tests/gvariant-get.c index 0f0d965..2a8d1a2 100644 --- a/tests/gvariant-get.c +++ b/tests/gvariant-get.c @@ -510,3 +510,43 @@ va_list some_va_list; g_variant_get_va (existing_variant, "invalid", NULL, &some_va_list); } + +/* + * Expected a GVariant variadic argument of type 'gint64 *' (aka 'long *') but saw one of type 'glong *' (aka 'long *'). These types are not compatible on every architecture. + * g_variant_get (existing_variant, "x", &some_long); + * ^ + */ +{ + glong some_long; + g_variant_get (existing_variant, "x", &some_long); +} + +/* + * Expected a GVariant variadic argument of type 'gint64 *' (aka 'long *') but saw one of type 'long *'. These types are not compatible on every architecture. + * g_variant_get (existing_variant, "x", &some_long); + * ^ + */ +{ + long some_long; + g_variant_get (existing_variant, "x", &some_long); +} + +/* + * Expected a GVariant variadic argument of type 'guint64 *' (aka 'unsigned long *') but saw one of type 'gulong *' (aka 'unsigned long *'). These types are not compatible on every architecture. + * g_variant_get (existing_variant, "t", &some_long); + * ^ + */ +{ + gulong some_long; + g_variant_get (existing_variant, "t", &some_long); +} + +/* + * Expected a GVariant variadic argument of type 'gint32 *' (aka 'int *') but saw one of type 'glong *' (aka 'long *'). These types are not compatible on every architecture. + * g_variant_get (existing_variant, "i", &some_long); + * ^ + */ +{ + glong some_long; + g_variant_get (existing_variant, "i", &some_long); +} |