diff options
author | Carsten Haitzler (Rasterman) <raster@rasterman.com> | 2017-07-29 13:49:33 +0900 |
---|---|---|
committer | Carsten Haitzler (Rasterman) <raster@rasterman.com> | 2017-07-29 13:49:33 +0900 |
commit | 2b91a48d72071e195b691156a5755cb7e76fdc37 (patch) | |
tree | 7f10cb23ddd5ae1a31e368a28217ef43bf2aa620 | |
parent | 29eebb44fc6df0ed50ebba929b22e0ee0483dab0 (diff) | |
download | efl-2b91a48d72071e195b691156a5755cb7e76fdc37.tar.gz |
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
-rw-r--r-- | src/lib/ector/software/ector_software_gradient.c | 7 |
1 files changed, 5 insertions, 2 deletions
diff --git a/src/lib/ector/software/ector_software_gradient.c b/src/lib/ector/software/ector_software_gradient.c index 55636b4237..bdbf70380c 100644 --- a/src/lib/ector/software/ector_software_gradient.c +++ b/src/lib/ector/software/ector_software_gradient.c @@ -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); |