bug-coreutils
[Top][All Lists]
Advanced

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

xnanosleep range with 64 bit time_t


From: Frank v Waveren
Subject: xnanosleep range with 64 bit time_t
Date: Sun, 27 Aug 2006 11:43:30 +0200
User-agent: Mutt/1.5.9i

lib/xnanosleep.c currently assumes nanosleep works with any value that
can be fit into the struct timespec. For gnu+linux on a 
platform with 64 bit longs, this isn't true (it currently doesn't even
return and error but just silently integer-overflows, but I've
submitted a patch to make it error).

I haven't checked how other operating systems handle this (do any
others even have 64 bit time_t's?), but the follow patch stops it from
failing silently on linux, and if and when my patch is accepted, it
stops it from erroring.

If there are other operating systems the coreutils run on that handle
64 bit time_t's properly this should be "#ifdef linux"-ed, but I'll
leave that to someone who knows more about the build system.

--- coreutils/lib/xnanosleep.c.old      2006-08-27 10:49:11.000000000 +0200
+++ coreutils/lib/xnanosleep.c  2006-08-27 11:40:25.000000000 +0200
@@ -34,9 +34,10 @@
 
 #include "intprops.h"
 #include "timespec.h"
+#include "minmax.h"
 
 #ifndef TIME_T_MAX
-# define TIME_T_MAX TYPE_MAXIMUM (time_t)
+# define TIME_T_MAX MIN(TYPE_MAXIMUM (time_t), (~(1<<31)))
 #endif
 
 /* Sleep until the time (call it WAKE_UP_TIME) specified as

-- 
Frank v Waveren                                  Key fingerprint: BDD7 D61E
address@hidden                                              5D39 CF05 4BFC F57A
Public key: hkp://wwwkeys.pgp.net/468D62C8              FA00 7D51 468D 62C8

Attachment: signature.asc
Description: Digital signature


reply via email to

[Prev in Thread] Current Thread [Next in Thread]