aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorPaul Eggert2016-06-08 00:35:11 -0700
committerPaul Eggert2016-06-08 00:36:18 -0700
commite8ba94bf83515a64523532cc2942033ef0364301 (patch)
tree3d37b07d25b40c591e6f4a9c60b3b84787acc041 /src
parent378f5776fce0b4d6df95aa65be2ef6276e7bc610 (diff)
downloademacs-e8ba94bf83515a64523532cc2942033ef0364301.tar.gz
emacs-e8ba94bf83515a64523532cc2942033ef0364301.zip
Simplify overflow check via INT_SUBTRACT_WRAPV
* src/editfns.c (check_tm_member): Simplify integer overflow check.
Diffstat (limited to 'src')
-rw-r--r--src/editfns.c11
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) */)
2176} 2176}
2177 2177
2178/* Return OBJ - OFFSET, checking that OBJ is a valid fixnum and that 2178/* Return OBJ - OFFSET, checking that OBJ is a valid fixnum and that
2179 the result is representable as an int. Assume OFFSET is small and 2179 the result is representable as an int. */
2180 nonnegative. */
2181static int 2180static int
2182check_tm_member (Lisp_Object obj, int offset) 2181check_tm_member (Lisp_Object obj, int offset)
2183{ 2182{
2184 EMACS_INT n;
2185 CHECK_NUMBER (obj); 2183 CHECK_NUMBER (obj);
2186 n = XINT (obj); 2184 EMACS_INT n = XINT (obj);
2187 if (! (INT_MIN + offset <= n && n - offset <= INT_MAX)) 2185 int result;
2186 if (INT_SUBTRACT_WRAPV (n, offset, &result))
2188 time_overflow (); 2187 time_overflow ();
2189 return n - offset; 2188 return result;
2190} 2189}
2191 2190
2192DEFUN ("encode-time", Fencode_time, Sencode_time, 6, MANY, 0, 2191DEFUN ("encode-time", Fencode_time, Sencode_time, 6, MANY, 0,