Re: [PATCH] Timespec normalize off by one errors

From: George Anzinger
Date: Fri Nov 11 2005 - 17:16:10 EST


Joe Perches wrote:
On Fri, 2005-11-11 at 13:16 -0800, George Anzinger wrote:

@@ -1209,13 +1209,9 @@ static int do_posix_clock_monotonic_get(

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,
+ 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;
}


This is extremely ugly.

tp->tv_sec += wall_to_mono.tv_sec;
tp->tv_nsec += wall_to_mono.tv_nsec;
set_normalized_timespec(tp, tv->sec, tv_nsec);

is much more intelligible.

Besides, I think you forgot the "tp->" indirection in the
last argument of the set_normalized_timespec.

Oh SHIT. That is wrong. Think I will compile the next version... Stand by.

cheers, Joe


--
George Anzinger george@xxxxxxxxxx
HRT (High-res-timers): http://sourceforge.net/projects/high-res-timers/
-
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/