You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Getting a warning caused by comparison of different data types
Your workbench
STM32
LoRa ST (EU868
Wired via I2C
The power supply is 3V3
I'm using PlatformIO
Output warning:
.pio\libdeps\disco_l072cz_lrwan1\SparkFun External EEPROM Arduino Library\src\SparkFun_External_EEPROM.cpp: In member function 'void ExternalEEPROM::read(uint32_t, uint8_t*, uint16_t)':
.pio\libdeps\disco_l072cz_lrwan1\SparkFun External EEPROM Arduino Library\src\SparkFun_External_EEPROM.cpp:159:50: warning: comparison of integer expressions of different signedness: 'long unsigned int' and 'int' [-Wsign-compare]
159 | if (0xFFFF - (eepromLocation + received) < amtToRead) //0xFFFF - 0xFFFA < 32
| ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^~~~~~~~~~~
Steps to reproduce
The datatype of amtToRead can be set to uint16_t since the var is initialized with bufferSize-received where bufferSize also is a uint16_t and substracted by another value. So amtToRead could never get bigger then uint16_t
Expected behavior
In file SparkFun_External_EEPROM.cpp in line 148 change the data type from int to uint16_t.
Actual behavior
In case the amtToRead var becomes negative, there is an overflow and an unintended behavior could happen.
The text was updated successfully, but these errors were encountered:
Subject of the issue
Getting a warning caused by comparison of different data types
Your workbench
Output warning:
Steps to reproduce
The datatype of
amtToRead
can be set touint16_t
since the var is initialized withbufferSize-received
where bufferSize also is a uint16_t and substracted by another value. So amtToRead could never get bigger then uint16_tExpected behavior
In file
SparkFun_External_EEPROM.cpp
in line 148 change the data type fromint
touint16_t
.Actual behavior
In case the amtToRead var becomes negative, there is an overflow and an unintended behavior could happen.
The text was updated successfully, but these errors were encountered: