lkml.org 
[lkml]   [2005]   [Jan]   [15]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
Patch in this message
/
From
Date
SubjectRe: sparse warning, or why does jifies_to_msecs() return an int?
>>>>> On Fri, 14 Jan 2005 20:29:07 -0800 (PST), Linus Torvalds <torvalds@osdl.org> said:

>> Is there are a good reason to constrain the return value to 4
>> billion msecs? If so, what's the proper way to shut up sparse?

Linus> There's no good way to shut up sparse, I think. The fact is,
Linus> we _are_ losing bits, but it doesn't matter much in this
Linus> case.

Yes, you're right.

Linus> I think "jiffies_to_msecs(MAX_JIFFY_OFFSET)" is fundamentally
Linus> a suspect operation (since the ranges are different for the
Linus> two types), and I think that the sparse warnign is correct,
Linus> but it's one of those "doing the wrong thing is not always
Linus> wrogn enough to matter".

How about something along the lines of the attached? The test in
msecs_to_jiffies is non-sensical for HZ>=1000 because

(a) jiffies_to_msecs(x) <= x, if HZ >= 1000, and
(b) MAX_UINT <= MAX_ULONG

--david

===== include/linux/jiffies.h 1.11 vs edited =====
--- 1.11/include/linux/jiffies.h 2005-01-04 18:48:02 -08:00
+++ edited/include/linux/jiffies.h 2005-01-14 21:52:46 -08:00
@@ -276,8 +276,10 @@

static inline unsigned long msecs_to_jiffies(const unsigned int m)
{
+#if HZ < 1000
if (m > jiffies_to_msecs(MAX_JIFFY_OFFSET))
return MAX_JIFFY_OFFSET;
+#endif
#if HZ <= 1000 && !(1000 % HZ)
return (m + (1000 / HZ) - 1) / (1000 / HZ);
#elif HZ > 1000 && !(HZ % 1000)
-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/
\
 
 \ /
  Last update: 2005-03-22 14:09    [W:0.092 / U:0.028 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site