summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorChris Mason <clm@fb.com>2020-04-16 11:13:47 -0700
committerChris Mason <clm@fb.com>2020-04-16 11:13:47 -0700
commit17703d4fdf13ca5a3284c796033a1146915bede7 (patch)
treed6ae3a5f872fdf01ee877a2a294cc23bb1c0fc60
parent691e47dc6f9f4bb883b78b45a8a42bfee9a5526c (diff)
downloadsimoop-17703d4fdf13ca5a3284c796033a1146915bede7.tar.gz
simoop: make sure oddsizes never returns zero sizes
Signed-off-by: Chris Mason <clm@fb.com>
-rw-r--r--simoop.c7
1 files changed, 6 insertions, 1 deletions
diff --git a/simoop.c b/simoop.c
index fac500a..f73bb64 100644
--- a/simoop.c
+++ b/simoop.c
@@ -1010,10 +1010,15 @@ static int open_path(char *path, int seq, char *postfix, int flags)
static loff_t randomize_size(loff_t sz)
{
+ loff_t val;
if (!oddsizes)
return sz;
- return rand() % sz;
+ val = rand() % sz;
+ if (val == 0)
+ val = sz;
+
+ return val;
}
static void maybe_fsync(int fd)