From: Paul Eggert Date: Thu, 16 Jun 2011 06:19:26 +0000 (-0700) Subject: * buffer.h (BUF_BYTES_MAX): Cast to ptrdiff_t so that it's signed. X-Git-Tag: emacs-pretest-24.0.90~104^2~538^2~6 X-Git-Url: http://git.eshelyaron.com/gitweb/?a=commitdiff_plain;h=28177adde9132702ed05b411a12c95f05dc2ba89;p=emacs.git * buffer.h (BUF_BYTES_MAX): Cast to ptrdiff_t so that it's signed. --- diff --git a/src/ChangeLog b/src/ChangeLog index 59fb2d89b24..ed94ce5599c 100644 --- a/src/ChangeLog +++ b/src/ChangeLog @@ -1,3 +1,7 @@ +2011-06-16 Paul Eggert + + * buffer.h (BUF_BYTES_MAX): Cast to ptrdiff_t so that it's signed. + 2011-06-15 Paul Eggert Integer overflow and signedness fixes (Bug#8873). diff --git a/src/buffer.h b/src/buffer.h index dc1d62beb00..a13351b5ea6 100644 --- a/src/buffer.h +++ b/src/buffer.h @@ -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. */