summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorHavoc Pennington <hp@redhat.com>2007-06-12 19:39:47 +0000
committerHavoc Pennington <hp@redhat.com>2007-06-12 19:39:47 +0000
commit15a610bc4c87d389463112ef0ad4fde195af83ca (patch)
tree94e13a77a06b749498a6d74c627f0e0cc1b95976
parent1680f1fb403db648c1a9ebc45873df44dcfde6ef (diff)
2007-06-12 Havoc Pennington <hp@redhat.com>
* dbus/dbus-message.c (dbus_message_iter_open_container): improve the checks/warnings for contained_signature a bit
-rw-r--r--ChangeLog5
-rw-r--r--dbus/dbus-marshal-recursive.c27
-rw-r--r--dbus/dbus-message.c17
3 files changed, 35 insertions, 14 deletions
diff --git a/ChangeLog b/ChangeLog
index 46d6dea5..a433fd4c 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,5 +1,10 @@
2007-06-12 Havoc Pennington <hp@redhat.com>
+ * dbus/dbus-message.c (dbus_message_iter_open_container): improve
+ the checks/warnings for contained_signature a bit
+
+2007-06-12 Havoc Pennington <hp@redhat.com>
+
* dbus/dbus-marshal-recursive.c (write_or_verify_typecode):
improve the warning a bit if you write extra data into a message
diff --git a/dbus/dbus-marshal-recursive.c b/dbus/dbus-marshal-recursive.c
index b16f4ea5..3a3e8052 100644
--- a/dbus/dbus-marshal-recursive.c
+++ b/dbus/dbus-marshal-recursive.c
@@ -1645,9 +1645,18 @@ writer_recurse_init_and_check (DBusTypeWriter *writer,
if (expected != sub->container_type)
{
- _dbus_warn_check_failed ("Writing an element of type %s, but the expected type here is %s\n",
- _dbus_type_to_string (sub->container_type),
- _dbus_type_to_string (expected));
+ if (expected != DBUS_TYPE_INVALID)
+ _dbus_warn_check_failed ("Writing an element of type %s, but the expected type here is %s\n"
+ "The overall signature expected here was '%s' and we are on byte %d of that signature.\n",
+ _dbus_type_to_string (sub->container_type),
+ _dbus_type_to_string (expected),
+ _dbus_string_get_const_data (writer->type_str), writer->type_pos);
+ else
+ _dbus_warn_check_failed ("Writing an element of type %s, but no value is expected here\n",
+ "The overall signature expected here was '%s' and we are on byte %d of that signature.\n",
+ _dbus_type_to_string (sub->container_type),
+ _dbus_string_get_const_data (writer->type_str), writer->type_pos);
+
_dbus_assert_not_reached ("bad array element or variant content written");
}
}
@@ -1703,11 +1712,15 @@ write_or_verify_typecode (DBusTypeWriter *writer,
if (expected != typecode)
{
if (expected != DBUS_TYPE_INVALID)
- _dbus_warn_check_failed ("Array or variant type requires that type %s be written, but %s was written\n",
- _dbus_type_to_string (expected), _dbus_type_to_string (typecode));
+ _dbus_warn_check_failed ("Array or variant type requires that type %s be written, but %s was written.\n"
+ "The overall signature expected here was '%s' and we are on byte %d of that signature.\n",
+ _dbus_type_to_string (expected), _dbus_type_to_string (typecode),
+ _dbus_string_get_const_data (writer->type_str), writer->type_pos);
else
- _dbus_warn_check_failed ("Array or variant type wasn't expecting any more values to be written into it, but a value %s was written\n",
- _dbus_type_to_string (typecode));
+ _dbus_warn_check_failed ("Array or variant type wasn't expecting any more values to be written into it, but a value %s was written.\n"
+ "The overall signature expected here was '%s' and we are on byte %d of that signature.\n",
+ _dbus_type_to_string (typecode),
+ _dbus_string_get_const_data (writer->type_str), writer->type_pos);
_dbus_assert_not_reached ("bad type inserted somewhere inside an array or variant");
}
}
diff --git a/dbus/dbus-message.c b/dbus/dbus-message.c
index a98a0f8c..a64888ef 100644
--- a/dbus/dbus-message.c
+++ b/dbus/dbus-message.c
@@ -2350,16 +2350,19 @@ dbus_message_iter_open_container (DBusMessageIter *iter,
contained_signature == NULL) ||
(type == DBUS_TYPE_DICT_ENTRY &&
contained_signature == NULL) ||
- contained_signature != NULL, FALSE);
+ (type == DBUS_TYPE_VARIANT &&
+ contained_signature != NULL) ||
+ (type == DBUS_TYPE_ARRAY &&
+ contained_signature != NULL), FALSE);
-#if 0
- /* FIXME this would fail if the contained_signature is a dict entry,
- * since dict entries are invalid signatures standalone (they must be in
+ /* this would fail if the contained_signature is a dict entry, since
+ * dict entries are invalid signatures standalone (they must be in
* an array)
*/
- _dbus_return_val_if_fail (contained_signature == NULL ||
- _dbus_check_is_valid_signature (contained_signature));
-#endif
+ _dbus_return_val_if_fail (type == DBUS_TYPE_DICT_ENTRY ||
+ (contained_signature == NULL ||
+ _dbus_check_is_valid_signature (contained_signature)),
+ FALSE);
if (!_dbus_message_iter_open_signature (real))
return FALSE;