Cleaned up rand32() and remove __rand32()
PATCH 8/12 Cleaned up rand32() and remove __rand32()
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(-)
random.c +2 -29
@@ -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;
Signature · 1 line
1.9.1