diff options
author | Philip Withnall <philip.withnall@collabora.co.uk> | 2014-06-30 00:07:01 +0100 |
---|---|---|
committer | Philip Withnall <philip.withnall@collabora.co.uk> | 2014-06-30 00:07:01 +0100 |
commit | 234ba46cd95026e763d6a8d7c19cd561c0520ee6 (patch) | |
tree | fbf232863b72929c306f2d1a7a4891a796b25d60 | |
parent | 189edcc649c36e4a1c814822678472c4aff934e5 (diff) |
gvariant: Explicitly use fixed-width GLib types in error messages
Otherwise we can end up with error messages which recommend using a C
standard ‘long’, whose width varies between architectures. Using that is
a bad idea.
-rw-r--r-- | clang-plugin/gvariant-checker.cpp | 14 | ||||
-rw-r--r-- | tests/gvariant-get.c | 6 |
2 files changed, 11 insertions, 9 deletions
diff --git a/clang-plugin/gvariant-checker.cpp b/clang-plugin/gvariant-checker.cpp index 41bafa8..a39bf59 100644 --- a/clang-plugin/gvariant-checker.cpp +++ b/clang-plugin/gvariant-checker.cpp @@ -348,23 +348,23 @@ _check_basic_type_string (const gchar **type_str, expected_type = context.UnsignedCharTy; break; case 'n': /* gint16 */ - expected_type = context.getIntTypeForBitwidth (16, true); + expected_type = type_manager.find_type_by_name ("gint16"); break; case 'q': /* guint16 */ - expected_type = context.getIntTypeForBitwidth (16, false); + expected_type = type_manager.find_type_by_name ("guint16"); break; case 'i': case 'h': /* gint32 */ - expected_type = context.getIntTypeForBitwidth (32, true); + expected_type = type_manager.find_type_by_name ("gint32"); break; case 'u': /* guint32 */ - expected_type = context.getIntTypeForBitwidth (32, false); + expected_type = type_manager.find_type_by_name ("guint32"); break; case 'x': /* gint64 */ - expected_type = context.getIntTypeForBitwidth (64, true); + expected_type = type_manager.find_type_by_name ("gint64"); break; case 't': /* guint64 */ - expected_type = context.getIntTypeForBitwidth (64, false); + expected_type = type_manager.find_type_by_name ("guint64"); break; case 'd': /* gdouble ≡ double */ expected_type = context.DoubleTy; @@ -390,6 +390,8 @@ _check_basic_type_string (const gchar **type_str, return false; } + assert (!expected_type.isNull ()); + /* Handle type promotion. Integer types which are smaller than 32 bits * (for all architectures we care about) are automatically promoted to * 32 bits when passed as varargs. diff --git a/tests/gvariant-get.c b/tests/gvariant-get.c index f4f744a..0f0d965 100644 --- a/tests/gvariant-get.c +++ b/tests/gvariant-get.c @@ -36,7 +36,7 @@ } /* - * Expected a GVariant variadic argument of type 'int *' but there wasn’t one. + * Expected a GVariant variadic argument of type 'gint32 *' (aka 'int *') but there wasn’t one. * g_variant_get (existing_variant, "invalid"); * ^ */ @@ -466,7 +466,7 @@ } /* - * Expected a GVariant variadic argument of type 'long *' but saw one of type 'gint32 *' (aka 'int *'). + * Expected a GVariant variadic argument of type 'gint64 *' (aka 'long *') but saw one of type 'gint32 *' (aka 'int *'). * g_variant_get (existing_variant, "x", &some_int); * ^ */ @@ -484,7 +484,7 @@ } /* - * Expected a GVariant variadic argument of type 'long *' but saw one of type 'guint64 *' (aka 'unsigned long *'). + * Expected a GVariant variadic argument of type 'gint64 *' (aka 'long *') but saw one of type 'guint64 *' (aka 'unsigned long *'). * g_variant_get (existing_variant, "x", &some_uint); * ^ */ |