linux-mtd.lists.infradead.org archive mirror
 help / color / mirror / Atom feed
From: Sascha Hauer <s.hauer@pengutronix.de>
To: linux-mtd@lists.infradead.org
Cc: Artem Bityutskiy <artem.bityutskiy@linux.intel.com>,
	Sascha Hauer <s.hauer@pengutronix.de>
Subject: [PATCH] mtd stresstest: Fix random number generation
Date: Fri, 25 May 2012 15:58:29 +0200	[thread overview]
Message-ID: <1337954309-18178-1-git-send-email-s.hauer@pengutronix.de> (raw)

the random number generation in the mtd stresstest was changed from a
homebrew generator to random32. random32 generates unsigned random
numbers, but the values are assigned to signed integers. This results
in negative offsets, eraseblocks and writesized. Fix it by using unsigned
integers for these variables instead.

This is broken since:

commit d9c04f2ccc6db3bc4b80e969af66d486c42e77b0
Author: Artem Bityutskiy <artem.bityutskiy@linux.intel.com>
Date:   Fri May 18 18:44:53 2012 +0300

    mtd: tests: use random32 instead of home-brewed generator

    This is a clean-up patch which removes the own pseudo-random numbers generator
    from the speed- and stress-tests and makes them use the 'random32()' generator
    instead.

    Signed-off-by: Artem Bityutskiy <artem.bityutskiy@linux.intel.com>

Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
---
 drivers/mtd/tests/mtd_stresstest.c |    6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/drivers/mtd/tests/mtd_stresstest.c b/drivers/mtd/tests/mtd_stresstest.c
index 52ea178..cb268ce 100644
--- a/drivers/mtd/tests/mtd_stresstest.c
+++ b/drivers/mtd/tests/mtd_stresstest.c
@@ -52,7 +52,7 @@ static int pgcnt;
 
 static int rand_eb(void)
 {
-	int eb;
+	unsigned int eb;
 
 again:
 	eb = random32();
@@ -65,7 +65,7 @@ again:
 
 static int rand_offs(void)
 {
-	int offs;
+	unsigned int offs;
 
 	offs = random32();
 	offs %= bufsize;
@@ -74,7 +74,7 @@ static int rand_offs(void)
 
 static int rand_len(int offs)
 {
-	int len;
+	unsigned int len;
 
 	len = random32();
 	len %= (bufsize - offs);
-- 
1.7.10

             reply	other threads:[~2012-05-25 13:58 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2012-05-25 13:58 Sascha Hauer [this message]
2012-05-25 14:57 ` [PATCH] mtd stresstest: Fix random number generation Artem Bityutskiy

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1337954309-18178-1-git-send-email-s.hauer@pengutronix.de \
    --to=s.hauer@pengutronix.de \
    --cc=artem.bityutskiy@linux.intel.com \
    --cc=linux-mtd@lists.infradead.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).