Re: [PATCH RESEND] cyclictest: calcdiff calculated wrong seconds if the difference was bigger than 2147s

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Hello,

My first fix didn't took into account that long is 4 byte long on ARM. Therefor 
I changed it to long long now, which works on my ARM board...


Signed-off-by: Stefan Agner <stefan@xxxxxxxx>
---
 src/cyclictest/cyclictest.c |   12 ++++++------
 1 files changed, 6 insertions(+), 6 deletions(-)

diff --git a/src/cyclictest/cyclictest.c b/src/cyclictest/cyclictest.c
index be9a3f9..3035a0a 100644
--- a/src/cyclictest/cyclictest.c
+++ b/src/cyclictest/cyclictest.c
@@ -287,18 +287,18 @@ static inline void tsnorm(struct timespec *ts)
 	}
 }
 
-static inline long calcdiff(struct timespec t1, struct timespec t2)
+static inline long long calcdiff(struct timespec t1, struct timespec t2)
 {
-	long diff;
-	diff = USEC_PER_SEC * ((int) t1.tv_sec - (int) t2.tv_sec);
+	long long diff;
+	diff = USEC_PER_SEC * (long long)((int) t1.tv_sec - (int) t2.tv_sec);
 	diff += ((int) t1.tv_nsec - (int) t2.tv_nsec) / 1000;
 	return diff;
 }
 
-static inline long calcdiff_ns(struct timespec t1, struct timespec t2)
+static inline long long calcdiff_ns(struct timespec t1, struct timespec t2)
 {
-	long diff;
-	diff = NSEC_PER_SEC * ((int) t1.tv_sec - (int) t2.tv_sec);
+	long long diff;
+	diff = NSEC_PER_SEC * (long long)((int) t1.tv_sec - (int) t2.tv_sec);
 	diff += ((int) t1.tv_nsec - (int) t2.tv_nsec);
 	return diff;
 }
-- 1.6.0.4 
--
To unsubscribe from this list: send the line "unsubscribe linux-rt-users" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html

[Index of Archives]     [RT Stable]     [Kernel Newbies]     [IDE]     [Security]     [Git]     [Netfilter]     [Bugtraq]     [Yosemite]     [Yosemite News]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Linux ATA RAID]     [Samba]     [Video 4 Linux]     [Device Mapper]

  Powered by Linux