Re: [PATCH] Timespec normalize off by one errors

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

 



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   [email protected]
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 [email protected]
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/

[Index of Archives]     [Kernel Newbies]     [Netfilter]     [Bugtraq]     [Photo]     [Stuff]     [Gimp]     [Yosemite News]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Video 4 Linux]     [Linux for the blind]     [Linux Resources]
  Powered by Linux