aboutsummaryrefslogtreecommitdiff
path: root/src/cmd/venti/randtest.c
diff options
context:
space:
mode:
authorRuss Cox <rsc@swtch.com>2007-09-24 22:29:16 -0400
committerRuss Cox <rsc@swtch.com>2007-09-24 22:29:16 -0400
commit72281ecda814ad952b868ac61f018507916dd6da (patch)
tree9fc5d0ea3a27f359cdeafdc1b3cb9294424442aa /src/cmd/venti/randtest.c
parent50f5d1a7a8b307464a4dfabb249bbf3605b2ffae (diff)
downloadplan9port-72281ecda814ad952b868ac61f018507916dd6da.tar.gz
plan9port-72281ecda814ad952b868ac61f018507916dd6da.tar.bz2
plan9port-72281ecda814ad952b868ac61f018507916dd6da.zip
venti/randtest: compute totalbytes correctly
Diffstat (limited to 'src/cmd/venti/randtest.c')
-rw-r--r--src/cmd/venti/randtest.c7
1 files changed, 4 insertions, 3 deletions
diff --git a/src/cmd/venti/randtest.c b/src/cmd/venti/randtest.c
index 2a1fa6ee..7d94eef2 100644
--- a/src/cmd/venti/randtest.c
+++ b/src/cmd/venti/randtest.c
@@ -96,8 +96,9 @@ run(void (*fn)(char*, char*), Channel *c)
buf = vtmalloc(blocksize);
cur = 0;
packets = totalbytes/blocksize;
- if(maxpackets == 0)
- maxpackets = packets;
+ if(maxpackets > 0 && maxpackets < packets)
+ packets = maxpackets;
+ totalbytes = (vlong)packets * blocksize;
order = vtmalloc(packets*sizeof order[0]);
for(i=0; i<packets; i++)
order[i] = i;
@@ -109,7 +110,7 @@ run(void (*fn)(char*, char*), Channel *c)
order[j] = t;
}
}
- for(i=0; i<packets && i<maxpackets; i++){
+ for(i=0; i<packets; i++){
memmove(buf, template, blocksize);
*(uint*)buf = order[i];
if(c){