From 2a2c93e8fccb053a569c2d893bd5ad4fd97053cb Mon Sep 17 00:00:00 2001 From: Simon McVittie Date: Tue, 10 May 2011 11:16:45 +0100 Subject: [PATCH 5/6] marshal_collection_array: statically assert that size conversion is not needed Previously, the function blindly assumed this without a check. --- dbus/dbus-gvalue.c | 10 ++++++++++ 1 files changed, 10 insertions(+), 0 deletions(-) diff --git a/dbus/dbus-gvalue.c b/dbus/dbus-gvalue.c index 2c2b59a..e154da4 100644 --- a/dbus/dbus-gvalue.c +++ b/dbus/dbus-gvalue.c @@ -1926,6 +1926,16 @@ marshal_collection_ptrarray (DBusMessageIter *iter, return dbus_message_iter_close_container (iter, &subiter); } +/* If any of these assertions are violated, then marshal_collection_array + * is buggy for that type. dbus_g_value_basic_array_parse_variant() has + * general size-conversion code, if needed. */ +G_STATIC_ASSERT (sizeof (dbus_bool_t) == sizeof (gboolean)); +G_STATIC_ASSERT (sizeof (dbus_int32_t) == sizeof (gint)); +G_STATIC_ASSERT (sizeof (dbus_uint32_t) == sizeof (guint)); +/* These should be true regardless, but just for completeness... */ +G_STATIC_ASSERT (sizeof (dbus_int64_t) == sizeof (gint64)); +G_STATIC_ASSERT (sizeof (dbus_uint64_t) == sizeof (guint64)); +G_STATIC_ASSERT (sizeof (double) == sizeof (gdouble)); static gboolean marshal_collection_array (DBusMessageIter *iter, -- 1.7.5.1