[PATCH 09/12] Actually flip the sign of the value (1 -> -1)
[email protected] Fri, 6 Mar 2015 14:34:09 -0800
| Newsgroups | org.kernel.vger.trinity |
|---|---|
| Message-ID | <[email protected]> |
From: Tyson Smith <[email protected]> I believe this is what was intended, previously the high bit was just being set. Perhaps it was meant to be toggled? If that is the case we can add that too. --- random.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/random.c b/random.c index ec20656..d671035 100644 --- a/random.c +++ b/random.c @@ -130,7 +130,7 @@ unsigned int rand32(void) /* Sometimes flip sign */ if (rand_bool()) - r |= (1L << 31); + r = ~r + 1; /* we might get lucky if something is counting ints/longs etc. */ if (ONE_IN(4)) { @@ -206,9 +206,9 @@ u64 rand64(void) r |= (1UL << ((__WORDSIZE - 1) - (rand() % 8))); } - /* randomly flip sign bit. */ + /* Sometimes flip sign */ if (rand_bool()) - r |= (1UL << (__WORDSIZE - 1)); + r = ~r + 1; return r; } -- 1.9.1