Rework overflow checks of r247898 to not let too "intelligent" compiler to
optimize it out. Submitted by: bde
This commit is contained in:
parent
b3420862a7
commit
21a37a7196
Notes:
svn2git
2020-12-20 02:59:44 +00:00
svn path=/head/; revision=248092
@ -1329,12 +1329,13 @@ kqueue_scan(struct kqueue *kq, int maxevents, struct kevent_copyops *k_ops,
|
||||
goto done_nl;
|
||||
}
|
||||
if (timespecisset(tsp)) {
|
||||
if (tsp->tv_sec < INT32_MAX) {
|
||||
if (tsp->tv_sec <= INT32_MAX) {
|
||||
rsbt = tstosbt(*tsp);
|
||||
if (TIMESEL(&asbt, rsbt))
|
||||
asbt += tc_tick_sbt;
|
||||
asbt += rsbt;
|
||||
if (asbt < rsbt)
|
||||
if (asbt <= INT64_MAX - rsbt)
|
||||
asbt += rsbt;
|
||||
else
|
||||
asbt = 0;
|
||||
rsbt >>= tc_precexp;
|
||||
} else
|
||||
|
@ -1051,16 +1051,17 @@ kern_select(struct thread *td, int nd, fd_set *fd_in, fd_set *fd_ou,
|
||||
error = EINVAL;
|
||||
goto done;
|
||||
}
|
||||
if (rtv.tv_sec == 0 && rtv.tv_usec == 0)
|
||||
if (!timevalisset(&rtv))
|
||||
asbt = 0;
|
||||
else if (rtv.tv_sec < INT32_MAX) {
|
||||
else if (rtv.tv_sec <= INT32_MAX) {
|
||||
rsbt = tvtosbt(rtv);
|
||||
precision = rsbt;
|
||||
precision >>= tc_precexp;
|
||||
if (TIMESEL(&asbt, rsbt))
|
||||
asbt += tc_tick_sbt;
|
||||
asbt += rsbt;
|
||||
if (asbt < rsbt)
|
||||
if (asbt <= INT64_MAX - rsbt)
|
||||
asbt += rsbt;
|
||||
else
|
||||
asbt = -1;
|
||||
} else
|
||||
asbt = -1;
|
||||
|
Loading…
Reference in New Issue
Block a user