From b3e1b382456b0f7d108c57d6f902bbddfdd97b2a Mon Sep 17 00:00:00 2001 From: Paul Eggert Date: Sat, 24 Sep 2016 02:35:13 -0700 Subject: Improve integer overflow handling a bit * src/charset.c (read_hex): Use INT_LEFT_SHIFT_OVERFLOW for clarity. The machine code is the same on my platform. * src/doprnt.c (doprnt): * src/emacs-module.c (module_funcall): * src/font.c (font_intern_prop): * src/keyboard.c (Frecursion_depth): * src/lread.c (read1): Use WRAPV macros instead of checking overflow by hand. * src/editfns.c (hi_time, time_arith, decode_time_components): * src/emacs-module.c (Fmodule_load): Simplify by using FIXNUM_OVERFLOW_P. * src/emacs-module.c: Include intprops.h. * src/xdisp.c (percent99): New function. (decode_mode_spec): Use it to simplify overflow avoidance and formatting of %p and %P. --- src/charset.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src/charset.c') diff --git a/src/charset.c b/src/charset.c index 0c831f13591..cdbfe119515 100644 --- a/src/charset.c +++ b/src/charset.c @@ -435,7 +435,7 @@ read_hex (FILE *fp, bool *eof, bool *overflow) n = 0; while (c_isxdigit (c = getc (fp))) { - if (UINT_MAX >> 4 < n) + if (INT_LEFT_SHIFT_OVERFLOW (n, 4)) *overflow = 1; n = ((n << 4) | (c - ('0' <= c && c <= '9' ? '0' -- cgit v1.2.3