From: Paul Eggert Date: Thu, 7 Jul 2011 17:51:05 +0000 (-0700) Subject: * buffer.c: Integer signedness fixes. X-Git-Tag: emacs-pretest-24.0.90~104^2~152^2~172 X-Git-Url: http://git.eshelyaron.com/gitweb/?a=commitdiff_plain;h=fd05c7e9aae3cc636a7e13487dc50010084adae8;p=emacs.git * buffer.c: Integer signedness fixes. (alloc_buffer_text, enlarge_buffer_text): Use ptrdiff_t rather than size_t when either will do, as we prefer signed integers. --- diff --git a/src/ChangeLog b/src/ChangeLog index a6cafedb36c..6d8ee7d5306 100644 --- a/src/ChangeLog +++ b/src/ChangeLog @@ -1,5 +1,10 @@ 2011-07-07 Paul Eggert + * buffer.c: Integer signedness fixes. + (alloc_buffer_text, enlarge_buffer_text): + Use ptrdiff_t rather than size_t when either will do, as we prefer + signed integers. + * bidi.c: Integer signedness and overflow fixes. (bidi_cache_idx, bidi_cache_last_idx, bidi_cache_fetch_state) (bidi_cache_search, bidi_cache_find_level_change) diff --git a/src/buffer.c b/src/buffer.c index e2f34d629e9..48dde18b02c 100644 --- a/src/buffer.c +++ b/src/buffer.c @@ -152,7 +152,7 @@ Lisp_Object Qmodification_hooks; Lisp_Object Qinsert_in_front_hooks; Lisp_Object Qinsert_behind_hooks; -static void alloc_buffer_text (struct buffer *, size_t); +static void alloc_buffer_text (struct buffer *, ptrdiff_t); static void free_buffer_text (struct buffer *b); static struct Lisp_Overlay * copy_overlays (struct buffer *, struct Lisp_Overlay *); static void modify_overlay (struct buffer *, EMACS_INT, EMACS_INT); @@ -4816,7 +4816,7 @@ extern void r_alloc_free (POINTER_TYPE **ptr); /* Allocate NBYTES bytes for buffer B's text buffer. */ static void -alloc_buffer_text (struct buffer *b, size_t nbytes) +alloc_buffer_text (struct buffer *b, ptrdiff_t nbytes) { POINTER_TYPE *p; @@ -4846,8 +4846,8 @@ void enlarge_buffer_text (struct buffer *b, EMACS_INT delta) { POINTER_TYPE *p; - size_t nbytes = (BUF_Z_BYTE (b) - BUF_BEG_BYTE (b) + BUF_GAP_SIZE (b) + 1 - + delta); + ptrdiff_t nbytes = (BUF_Z_BYTE (b) - BUF_BEG_BYTE (b) + BUF_GAP_SIZE (b) + 1 + + delta); BLOCK_INPUT; #if defined USE_MMAP_FOR_BUFFERS p = mmap_realloc ((POINTER_TYPE **) &b->text->beg, nbytes);