Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

warning: comparison is always false due to limited range of data type #98

Open
birkler opened this issue Oct 4, 2022 · 1 comment
Open

Comments

@birkler
Copy link

birkler commented Oct 4, 2022

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
Copy link

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)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants