warning: comparison is always false due to limited range of data type
birkler opened this issue · comments
Jorgen Birkler commented
E.g. gainEE is declared int8_t so it cannot hold values more than 127.
./mlx90640-library/functions/MLX90640_API.cpp: In function ‘void ExtractGainParameters(uint16_t*, paramsMLX90640*)’:
./mlx90640-library/functions/MLX90640_API.cpp:863:15: warning: comparison is always false due to limited range of data type [-Wtype-limits]
863 | if(gainEE > 32767)
| ~~~~~~~^~~~~~~
./mlx90640-library/functions/MLX90640_API.cpp: In function ‘void ExtractOffsetParameters(uint16_t*, paramsMLX90640*)’:
./mlx90640-library/functions/MLX90640_API.cpp:1067:19: warning: comparison is always false due to limited range of data type [-Wtype-limits]
1067 | if (offsetRef > 32767)
| ~~~~~~~~~~^~~~~~~
./mlx90640-library/functions/MLX90640_API.cpp: In function ‘void ExtractKtaPixelParameters(uint16_t*, paramsMLX90640*)’:
./mlx90640-library/functions/MLX90640_API.cpp:1139:17: warning: comparison is always false due to limited range of data type [-Wtype-limits]
1139 | if (KtaRoCo > 127)
| ~~~~~~~~^~~~~
./mlx90640-library/functions/MLX90640_API.cpp:1146:17: warning: comparison is always false due to limited range of data type [-Wtype-limits]
1146 | if (KtaReCo > 127)
| ~~~~~~~~^~~~~
./mlx90640-library/functions/MLX90640_API.cpp:1153:17: warning: comparison is always false due to limited range of data type [-Wtype-limits]
1153 | if (KtaRoCe > 127)
| ~~~~~~~~^~~~~
./mlx90640-library/functions/MLX90640_API.cpp:1160:17: warning: comparison is always false due to limited range of data type [-Wtype-limits]
1160 | if (KtaReCe > 127)
| ~~~~~~~~^~~~~
aksdfauytv commented
Also, the expression inside doesn't make sense: KtaRoCo = KtaRoCo - 256;
will do nothing, since KtaRoCo is only 8 bits wide. Same goes for all the others. Did you mean to invert the value? KtaRoCo = 256 - KtaRoCo;
Since KtaRoCo (and others) are signed, you can just do if (KtaRoCo < 0)