* buffer.h (struct buffer): Use time_t, not int, for a time stamp.
authorPaul Eggert <eggert@cs.ucla.edu>
Fri, 30 Sep 2011 20:22:01 +0000 (13:22 -0700)
committerPaul Eggert <eggert@cs.ucla.edu>
Fri, 30 Sep 2011 20:22:01 +0000 (13:22 -0700)
This fixes a Y2038 bug on 64-bit hosts.
* buffer.c (reset_buffer):
* fileio.c (Fdo_auto_save, Fset_buffer_auto_saved)
(Fclear_buffer_auto_save_failure):
Use 0, not -1, to represent an unset failure time, since time_t
might not be signed.

src/ChangeLog
src/buffer.c
src/buffer.h
src/fileio.c

index 89e705e..238e3fa 100644 (file)
@@ -1,5 +1,13 @@
 2011-09-30  Paul Eggert  <eggert@cs.ucla.edu>
 
+       * buffer.h (struct buffer): Use time_t, not int, for a time stamp.
+       This fixes a Y2038 bug on 64-bit hosts.
+       * buffer.c (reset_buffer):
+       * fileio.c (Fdo_auto_save, Fset_buffer_auto_saved)
+       (Fclear_buffer_auto_save_failure):
+       Use 0, not -1, to represent an unset failure time, since time_t
+       might not be signed.
+
        Remove dependency on glibc malloc internals.
        * alloc.c (XMALLOC_OVERRUN_CHECK_OVERHEAD, XMALLOC_OVERRUN_CHECK_SIZE):
        Move back here from lisp.h, but with their new implementations.
index dffdeb5..f38c9a7 100644 (file)
@@ -724,7 +724,7 @@ reset_buffer (register struct buffer *b)
   b->prevent_redisplay_optimizations_p = 1;
   BVAR (b, backed_up) = Qnil;
   BUF_AUTOSAVE_MODIFF (b) = 0;
-  b->auto_save_failure_time = -1;
+  b->auto_save_failure_time = 0;
   BVAR (b, auto_save_file_name) = Qnil;
   BVAR (b, read_only) = Qnil;
   b->overlays_before = NULL;
index 73628fe..a6b82ab 100644 (file)
@@ -566,8 +566,8 @@ struct buffer
      Redisplay of this buffer is inhibited until it changes again.  */
   int display_error_modiff;
   /* The time at which we detected a failure to auto-save,
-     Or -1 if we didn't have a failure.  */
-  int auto_save_failure_time;
+     Or 0 if we didn't have a failure.  */
+  time_t auto_save_failure_time;
   /* Position in buffer at which display started
      the last time this buffer was displayed.  */
   EMACS_INT last_window_start;
index e335dcf..44a85ab 100644 (file)
@@ -5344,7 +5344,7 @@ A non-nil CURRENT-ONLY argument means save only current buffer.  */)
            EMACS_GET_TIME (before_time);
 
            /* If we had a failure, don't try again for 20 minutes.  */
-           if (b->auto_save_failure_time >= 0
+           if (b->auto_save_failure_time > 0
                && EMACS_SECS (before_time) - b->auto_save_failure_time < 1200)
              continue;
 
@@ -5423,7 +5423,7 @@ No auto-save file will be written until the buffer changes again.  */)
      they're not autosaved.  */
   BUF_AUTOSAVE_MODIFF (current_buffer) = MODIFF;
   XSETFASTINT (BVAR (current_buffer, save_length), Z - BEG);
-  current_buffer->auto_save_failure_time = -1;
+  current_buffer->auto_save_failure_time = 0;
   return Qnil;
 }
 
@@ -5432,7 +5432,7 @@ DEFUN ("clear-buffer-auto-save-failure", Fclear_buffer_auto_save_failure,
        doc: /* Clear any record of a recent auto-save failure in the current buffer.  */)
   (void)
 {
-  current_buffer->auto_save_failure_time = -1;
+  current_buffer->auto_save_failure_time = 0;
   return Qnil;
 }