From: Will Thompson Date: Wed, 9 Sep 2009 19:35:13 +0000 (+0100) Subject: Make array-printing code easier to follow X-Git-Tag: dbus-1.3.1~265^2~2 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=1e14e409a48a96e0599c8f675604735ca132fc0f;p=platform%2Fupstream%2Fdbus.git 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. --- diff --git a/tools/dbus-print-message.c b/tools/dbus-print-message.c index 335aa3d..749fca6 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);