]> git.eshelyaron.com Git - emacs.git/commit
In timefns.c avoid by-hand overflow checking
authorPaul Eggert <eggert@cs.ucla.edu>
Thu, 11 Jul 2024 10:57:01 +0000 (12:57 +0200)
committerEshel Yaron <me@eshelyaron.com>
Thu, 11 Jul 2024 14:39:51 +0000 (16:39 +0200)
commit2861bbf7c00f1f314def10ef4a000df7131b3ab2
tree97c8f7134b773587dade42b31cb3c55dffd72c15
parent2d1f5de16ef6c0be14355f294326d98c6fb6348b
In timefns.c avoid by-hand overflow checking

Prefer functions like ckd_add to do overflow checking, instead of
doing it by hand, to simplify and I hope to make things a bit less
error prone.
* src/timefns.c (TIME_T_MIN, TIME_T_MAX): Remove.  All by-hand
overflow checking replaced with calls to ckd_add or ckd_mul.
(s_ns_to_timespec): New static function, that uses ckd_add
instead of by-hand overflow checking.
(ticks_hz_to_timespec): Use it.
(check_tm_member): Use mpz_fits_sint_p and mpz_get_si rather
than mpz_to_intmax and by-hand overflow checking.

(cherry picked from commit 75f53d7c2c1f6706d1d4c1f3eed3aa675464c62f)
src/timefns.c