Patchwork nandtest: use seed argument

login
register
mail settings
Submitter Jan Weitzel
Date Nov. 24, 2011, 10:57 a.m.
Message ID <1322132254-5830-1-git-send-email-j.weitzel@phytec.de>
Download mbox | patch
Permalink /patch/127475/
State New
Headers show

Comments

Jan Weitzel - Nov. 24, 2011, 10:57 a.m.
if a seed is provided it is actually not used. First call is
"seed = rand()" killing the given seed.

Signed-off-by: Jan Weitzel <j.weitzel@phytec.de>
---
 nandtest.c |    1 +
 1 files changed, 1 insertions(+), 0 deletions(-)
Brian Norris - Nov. 28, 2011, 5:56 p.m.
On Thu, Nov 24, 2011 at 2:57 AM, Jan Weitzel <j.weitzel@phytec.de> wrote:
> if a seed is provided it is actually not used. First call is
> "seed = rand()" killing the given seed.
>
> Signed-off-by: Jan Weitzel <j.weitzel@phytec.de>

Tested-by: Brian Norris <computersforpeace@gmail.com>

You might also note that when a seed isn't provided, nandtest does not
produce random results because it just uses the default seed. At least
for my system, I see the same results every execution; I believe this
is the general C rand() behavior. I'll send a follow-up patch that
actually utilizes <time.h> to use time as a random seed.

Brian
Artem Bityutskiy - Dec. 1, 2011, 7:56 a.m.
On Thu, 2011-11-24 at 11:57 +0100, Jan Weitzel wrote:
> if a seed is provided it is actually not used. First call is
> "seed = rand()" killing the given seed.
> 
> Signed-off-by: Jan Weitzel <j.weitzel@phytec.de>

Pushed to mtd-utils.git, thanks!

Artem.

Patch

diff --git a/nandtest.c b/nandtest.c
index db7f427..b3aacaf 100644
--- a/nandtest.c
+++ b/nandtest.c
@@ -173,6 +173,7 @@  int main(int argc, char **argv)
 
 		case 's':
 			seed = atol(optarg);
+			srand(seed);
 			break;
 
 		case 'p':