Author: jra
Date: 2007-01-12 02:48:37 +0000 (Fri, 12 Jan 2007)
New Revision: 20694

WebSVN: 
http://websvn.samba.org/cgi-bin/viewcvs.cgi?view=rev&root=samba&rev=20694

Log:
To get this right we need to do signed 64-bit
comparisons here, not unsigned as we're eventually
casting into what it normall a signed 32 bit
value. Guenther please check (but I think I'm right here).
Jeremy.

Modified:
   branches/SAMBA_3_0/source/lib/time.c
   branches/SAMBA_3_0_24/source/lib/time.c


Changeset:
Modified: branches/SAMBA_3_0/source/lib/time.c
===================================================================
--- branches/SAMBA_3_0/source/lib/time.c        2007-01-12 02:33:09 UTC (rev 
20693)
+++ branches/SAMBA_3_0/source/lib/time.c        2007-01-12 02:48:37 UTC (rev 
20694)
@@ -1085,16 +1085,16 @@
 /* Large integer version. */
 struct timespec nt_time_to_unix_timespec(NTTIME *nt)
 {
-       uint64 d;
+       int64 d;
        struct timespec ret;
 
-       if (*nt == 0 || *nt == (uint64)-1) {
+       if (*nt == 0 || *nt == (int64)-1) {
                ret.tv_sec = 0;
                ret.tv_nsec = 0;
                return ret;
        }
 
-       d = *nt;
+       d = (int64)*nt;
        /* d is now in 100ns units, since jan 1st 1601".
           Save off the ns fraction. */
        
@@ -1106,20 +1106,20 @@
        /* Now adjust by 369 years to make the secs since 1970 */
        d -= TIME_FIXUP_CONSTANT_INT;
 
-       if (((time_t)d) <= TIME_T_MIN) {
+       if (d <= (int64)TIME_T_MIN) {
                ret.tv_sec = TIME_T_MIN;
                ret.tv_nsec = 0;
                return ret;
        }
 
-       if (d >= (uint64)TIME_T_MAX) {
+       if (d >= (int64)TIME_T_MAX) {
                ret.tv_sec = TIME_T_MAX;
                ret.tv_nsec = 0;
                return ret;
        }
 
        ret.tv_sec = (time_t)d;
-    return ret;
+       return ret;
 }
 /****************************************************************************
  Check if two NTTIMEs are the same.
@@ -1238,7 +1238,7 @@
 
  This is an absolute version of the one above.
  By absolute I mean, it doesn't adjust from 1/1/1970 to 1/1/1601
- If the nttime_t was 5 seconds, the NTTIME is 5 seconds. JFM
+ If the time_t was 5 seconds, the NTTIME is 5 seconds. JFM
 ****************************************************************************/
 
 void unix_to_nt_time_abs(NTTIME *nt, time_t t)

Modified: branches/SAMBA_3_0_24/source/lib/time.c
===================================================================
--- branches/SAMBA_3_0_24/source/lib/time.c     2007-01-12 02:33:09 UTC (rev 
20693)
+++ branches/SAMBA_3_0_24/source/lib/time.c     2007-01-12 02:48:37 UTC (rev 
20694)
@@ -1085,16 +1085,16 @@
 /* Large integer version. */
 struct timespec nt_time_to_unix_timespec(NTTIME *nt)
 {
-       uint64 d;
+       int64 d;
        struct timespec ret;
 
-       if (*nt == 0 || *nt == (uint64)-1) {
+       if (*nt == 0 || *nt == (int64)-1) {
                ret.tv_sec = 0;
                ret.tv_nsec = 0;
                return ret;
        }
 
-       d = *nt;
+       d = (int64)*nt;
        /* d is now in 100ns units, since jan 1st 1601".
           Save off the ns fraction. */
        
@@ -1106,20 +1106,20 @@
        /* Now adjust by 369 years to make the secs since 1970 */
        d -= TIME_FIXUP_CONSTANT_INT;
 
-       if (((time_t)d) <= TIME_T_MIN) {
+       if (d <= (int64)TIME_T_MIN) {
                ret.tv_sec = TIME_T_MIN;
                ret.tv_nsec = 0;
                return ret;
        }
 
-       if (d >= (uint64)TIME_T_MAX) {
+       if (d >= (int64)TIME_T_MAX) {
                ret.tv_sec = TIME_T_MAX;
                ret.tv_nsec = 0;
                return ret;
        }
 
        ret.tv_sec = (time_t)d;
-    return ret;
+       return ret;
 }
 /****************************************************************************
  Check if two NTTIMEs are the same.
@@ -1238,7 +1238,7 @@
 
  This is an absolute version of the one above.
  By absolute I mean, it doesn't adjust from 1/1/1970 to 1/1/1601
- If the nttime_t was 5 seconds, the NTTIME is 5 seconds. JFM
+ If the time_t was 5 seconds, the NTTIME is 5 seconds. JFM
 ****************************************************************************/
 
 void unix_to_nt_time_abs(NTTIME *nt, time_t t)

Reply via email to