All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] improve randomness in rand64()
@ 2013-07-19 21:39 Andy Honig
  2013-07-20  0:30 ` Dave Jones
  0 siblings, 1 reply; 2+ messages in thread
From: Andy Honig @ 2013-07-19 21:39 UTC (permalink / raw)
  To: davej; +Cc: trinity

Commit 6112813df53ce6762f5c8de1d4382d67f9f2f769 introduced
code to occasionally invert the valuerand64().  However the code 
mistakenly zeroed the value instead by xoring it with itself.

Signed-off-by: Andy Honig <ahonig@google.com>

---
 random.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/random.c b/random.c
index a12ba42..b148714 100644
--- a/random.c
+++ b/random.c
@@ -214,7 +214,7 @@ u64 rand64(void)
 	}
 
 	if (rand_bool())
-		r ^= r;
+		r = ~r;
 
 	/* increase distribution in MSB */
 	if ((rand() % 10)) {
-- 
1.8.3

^ permalink raw reply related	[flat|nested] 2+ messages in thread

* Re: [PATCH] improve randomness in rand64()
  2013-07-19 21:39 [PATCH] improve randomness in rand64() Andy Honig
@ 2013-07-20  0:30 ` Dave Jones
  0 siblings, 0 replies; 2+ messages in thread
From: Dave Jones @ 2013-07-20  0:30 UTC (permalink / raw)
  To: Andy Honig; +Cc: trinity

On Fri, Jul 19, 2013 at 02:39:15PM -0700, Andy Honig wrote:
 > Commit 6112813df53ce6762f5c8de1d4382d67f9f2f769 introduced
 > code to occasionally invert the valuerand64().  However the code 
 > mistakenly zeroed the value instead by xoring it with itself.

Well that's just embaressing.

thanks, applied.

	Dave

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2013-07-20  0:30 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2013-07-19 21:39 [PATCH] improve randomness in rand64() Andy Honig
2013-07-20  0:30 ` Dave Jones

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.