All of lore.kernel.org
 help / color / mirror / Atom feed
From: Stefan Agner <stefan@agner.ch>
To: linux-rt-users@vger.kernel.org
Subject: [PATCH] cyclictest: calcdiff calculated wrong seconds if the difference was bigger than 2147s
Date: Wed, 27 May 2009 23:22:15 +0200	[thread overview]
Message-ID: <4A1DAF07.6020704@agner.ch> (raw)

[-- Attachment #1: Type: text/plain, Size: 1042 bytes --]


Signed-off-by: Stefan Agner <stefan@agner.ch>
---
 src/cyclictest/cyclictest.c |    4 ++--
 1 files changed, 2 insertions(+), 2 deletions(-)

diff --git a/src/cyclictest/cyclictest.c b/src/cyclictest/cyclictest.c
index be9a3f9..6d695cb 100644
--- a/src/cyclictest/cyclictest.c
+++ b/src/cyclictest/cyclictest.c
@@ -290,7 +290,7 @@ static inline void tsnorm(struct timespec *ts)
 static inline long calcdiff(struct timespec t1, struct timespec t2)
 {
 	long diff;
-	diff = USEC_PER_SEC * ((int) t1.tv_sec - (int) t2.tv_sec);
+	diff = USEC_PER_SEC * (long)((int) t1.tv_sec - (int) t2.tv_sec);
 	diff += ((int) t1.tv_nsec - (int) t2.tv_nsec) / 1000;
 	return diff;
 }
@@ -298,7 +298,7 @@ static inline long calcdiff(struct timespec t1, struct timespec t2)
 static inline long calcdiff_ns(struct timespec t1, struct timespec t2)
 {
 	long diff;
-	diff = NSEC_PER_SEC * ((int) t1.tv_sec - (int) t2.tv_sec);
+	diff = NSEC_PER_SEC * (long)((int) t1.tv_sec - (int) t2.tv_sec);
 	diff += ((int) t1.tv_nsec - (int) t2.tv_nsec);
 	return diff;
 }
-- 


[-- Attachment #2: S/MIME Cryptographic Signature --]
[-- Type: application/x-pkcs7-signature, Size: 3928 bytes --]

             reply	other threads:[~2009-05-27 21:29 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2009-05-27 21:22 Stefan Agner [this message]
     [not found] ` <826434.45900.qm@web59805.mail.ac4.yahoo.com>
2009-05-27 21:53   ` [PATCH RESEND] cyclictest: calcdiff calculated wrong seconds if the difference was bigger than 2147s Stefan Agner
2009-05-28 19:52     ` Clark Williams

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=4A1DAF07.6020704@agner.ch \
    --to=stefan@agner.ch \
    --cc=linux-rt-users@vger.kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.