Document switch fall-through cases
[fio.git] / lib / rand.c
index 1b661a86946bd75a06c2048022422487b00f17ea..f18bd8d84e9cf021cd49a8df3dc931f47d7f35e2 100644 (file)
@@ -34,9 +34,8 @@
 */
 
 #include <string.h>
-#include <assert.h>
 #include "rand.h"
-#include "lib/pattern.h"
+#include "pattern.h"
 #include "../hash.h"
 
 int arch_random;
@@ -76,7 +75,7 @@ static void __init_rand64(struct taus258_state *state, uint64_t seed)
                __rand64(state);
 }
 
-void init_rand(struct frand_state *state, int use64)
+void init_rand(struct frand_state *state, bool use64)
 {
        state->use64 = use64;
 
@@ -86,7 +85,7 @@ void init_rand(struct frand_state *state, int use64)
                __init_rand64(&state->state64, 1);
 }
 
-void init_rand_seed(struct frand_state *state, unsigned int seed, int use64)
+void init_rand_seed(struct frand_state *state, unsigned int seed, bool use64)
 {
        state->use64 = use64;
 
@@ -157,7 +156,7 @@ void __fill_random_buf_percentage(unsigned long seed, void *buf,
                /*
                 * Fill random chunk
                 */
-               this_len = (segment * (100 - percentage)) / 100;
+               this_len = ((unsigned long long)segment * (100 - percentage)) / 100;
                if (this_len > len)
                        this_len = len;
 
@@ -167,6 +166,7 @@ void __fill_random_buf_percentage(unsigned long seed, void *buf,
                if (!len)
                        break;
                buf += this_len;
+               this_len = segment - this_len;
 
                if (this_len > len)
                        this_len = len;