From: Brian Norris <computersforpeace@gmail.com>
To: Artem Bityutskiy <dedekind1@gmail.com>
Cc: Jan Weitzel <j.weitzel@phytec.de>,
Brian Norris <computersforpeace@gmail.com>,
linux-mtd@lists.infradead.org
Subject: [PATCH v2] nandtest: seed random generator with time
Date: Fri, 2 Dec 2011 09:46:12 -0800 [thread overview]
Message-ID: <1322847972-26504-1-git-send-email-computersforpeace@gmail.com> (raw)
In-Reply-To: <1322730350.2332.28.camel@koala>
If a seed is not provided via --seed, we use the default rand() values,
which produces the same sequence of values every run. Since this is
undesirable, we should choose a random seed via the current time().
Note that this patch moves the srand() until after all the initial
options processing.
Cc: Jan Weitzel <j.weitzel@phytec.de>
Signed-off-by: Brian Norris <computersforpeace@gmail.com>
---
rebased on top of Jan's patch
nandtest.c | 5 ++++-
1 files changed, 4 insertions(+), 1 deletions(-)
diff --git a/nandtest.c b/nandtest.c
index b3aacaf..0187b87 100644
--- a/nandtest.c
+++ b/nandtest.c
@@ -140,6 +140,8 @@ int main(int argc, char **argv)
uint32_t offset = 0;
uint32_t length = -1;
+ seed = time(NULL);
+
for (;;) {
static const char *short_options="hkl:mo:p:s:";
static const struct option long_options[] = {
@@ -173,7 +175,6 @@ int main(int argc, char **argv)
case 's':
seed = atol(optarg);
- srand(seed);
break;
case 'p':
@@ -244,6 +245,8 @@ int main(int argc, char **argv)
printf("Bad blocks : %d\n", oldstats.badblocks);
printf("BBT blocks : %d\n", oldstats.bbtblocks);
+ srand(seed);
+
for (pass = 0; pass < nr_passes; pass++) {
loff_t test_ofs;
--
1.7.5.4
next prev parent reply other threads:[~2011-12-02 17:46 UTC|newest]
Thread overview: 10+ messages / expand[flat|nested] mbox.gz Atom feed top
2011-11-24 10:57 [PATCH] nandtest: use seed argument Jan Weitzel
2011-11-28 17:56 ` Brian Norris
2011-11-28 18:11 ` [PATCH] nandtest: seed random generator properly Brian Norris
2011-11-29 7:30 ` Antwort: " Jan Weitzel
2011-11-30 18:24 ` Brian Norris
2011-12-01 8:23 ` Jan Weitzel
2011-12-01 9:05 ` Artem Bityutskiy
2011-12-02 17:46 ` Brian Norris [this message]
2011-12-05 6:30 ` [PATCH v2] nandtest: seed random generator with time Artem Bityutskiy
2011-12-01 7:56 ` [PATCH] nandtest: use seed argument 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=1322847972-26504-1-git-send-email-computersforpeace@gmail.com \
--to=computersforpeace@gmail.com \
--cc=dedekind1@gmail.com \
--cc=j.weitzel@phytec.de \
--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).