[PATCH 08/12] Cleaned up rand32() and remove __rand32()
[email protected] Fri, 6 Mar 2015 14:33:48 -0800
| Newsgroups | org.kernel.vger.trinity |
|---|---|
| Message-ID | <[email protected]> |
From: Tyson Smith <[email protected]> Removed the block at the beginning of rand32() that just basically |s and ^s rand() with rand() or a more interesting number to basically get rand again. This is just an expensive way of getting a random number. Merged the small switch case from __rand32() in to rand32() now that there is room. --- random.c | 31 ++----------------------------- 1 file changed, 2 insertions(+), 29 deletions(-) diff --git a/random.c b/random.c index bf32648..ec20656 100644 --- a/random.c +++ b/random.c @@ -106,10 +106,9 @@ static unsigned long rept_byte(void) } /* - * "selector" function for 32bit random. - * only called from rand32() + * Generate, and munge a 32bit number. */ -static unsigned int __rand32(void) +unsigned int rand32(void) { unsigned long r = 0; @@ -125,32 +124,6 @@ static unsigned int __rand32(void) case 4: return get_interesting_value(); } - return r; -} - -/* - * Generate, and munge a 32bit number. - */ -unsigned int rand32(void) -{ - unsigned long r = 0; - - r = __rand32(); - - if (rand_bool()) { - unsigned int i; - unsigned int rounds; - - /* mangle it. */ - rounds = rand() % 3; - for (i = 0; i < rounds; i++) { - if (rand_bool()) - r |= __rand32(); - else - r ^= __rand32(); - } - } - /* Sometimes deduct it from INT_MAX */ if (rand_bool()) r = INT_MAX - r; -- 1.9.1