diff options
author | Paul Eggert <eggert@cs.ucla.edu> | 2016-06-08 00:35:11 -0700 |
---|---|---|
committer | Paul Eggert <eggert@cs.ucla.edu> | 2016-06-08 00:36:18 -0700 |
commit | e8ba94bf83515a64523532cc2942033ef0364301 (patch) | |
tree | 3d37b07d25b40c591e6f4a9c60b3b84787acc041 /src/editfns.c | |
parent | 378f5776fce0b4d6df95aa65be2ef6276e7bc610 (diff) | |
download | emacs-e8ba94bf83515a64523532cc2942033ef0364301.tar.gz |
Simplify overflow check via INT_SUBTRACT_WRAPV
* src/editfns.c (check_tm_member): Simplify integer overflow check.
Diffstat (limited to 'src/editfns.c')
-rw-r--r-- | src/editfns.c | 11 |
1 files changed, 5 insertions, 6 deletions
diff --git a/src/editfns.c b/src/editfns.c index 6b0996d65eb..81c30d30d62 100644 --- a/src/editfns.c +++ b/src/editfns.c @@ -2176,17 +2176,16 @@ usage: (decode-time &optional TIME ZONE) */) } /* Return OBJ - OFFSET, checking that OBJ is a valid fixnum and that - the result is representable as an int. Assume OFFSET is small and - nonnegative. */ + the result is representable as an int. */ static int check_tm_member (Lisp_Object obj, int offset) { - EMACS_INT n; CHECK_NUMBER (obj); - n = XINT (obj); - if (! (INT_MIN + offset <= n && n - offset <= INT_MAX)) + EMACS_INT n = XINT (obj); + int result; + if (INT_SUBTRACT_WRAPV (n, offset, &result)) time_overflow (); - return n - offset; + return result; } DEFUN ("encode-time", Fencode_time, Sencode_time, 6, MANY, 0, |