summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorKent Overstreet <koverstreet@google.com>2013-06-28 13:34:54 -0700
committerKent Overstreet <koverstreet@google.com>2013-06-28 13:34:54 -0700
commitd356fcd69117a03ea7d35150a3499986ee437b76 (patch)
treedfa52c81cf9ae492e13a255f4d7359c63e21690e
parent79b506457edc60d0b34fadefc0c84176b18b09b1 (diff)
fix an off by one bugHEADmaster
-rw-r--r--.gitignore1
-rw-r--r--aio-cancel.c4
2 files changed, 3 insertions, 2 deletions
diff --git a/.gitignore b/.gitignore
index 38b9f03..603bccf 100644
--- a/.gitignore
+++ b/.gitignore
@@ -4,3 +4,4 @@ aio-cancel-old
cscope.*
tags
*.o
+*.d
diff --git a/aio-cancel.c b/aio-cancel.c
index f5936cc..846fe6a 100644
--- a/aio-cancel.c
+++ b/aio-cancel.c
@@ -137,7 +137,7 @@ int main(int argc, char const *argv[])
exit(EXIT_FAILURE);
}
- blocks -= iosize / 512;
+ blocks -= iosize / 512; /* avoid reading past the end of the file */
printf("Doing %lu random reads to %s with iodepth %lu, iosize %lu\n",
nr_ios, argv[1], iodepth, iosize);
@@ -153,7 +153,7 @@ int main(int argc, char const *argv[])
iocb = malloc(sizeof(struct iocb));
io_prep_pread(iocb, fd, buffer, iosize,
- (random() % blocks) * 512);
+ (random() % (blocks + 1)) * 512);
ret = io_submit(io_ctx, 1, &iocb);
if (ret != 1)