diff options
author | truckman <truckman@FreeBSD.org> | 2017-05-25 17:22:13 +0000 |
---|---|---|
committer | truckman <truckman@FreeBSD.org> | 2017-05-25 17:22:13 +0000 |
commit | 61ad262512e302f69f713f8f13a6fff42dd917c7 (patch) | |
tree | a1712e6200cd6b3ed9949882eb7d40e00eb6bfab /lib/libc/sys/open.2 | |
parent | ea8decded162c663e1a10d48adb2bf74c2f6c811 (diff) | |
download | FreeBSD-src-61ad262512e302f69f713f8f13a6fff42dd917c7.zip FreeBSD-src-61ad262512e302f69f713f8f13a6fff42dd917c7.tar.gz |
MFC r318511
The result of right shifting a negative signed value is implementation
defined. On machines without arithmetic shift instructions, zero bits
may be shifted in from the left, giving a large positive result instead
of the desired divide-by power-of-2. Fix this by operating on the
absolute value and compensating for the possible negation later.
Reverse the order of the underflow/overflow tests and the exponential
decay calculation to avoid the possibility of an erroneous overflow
detection if p is a sufficiently small non-negative value. Also
check for negative values of prob before doing the exponential decay
to avoid another instance of of right shifting a negative value.
Tested by: Rasool Al-Saadi <ralsaadi@swin.edu.au>
Diffstat (limited to 'lib/libc/sys/open.2')
0 files changed, 0 insertions, 0 deletions