From 234ba46cd95026e763d6a8d7c19cd561c0520ee6 Mon Sep 17 00:00:00 2001 From: Philip Withnall Date: Mon, 30 Jun 2014 00:07:01 +0100 Subject: gvariant: Explicitly use fixed-width GLib types in error messages MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 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. --- clang-plugin/gvariant-checker.cpp | 14 ++++++++------ 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); * ^ */ -- cgit v1.2.3