From ffa8c828c6c76d3c246443a6752f1038eab60413 Mon Sep 17 00:00:00 2001 From: Paul Eggert Date: Sat, 26 Mar 2011 19:20:34 -0700 Subject: [PATCH] * keyboard.c, keyboard.h (num_input_events): Now size_t. This avoids undefined behavior on integer overflow, and is a bit more convenient anyway since it is compared to a size_t variable. --- src/ChangeLog | 4 ++++ src/keyboard.c | 4 ++-- src/keyboard.h | 4 ++-- 3 files changed, 8 insertions(+), 4 deletions(-) diff --git a/src/ChangeLog b/src/ChangeLog index 32f64893ae6..93c43b85184 100644 --- a/src/ChangeLog +++ b/src/ChangeLog @@ -1,5 +1,9 @@ 2011-03-27 Paul Eggert + * keyboard.c, keyboard.h (num_input_events): Now size_t. + This avoids undefined behavior on integer overflow, and is a bit + more convenient anyway since it is compared to a size_t variable. + Variadic C functions now count arguments with size_t, not int. This avoids an unnecessary limitation on 64-bit machines, which caused (substring ...) to crash on large vectors (Bug#8344). diff --git a/src/keyboard.c b/src/keyboard.c index c4ef2795f6a..09a0010cedc 100644 --- a/src/keyboard.c +++ b/src/keyboard.c @@ -201,8 +201,8 @@ Lisp_Object unread_switch_frame; /* Last size recorded for a current buffer which is not a minibuffer. */ static EMACS_INT last_non_minibuf_size; -/* Total number of times read_char has returned. */ -int num_input_events; +/* Total number of times read_char has returned, modulo SIZE_MAX + 1. */ +size_t num_input_events; /* Value of num_nonmacro_input_events as of last auto save. */ diff --git a/src/keyboard.h b/src/keyboard.h index ba3c909c4dd..31215199f14 100644 --- a/src/keyboard.h +++ b/src/keyboard.h @@ -194,8 +194,8 @@ extern KBOARD *all_kboards; /* Nonzero in the single-kboard state, 0 in the any-kboard state. */ extern int single_kboard; -/* Total number of times read_char has returned. */ -extern int num_input_events; +/* Total number of times read_char has returned, modulo SIZE_MAX + 1. */ +extern size_t num_input_events; /* Nonzero means polling for input is temporarily suppressed. */ extern int poll_suppress_count; -- 2.39.5