summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSimon McVittie <simon.mcvittie@collabora.co.uk>2011-06-10 14:17:31 +0100
committerSimon McVittie <simon.mcvittie@collabora.co.uk>2012-02-08 19:16:07 +0000
commit54954928aea49eedfe88d7335828d1bd912aed9a (patch)
treedf69202dad12d8837dfbfd4cea2c4db8679d63d6
parent7fc3af9f12079c30ef05af24e64bcce5f06a65f5 (diff)
Stop checking for DBusTypeWriter.type_str == NULLrecursive-marshal-clarity-33870
Bug: https://bugs.freedesktop.org/show_bug.cgi?id=38240 Signed-off-by: Simon McVittie <simon.mcvittie@collabora.co.uk>
-rw-r--r--dbus/dbus-marshal-recursive.c70
1 files changed, 25 insertions, 45 deletions
diff --git a/dbus/dbus-marshal-recursive.c b/dbus/dbus-marshal-recursive.c
index e8cc20fd..5a9fce4c 100644
--- a/dbus/dbus-marshal-recursive.c
+++ b/dbus/dbus-marshal-recursive.c
@@ -1610,7 +1610,7 @@ writer_recurse_init_and_check (DBusTypeWriter *writer,
sub->enabled = writer->enabled;
#ifndef DBUS_DISABLE_CHECKS
- if (writer->type_pos_is_expectation && writer->type_str)
+ if (writer->type_pos_is_expectation)
{
int expected;
@@ -1640,9 +1640,7 @@ writer_recurse_init_and_check (DBusTypeWriter *writer,
writer,
_dbus_type_to_string (writer->container_type),
writer->type_pos, writer->value_pos, writer->type_pos_is_expectation,
- writer->type_str ?
- _dbus_string_get_const_data_len (writer->type_str, writer->type_pos, 0) :
- "unknown",
+ _dbus_string_get_const_data_len (writer->type_str, writer->type_pos, 0),
writer->enabled);
_dbus_verbose (" type writer %p recurse sub %s type_pos = %d value_pos = %d is_expectation = %d enabled = %d\n",
sub,
@@ -1665,15 +1663,10 @@ write_or_verify_typecode (DBusTypeWriter *writer,
#if RECURSIVE_MARSHAL_WRITE_TRACE
_dbus_verbose (" type writer %p write_or_verify start type_pos = %d remaining sig '%s' enabled = %d\n",
writer, writer->type_pos,
- writer->type_str ?
- _dbus_string_get_const_data_len (writer->type_str, writer->type_pos, 0) :
- "unknown",
+ _dbus_string_get_const_data_len (writer->type_str, writer->type_pos, 0),
writer->enabled);
#endif
- if (writer->type_str == NULL)
- return TRUE;
-
if (writer->type_pos_is_expectation)
{
#ifndef DBUS_DISABLE_CHECKS
@@ -1775,8 +1768,7 @@ writer_recurse_array (DBusTypeWriter *writer,
int aligned;
#ifndef DBUS_DISABLE_CHECKS
- if (writer->container_type == DBUS_TYPE_ARRAY &&
- writer->type_str)
+ if (writer->container_type == DBUS_TYPE_ARRAY)
{
if (!_dbus_string_equal_substring (contained_type,
contained_type_start,
@@ -1802,13 +1794,10 @@ writer_recurse_array (DBusTypeWriter *writer,
return FALSE;
}
- if (writer->type_str != NULL)
- {
- sub->type_pos += 1; /* move to point to the element type, since type_pos
- * should be the expected type for further writes
- */
- sub->u.array.element_type_pos = sub->type_pos;
- }
+ sub->type_pos += 1; /* move to point to the element type, since type_pos
+ * should be the expected type for further writes
+ */
+ sub->u.array.element_type_pos = sub->type_pos;
if (!writer->type_pos_is_expectation)
{
@@ -1830,16 +1819,13 @@ writer_recurse_array (DBusTypeWriter *writer,
_dbus_assert_not_reached ("should not have failed to insert array element typecodes");
}
- if (writer->type_str != NULL)
- {
- /* If the parent is an array, we hold type_pos pointing at the array element type;
- * otherwise advance it to reflect the array value we just recursed into
- */
- if (writer->container_type != DBUS_TYPE_ARRAY)
- writer->type_pos += 1 + contained_type_len;
- else
- _dbus_assert (writer->type_pos_is_expectation); /* because it's an array */
- }
+ /* If the parent is an array, we hold type_pos pointing at the array element type;
+ * otherwise advance it to reflect the array value we just recursed into
+ */
+ if (writer->container_type != DBUS_TYPE_ARRAY)
+ writer->type_pos += 1 + contained_type_len;
+ else
+ _dbus_assert (writer->type_pos_is_expectation); /* because it's an array */
if (writer->enabled)
{
@@ -1908,9 +1894,7 @@ writer_recurse_array (DBusTypeWriter *writer,
#if RECURSIVE_MARSHAL_WRITE_TRACE
_dbus_verbose (" type writer %p recurse array done remaining sig '%s' array start_pos = %d len_pos = %d value_pos = %d\n", sub,
- sub->type_str ?
- _dbus_string_get_const_data_len (sub->type_str, sub->type_pos, 0) :
- "unknown",
+ _dbus_string_get_const_data_len (sub->type_str, sub->type_pos, 0),
sub->u.array.start_pos, sub->u.array.len_pos, sub->value_pos);
#endif
@@ -2238,17 +2222,14 @@ _dbus_type_writer_unrecurse (DBusTypeWriter *writer,
*
* For all these, DICT_ENTRY is the same as STRUCT
*/
- if (writer->type_str != NULL)
+ if ((sub->container_type == DBUS_TYPE_STRUCT ||
+ sub->container_type == DBUS_TYPE_DICT_ENTRY) &&
+ (writer->container_type == DBUS_TYPE_STRUCT ||
+ writer->container_type == DBUS_TYPE_DICT_ENTRY ||
+ writer->container_type == DBUS_TYPE_INVALID))
{
- if ((sub->container_type == DBUS_TYPE_STRUCT ||
- sub->container_type == DBUS_TYPE_DICT_ENTRY) &&
- (writer->container_type == DBUS_TYPE_STRUCT ||
- writer->container_type == DBUS_TYPE_DICT_ENTRY ||
- writer->container_type == DBUS_TYPE_INVALID))
- {
- /* Advance the parent to the next struct field */
- writer->type_pos = sub->type_pos;
- }
+ /* Advance the parent to the next struct field */
+ writer->type_pos = sub->type_pos;
}
writer->value_pos = sub->value_pos;
@@ -2256,8 +2237,7 @@ _dbus_type_writer_unrecurse (DBusTypeWriter *writer,
#if RECURSIVE_MARSHAL_WRITE_TRACE
_dbus_verbose (" type writer %p unrecursed type_pos = %d value_pos = %d remaining sig '%s'\n",
writer, writer->type_pos, writer->value_pos,
- writer->type_str ?
- _dbus_string_get_const_data_len (writer->type_str, writer->type_pos, 0) :
+ _dbus_string_get_const_data_len (writer->type_str, writer->type_pos, 0),
"unknown");
#endif
@@ -2282,7 +2262,7 @@ _dbus_type_writer_write_basic (DBusTypeWriter *writer,
_DBUS_ASSERT_TYPE_WRITER (writer);
/* First ensure that our type realloc will succeed */
- if (!writer->type_pos_is_expectation && writer->type_str != NULL)
+ if (!writer->type_pos_is_expectation)
{
if (!_dbus_string_alloc_space (writer->type_str, 1))
return FALSE;