[PATCH 10/12] Decrease the likelihood of performing mangling operations
[email protected] Fri, 6 Mar 2015 14:35:14 -0800
| Newsgroups | org.kernel.vger.trinity |
|---|---|
| Message-ID | <[email protected]> |
From: Tyson Smith <[email protected]> These operations provide value however if they happen too often it prevents the use of unmodified values that are generated that are more significant. --- random.c | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/random.c b/random.c index d671035..fd5f2c0 100644 --- a/random.c +++ b/random.c @@ -125,11 +125,11 @@ unsigned int rand32(void) } /* Sometimes deduct it from INT_MAX */ - if (rand_bool()) + if (ONE_IN(25)) r = INT_MAX - r; /* Sometimes flip sign */ - if (rand_bool()) + if (ONE_IN(25)) r = ~r + 1; /* we might get lucky if something is counting ints/longs etc. */ @@ -193,11 +193,11 @@ u64 rand64(void) } /* Sometimes invert the generated number. */ - if (rand_bool()) + if (ONE_IN(25)) r = ~r; /* increase distribution in MSB */ - if ((rand() % 10)) { + if (ONE_IN(10)) { unsigned int i; unsigned int rounds; @@ -207,7 +207,7 @@ u64 rand64(void) } /* Sometimes flip sign */ - if (rand_bool()) + if (ONE_IN(25)) r = ~r + 1; return r; -- 1.9.1