64bit time_t patch

S.P.Zeidler spz at serpens.de
Wed Dec 11 20:41:52 UTC 2013


Hi,

eagle at eyrie.org (Russ Allbery) writes:

>"S.P.Zeidler" <spz at serpens.de> writes:

>> (64bit time_t on a 32bit machine)

>I suspect that will just be the first of a series of bugs that we'll find
>after the decision to make time_t longer than a long.  :/  Lots of C code
>was written under the assumption that wasn't possible.  For example, I bet
>there are lots of places where we printf a time_t by casting it to a long
>or an unsigned long.

The general idea in INN seems to be to cast time_t to long, and
in most places that does happen. Further exceptions I found:

Index: backends/ninpaths.c
===================================================================
--- backends/ninpaths.c (revision 9582)
+++ backends/ninpaths.c (working copy)
@@ -147,7 +147,7 @@
     }
     fprintf(f, "!!NINP " VERSION " %lu %lu %ld %ld %ld\n",
             (unsigned long) starttime, (unsigned long) time(NULL), sites,
-            total, (long)(atimes/total)+starttime);
+            total, (long)((atimes/total)+starttime));
     n=j=0;
     /* write the S-records (hosts), numbering them in the process */
     for (i=0; i<HASH_TBL; ++i)

Index: innfeed/endpoint.c
===================================================================
--- innfeed/endpoint.c  (revision 9582)
+++ innfeed/endpoint.c  (working copy)
@@ -502,8 +502,8 @@
   id = timerElemAdd (timeToWake,func,clientData) ;
 
 #if 0
-  d_printf (1,"Preparing wake %d at date %ld for %d seconds\n",
-           (int) id, (long) now, timeToWake - now) ;
+  d_printf (1,"Preparing wake %d at date %ld for %ld seconds\n",
+           (int) id, (long) now, (long) (timeToWake - now)) ;
 #endif
 
   return id ;
@@ -519,8 +519,8 @@
   id = timerElemAdd (now + timeToSleep,func,clientData) ;
 
 #if 0
-  d_printf (1,"Preparing sleep %d at date %ld for %d seconds\n",
-           (int) id, (long) now, timeToSleep) ;
+  d_printf (1,"Preparing sleep %d at date %ld for %ld seconds\n",
+           (int) id, (long) now, (long) timeToSleep) ;
 #endif
 
   return id ;

where for the latter file it's a pre-emptive strike, not active code.

I haven't had time to inspect this thoroughly, but have the impression
that changing from "cast time_t to long" to a 2039 compatible version,
doing printf(" .. %jd ..", (intmax_t) timeval); would be too disruptive
for a minor version. Maybe for the next major?

regards,
	spz
-- 
spz at serpens.de (S.P.Zeidler)


More information about the inn-workers mailing list