ector software - fix min/max int range for fixedpoint math

min value bitshifts are negative and thus not portable. just tax max
(as its 1 more than min it if we do -max) as the limit as its within
range. this should fix it

@fix

found by PVS studio
This commit is contained in:
Carsten Haitzler 2017-07-29 13:49:33 +09:00
parent 29eebb44fc
commit 2b91a48d72
1 changed files with 5 additions and 2 deletions

View File

@ -408,8 +408,11 @@ fetch_linear_gradient(uint32_t *buffer, Span_Data *data, int y, int x, int lengt
}
else
{
if (t + inc*length < (float)(INT_MAX >> (FIXPT_BITS + 1)) &&
t+inc*length > (float)(INT_MIN >> (FIXPT_BITS + 1)))
const int vmax = INT_MAX >> (FIXPT_BITS + 1);
const int vmin = -vmin;
float v = t + (inc *length);
if ((v < (float)vmax) && (v > (float)(vmin)))
{
// we can use fixed point math
t_fixed = (int)(t * FIXPT_SIZE);