summaryrefslogtreecommitdiff
path: root/kernel
diff options
context:
space:
mode:
authorGeorge Anzinger <george@mvista.com>2005-11-13 16:07:44 -0800
committerLinus Torvalds <torvalds@g5.osdl.org>2005-11-13 18:14:17 -0800
commit3f39894d1b5c253b10fcb8fbbbcf65a330f6cdc7 (patch)
tree6d166da37e874f2c0b891d4cf61b5f4b9bf5a71f /kernel
parent09e12f9f6bcd9af516d901223cebdbae58b32c9f (diff)
downloadlwn-3f39894d1b5c253b10fcb8fbbbcf65a330f6cdc7.tar.gz
lwn-3f39894d1b5c253b10fcb8fbbbcf65a330f6cdc7.zip
[PATCH] timespec: normalize off by one errors
It would appear that the timespec normalize code has an off by one error. Found in three places. Thanks to Ben for spotting. Signed-off-by: George Anzinger<george@mvista.com> Cc: Benjamin Herrenschmidt <benh@kernel.crashing.org> Signed-off-by: Andrew Morton <akpm@osdl.org> Signed-off-by: Linus Torvalds <torvalds@osdl.org>
Diffstat (limited to 'kernel')
-rw-r--r--kernel/posix-timers.c10
1 files changed, 3 insertions, 7 deletions
diff --git a/kernel/posix-timers.c b/kernel/posix-timers.c
index ea55c7a1cd75..5870efb3e200 100644
--- a/kernel/posix-timers.c
+++ b/kernel/posix-timers.c
@@ -270,7 +270,7 @@ static void tstojiffie(struct timespec *tp, int res, u64 *jiff)
long sec = tp->tv_sec;
long nsec = tp->tv_nsec + res - 1;
- if (nsec > NSEC_PER_SEC) {
+ if (nsec >= NSEC_PER_SEC) {
sec++;
nsec -= NSEC_PER_SEC;
}
@@ -1209,13 +1209,9 @@ static int do_posix_clock_monotonic_get(clockid_t clock, struct timespec *tp)
do_posix_clock_monotonic_gettime_parts(tp, &wall_to_mono);
- tp->tv_sec += wall_to_mono.tv_sec;
- tp->tv_nsec += wall_to_mono.tv_nsec;
+ set_normalized_timespec(tp, tp->tv_sec + wall_to_mono.tv_sec,
+ tp->tv_nsec + wall_to_mono.tv_nsec);
- if ((tp->tv_nsec - NSEC_PER_SEC) > 0) {
- tp->tv_nsec -= NSEC_PER_SEC;
- tp->tv_sec++;
- }
return 0;
}