* [PATCH] Avoid a build warning on 32-bit platforms
@ 2004-10-20 2:37 Chris Wedgwood
0 siblings, 0 replies; 2+ messages in thread
From: Chris Wedgwood @ 2004-10-20 2:37 UTC (permalink / raw)
To: LKML
Avoid a build warning on 32-bit platforms.
Signed-off-by: cw@f00f.org
Is this too ugly for words? :)
diff -Nru a/drivers/char/random.c b/drivers/char/random.c
--- a/drivers/char/random.c 2004-10-19 17:48:36 -07:00
+++ b/drivers/char/random.c 2004-10-19 17:48:36 -07:00
@@ -818,11 +818,12 @@
* jiffies.
*/
time = get_cycles();
- if (time != 0) {
- if (sizeof(time) > 4)
- num ^= (u32)(time >> 32);
- } else {
+ if (!time)
time = jiffies;
+ else {
+#if (BITS_PER_LONG > 32)
+ num ^= (u32)(time >> 32);
+#endif /* (BITS_PER_LONG > 32) */
}
/*
^ permalink raw reply [flat|nested] 2+ messages in thread
* Re: [PATCH] Avoid a build warning on 32-bit platforms
@ 2004-10-20 9:56 Mikael Pettersson
0 siblings, 0 replies; 2+ messages in thread
From: Mikael Pettersson @ 2004-10-20 9:56 UTC (permalink / raw)
To: cw, linux-kernel
On Tue, 19 Oct 2004 19:37:16 -0700, cw@f00f.org (Chris Wedgwood) wrote:
>@@ -818,11 +818,12 @@
> * jiffies.
> */
> time = get_cycles();
>- if (time != 0) {
>- if (sizeof(time) > 4)
>- num ^= (u32)(time >> 32);
>- } else {
>+ if (!time)
> time = jiffies;
>+ else {
>+#if (BITS_PER_LONG > 32)
>+ num ^= (u32)(time >> 32);
>+#endif /* (BITS_PER_LONG > 32) */
There's a coding idiom for doing this: just break up
the ">> 32" in two steps, like: ((time >> 31) >> 1).
Definitely preferable over #ifdef:s.
/Mikael
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2004-10-20 10:06 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2004-10-20 2:37 [PATCH] Avoid a build warning on 32-bit platforms Chris Wedgwood
2004-10-20 9:56 Mikael Pettersson
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®