r20694: To get this right we need to do signed 64-bit
authorJeremy Allison <jra@samba.org>
Fri, 12 Jan 2007 02:48:37 +0000 (02:48 +0000)
committerGerald (Jerry) Carter <jerry@samba.org>
Wed, 10 Oct 2007 17:17:03 +0000 (12:17 -0500)
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.

source/lib/time.c

index 762c775ea2ccf7a195c2f481de4c62e7b992d9cb..e211bda3fb1fd41cd3fc6253f591bcb1146730a4 100644 (file)
@@ -1085,16 +1085,16 @@ time_t cli_make_unix_date3(struct cli_state *cli, void *date_ptr)
 /* 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 @@ struct timespec nt_time_to_unix_timespec(NTTIME *nt)
        /* 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 @@ void unix_timespec_to_nt_time(NTTIME *nt, struct timespec ts)
 
  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)