From 58621a4ceff3ecf3c87a69450506f9eb30966bfc Mon Sep 17 00:00:00 2001 From: Will Thompson Date: Fri, 5 Aug 2011 13:41:57 +0100 Subject: [PATCH] dbus-spam: fix --random-size to not clobber argument parsing 'i' is used to iterate across command-line arguments: unless there happen to be exactly the right number of body lengths, re-using it to iterate whitespace-separated integers from stdin is not going to work. :) --- tools/dbus-spam.c | 10 +++++----- 1 files changed, 5 insertions(+), 5 deletions(-) diff --git a/tools/dbus-spam.c b/tools/dbus-spam.c index d680f12..b37478e 100644 --- a/tools/dbus-spam.c +++ b/tools/dbus-spam.c @@ -201,7 +201,7 @@ dbus_test_tool_spam (int argc, char **argv) else if (strcmp (arg, "--random-size") == 0) { unsigned int len, max = 0; - int consumed = 0; + int j, consumed = 0; const char *p; consume_stdin (&payload_buf, &payload_len); @@ -220,12 +220,12 @@ dbus_test_tool_spam (int argc, char **argv) if (random_sizes == NULL) tool_oom ("allocating array of message lengths"); - for (p = payload_buf, i = 0; - p < payload_buf + payload_len && i < n_random_sizes; - p += consumed, i++) + for (p = payload_buf, j = 0; + p < payload_buf + payload_len && j < n_random_sizes; + p += consumed, j++) { sscanf (p, " %u %n", &len, &consumed); - random_sizes[i] = len; + random_sizes[j] = len; if (len > max) max = len; -- 1.7.5.4