From 28177adde9132702ed05b411a12c95f05dc2ba89 Mon Sep 17 00:00:00 2001 From: Paul Eggert Date: Wed, 15 Jun 2011 23:19:26 -0700 Subject: [PATCH] * buffer.h (BUF_BYTES_MAX): Cast to ptrdiff_t so that it's signed. --- src/ChangeLog | 4 ++++ src/buffer.h | 6 ++++-- 2 files changed, 8 insertions(+), 2 deletions(-) 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. */ -- 2.39.5