summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorWill Thompson <will.thompson@collabora.co.uk>2009-09-09 20:35:13 +0100
committerColin Walters <walters@verbum.org>2010-01-28 17:01:23 -0500
commit7a8fcdee22d2716f7891e030cda0e1e6536d0054 (patch)
treedc0b20cf56aaf6a3e0b0ce0bea22fb0b821bfece
parente2aee8bdebc0f95ff626680b9882e74442c05f98 (diff)
downloaddbus-7a8fcdee22d2716f7891e030cda0e1e6536d0054.tar.gz
Make array-printing code easier to follow
Previously dbus_message_iter_get_arg_type() was called twice: once in the loop condition to update 'current_type', and once to check if the loop will run again. This patch moves updating current_type to the end of the loop body.
-rw-r--r--tools/dbus-print-message.c9
1 files changed, 7 insertions, 2 deletions
diff --git a/tools/dbus-print-message.c b/tools/dbus-print-message.c
index 335aa3dc..749fca68 100644
--- a/tools/dbus-print-message.c
+++ b/tools/dbus-print-message.c
@@ -186,12 +186,17 @@ print_iter (DBusMessageIter *iter, dbus_bool_t literal, int depth)
dbus_message_iter_recurse (iter, &subiter);
+ current_type = dbus_message_iter_get_arg_type (&subiter);
+
printf("array [\n");
- while ((current_type = dbus_message_iter_get_arg_type (&subiter)) != DBUS_TYPE_INVALID)
+ while (current_type != DBUS_TYPE_INVALID)
{
print_iter (&subiter, literal, depth+1);
+
dbus_message_iter_next (&subiter);
- if (dbus_message_iter_get_arg_type (&subiter) != DBUS_TYPE_INVALID)
+ current_type = dbus_message_iter_get_arg_type (&subiter);
+
+ if (current_type != DBUS_TYPE_INVALID)
printf (",");
}
indent(depth);