[PATCH (updated)] Avoid annoying build warning on 32-bit platforms

Chris Wedgwood
2004-10-20T10:30:46Z

On Wed, Oct 20, 2004 at 11:56:45AM +0200, Mikael Pettersson wrote:

> There's a coding idiom for doing this: just break up
> the ">> 32" in two steps, like: ((time >> 31) >> 1).

i assumed gcc would complain there too but it doesn't and it does
optimize this away (i checked)

> Definitely preferable over #ifdef:s.

indeed

Avoid annoying gcc warning on 32-bit platforms.

Signed-off-by: cw@f00f.org

===== drivers/char/random.c 1.57 vs edited =====
--- 1.57/drivers/char/random.c 2004-10-05 14:21:53 -07:00
+++ edited/drivers/char/random.c 2004-10-20 03:19:17 -07:00
@@ -818,12 +818,10 @@ static void add_timer_randomness(struct
* jiffies.
*/
time = get_cycles();
- if (time != 0) {
- if (sizeof(time) > 4)
- num ^= (u32)(time >> 32);
- } else {
+ if (time)
+ num ^= (u32)((time >> 32) >> 1);
+ else
time = jiffies;
- }

/*
* Calculate number of bits of randomness we probably added.