+2017-10-27 Jim Meyering <meyering@fb.com>
+
+ timespec.h: use "assure" to avoid a spurious warning
+ * lib/timespec.h: Include "assure.h" and use it to help
+ gcc7's -Wstrict-overflow avoid a false positive warning
+ for a use in coreutils' ls.c. Suggested by Paul Eggert in
+ https://lists.gnu.org/r/bug-gnulib/2017-10/msg00007.html
+ * modules/timespec (Depends-on): Add assure.
+
2017-10-29 Bruno Haible <bruno@clisp.org>
Avoid several test failures with traditional locales on Haiku.
extern "C" {
#endif
+#include "assure.h"
+
/* Resolution of timespec timestamps (in units per second), and log
base 10 of the resolution. */
_GL_TIMESPEC_INLINE int _GL_ATTRIBUTE_PURE
timespec_cmp (struct timespec a, struct timespec b)
{
+ /* These assure calls teach gcc7 enough so that its
+ -Wstrict-overflow does not complain about the following code. */
+ assure (-1 <= a.tv_nsec && a.tv_nsec <= 2 * TIMESPEC_RESOLUTION);
+ assure (-1 <= b.tv_nsec && b.tv_nsec <= 2 * TIMESPEC_RESOLUTION);
return (a.tv_sec < b.tv_sec ? -1
: a.tv_sec > b.tv_sec ? 1
: (int) (a.tv_nsec - b.tv_nsec));