* buffer.h (BUF_BYTES_MAX): Cast to ptrdiff_t so that it's signed.
authorPaul Eggert <eggert@cs.ucla.edu>
Thu, 16 Jun 2011 06:19:26 +0000 (23:19 -0700)
committerPaul Eggert <eggert@cs.ucla.edu>
Thu, 16 Jun 2011 06:19:26 +0000 (23:19 -0700)
src/ChangeLog
src/buffer.h

index 59fb2d8..ed94ce5 100644 (file)
@@ -1,3 +1,7 @@
+2011-06-16  Paul Eggert  <eggert@cs.ucla.edu>
+
+       * buffer.h (BUF_BYTES_MAX): Cast to ptrdiff_t so that it's signed.
+
 2011-06-15  Paul Eggert  <eggert@cs.ucla.edu>
 
        Integer overflow and signedness fixes (Bug#8873).
index dc1d62b..a13351b 100644 (file)
@@ -309,8 +309,10 @@ while (0)
 
 /* Maximum number of bytes in a buffer.
    A buffer cannot contain more bytes than a 1-origin fixnum can represent,
-   nor can it be so large that C pointer arithmetic stops working.  */
-#define BUF_BYTES_MAX min (MOST_POSITIVE_FIXNUM - 1, min (SIZE_MAX, PTRDIFF_MAX))
+   nor can it be so large that C pointer arithmetic stops working.
+   The ptrdiff_t cast ensures that this is signed, not unsigned.  */
+#define BUF_BYTES_MAX \
+  (ptrdiff_t) min (MOST_POSITIVE_FIXNUM - 1, min (SIZE_MAX, PTRDIFF_MAX))
 
 /* Return the address of byte position N in current buffer.  */