Re: Use of RAND_MAX still correct?
On Sun, Mar 08, 2020 at 01:27:22PM +0100, Tim Düsterhus wrote: > Willy, > > when looking at the newest PRNG commits I noticed that some places that > now use ha_random() still refer to RAND_MAX. You should check whether > that still is appropriate, because my understanding is that you are now > guaranteed to receive a specific number of bits. Yes, I even want to simplify some of them because the initial reason was that random() only provides 31 bits and at some places we need 32 or even 64. Now we also have ha_random32() and ha_random64() precisely in preparation for this :-) Cheers, Willy
[PATCH] CLEANUP: remove unused code in 'my_ffsl/my_flsl' functions
It seems to me that shifting the variable 'a' at the end of the functions is of no use. Maybe there is something I don't see here, in which case I apologize. :) -- Zaga What can change the nature of a man? >From 772c6517400e45c6e07c7f0fd733d9cbd68c65da Mon Sep 17 00:00:00 2001 From: Miroslav Zagorac Date: Sun, 8 Mar 2020 16:32:20 +0100 Subject: [PATCH] CLEANUP: remove unused code in 'my_ffsl/my_flsl' functions Shifting the variable 'a' one bit to the right has no effect on the result of the functions. --- include/common/standard.h | 2 -- 1 file changed, 2 deletions(-) diff --git a/include/common/standard.h b/include/common/standard.h index d8bccbafb..103a07e5f 100644 --- a/include/common/standard.h +++ b/include/common/standard.h @@ -902,7 +902,6 @@ static inline unsigned int my_ffsl(unsigned long a) cnt += 2; } if (!(a & 0x1)) { - a >>= 1; cnt += 1; } #endif /* x86_64 */ @@ -946,7 +945,6 @@ static inline unsigned int my_flsl(unsigned long a) cnt += 2; } if (a & 0x2) { - a >>= 1; cnt += 1; } #endif /* x86_64 */ -- 2.20.1
Use of RAND_MAX still correct?
Willy, when looking at the newest PRNG commits I noticed that some places that now use ha_random() still refer to RAND_MAX. You should check whether that still is appropriate, because my understanding is that you are now guaranteed to receive a specific number of bits. Best regards Tim Düsterhus