[PATCH] Fix dccp_timestamp()'s use of do_div()
From: David Howells
Date: Fri Jul 11 2008 - 09:59:41 EST
Fix dccp_timestamps()'s use of do_div() on an s64 by making delta a u64
instead and dividing that.
Possibly this should be guarded lest the interval calculation turn up negative,
but the possible negativity of the result of the division ignored anyway, and,
indeed, should not happen.
This was introduced by patch 4c70f383e0c0273c4092c4efdb414be0966978b7.
Signed-off-by: David Howells <dhowells@xxxxxxxxxx>
---
net/dccp/timer.c | 4 +++-
1 files changed, 3 insertions(+), 1 deletions(-)
diff --git a/net/dccp/timer.c b/net/dccp/timer.c
index 8703a79..27218c5 100644
--- a/net/dccp/timer.c
+++ b/net/dccp/timer.c
@@ -300,8 +300,10 @@ static ktime_t dccp_timestamp_seed;
*/
u32 dccp_timestamp(void)
{
- s64 delta = ktime_us_delta(ktime_get_real(), dccp_timestamp_seed);
+ u64 delta = ktime_us_delta(ktime_get_real(), dccp_timestamp_seed);
+ /* This will produce huge values if the current time should happen to
+ * be earlier than the initial timestamp, but that shouldn't happen */
do_div(delta, 10);
return delta;
}
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/