mirror of
https://github.com/portapack-mayhem/mayhem-firmware.git
synced 2024-12-04 23:45:26 +00:00
fix out of range warning (#2299)
This commit is contained in:
parent
a223bd1f21
commit
26b830b816
@ -69,8 +69,22 @@ std::vector<uint8_t> I2cDev_PPmod::downloadStandaloneApp(uint32_t index, size_t
|
||||
return {};
|
||||
}
|
||||
|
||||
uint16_t data[3] = {(uint16_t)Command::COMMAND_APP_TRANSFER, (uint16_t)index, (uint16_t)(offset / transfer_block_size)};
|
||||
uint16_t data[3] = {
|
||||
static_cast<uint16_t>(Command::COMMAND_APP_TRANSFER),
|
||||
static_cast<uint16_t>(index & 0xFFFF), // keep index in 16 bits range
|
||||
static_cast<uint16_t>((offset / transfer_block_size) & 0xFFFF) // keep (offset / transfer_block_size) in 16 bits range
|
||||
};
|
||||
|
||||
/*
|
||||
// TODO: check if there was an out of range, manage error
|
||||
if (index > std::numeric_limits<uint16_t>::max()) {
|
||||
// manage error if index is bigger than a 16 bits value
|
||||
}
|
||||
// TODO: check if there was an out of range, manage error
|
||||
if (offset / transfer_block_size > std::numeric_limits<uint16_t>::max()) {
|
||||
// manage error if (offset / transfer_block_size ) is bigger than a 16 bits value
|
||||
}
|
||||
*/
|
||||
std::vector<uint8_t> ret(transfer_block_size);
|
||||
bool success = i2c_read((uint8_t*)&data, sizeof(data), (uint8_t*)ret.data(), transfer_block_size);
|
||||
if (success == false) {
|
||||
|
Loading…
Reference in New Issue
Block a user