# HG changeset patch # User Jim Meyering # Date 1256813554 -3600 # Node ID 35acba1c7bcdc3e8449cc9b78cdc8264b3a36028 # Parent 5b7b0b8645f11520e9f481663bd943902bfc842f timespec: long-to-int truncation could make timespec_cmp malfunction * lib/timespec.h (timespec_cmp): Do not interpret a difference of a multiple of 2^32 nanoseconds as no difference. diff --git a/ChangeLog b/ChangeLog --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,9 @@ +2009-10-29 Jim Meyering + + timespec: long-to-int truncation could make timespec_cmp malfunction + * lib/timespec.h (timespec_cmp): Do not interpret a difference of + a multiple of 2^32 nanoseconds as no difference. + 2009-10-28 Jim Meyering fprintftime: wrap macro code argument in "do {...} while(0)" diff --git a/lib/timespec.h b/lib/timespec.h --- a/lib/timespec.h +++ b/lib/timespec.h @@ -1,6 +1,6 @@ /* timespec -- System time interface - Copyright (C) 2000, 2002, 2004, 2005, 2007 Free Software Foundation, Inc. + Copyright (C) 2000, 2002, 2004, 2005, 2007, 2009 Free Software Foundation, Inc. This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by @@ -27,7 +27,9 @@ { return (a.tv_sec < b.tv_sec ? -1 : a.tv_sec > b.tv_sec ? 1 - : a.tv_nsec - b.tv_nsec); + : a.tv_nsec < b.tv_nsec ? -1 + : a.tv_nsec > b.tv_nsec ? 1 + : 0); } void gettime (struct timespec *);