summaryrefslogtreecommitdiff
path: root/src/lib/ector/software/ector_software_gradient.c
diff options
context:
space:
mode:
authorCarsten Haitzler (Rasterman) <raster@rasterman.com>2017-07-29 13:49:33 +0900
committerCarsten Haitzler (Rasterman) <raster@rasterman.com>2017-07-29 13:49:33 +0900
commit2b91a48d72071e195b691156a5755cb7e76fdc37 (patch)
tree7f10cb23ddd5ae1a31e368a28217ef43bf2aa620 /src/lib/ector/software/ector_software_gradient.c
parent29eebb44fc6df0ed50ebba929b22e0ee0483dab0 (diff)
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
Diffstat (limited to 'src/lib/ector/software/ector_software_gradient.c')
-rw-r--r--src/lib/ector/software/ector_software_gradient.c7
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
408 } 408 }
409 else 409 else
410 { 410 {
411 if (t + inc*length < (float)(INT_MAX >> (FIXPT_BITS + 1)) && 411 const int vmax = INT_MAX >> (FIXPT_BITS + 1);
412 t+inc*length > (float)(INT_MIN >> (FIXPT_BITS + 1))) 412 const int vmin = -vmin;
413 float v = t + (inc *length);
414
415 if ((v < (float)vmax) && (v > (float)(vmin)))
413 { 416 {
414 // we can use fixed point math 417 // we can use fixed point math
415 t_fixed = (int)(t * FIXPT_SIZE); 418 t_fixed = (int)(t * FIXPT_SIZE);