summaryrefslogtreecommitdiff
path: root/aio-cancel.c
diff options
context:
space:
mode:
Diffstat (limited to 'aio-cancel.c')
-rw-r--r--aio-cancel.c4
1 files changed, 2 insertions, 2 deletions
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)