Add CRC32c comparison values to the logs when the check fails
Problem to solve
Currently when the CRC32c verification fails we do not print any information related to the values we tried to compare. Printing them could be useful for debugging as the only way around that is to attach gdb.
//-----------------------------------------------------------------------------
// verifyCrc32cForMemoryBlockWithCrc32c
//-----------------------------------------------------------------------------
bool verifyCrc32cForMemoryBlockWithCrc32c(
const uint32_t crcInit, const uint32_t cnt, const uint8_t *start) {
if (cnt <= 4)
return false; //block is too small to be valid, cannot check CRC
const uint32_t crccmp = crc32c(crcInit, cnt-4, start);
const uint32_t crcblk= (start[cnt-4] << 0) |
(start[cnt-3] << 8) |
(start[cnt-2] << 16) |
(start[cnt-1] << 24);
if (crccmp != crcblk){
return false; //block CRC is incorrect
}
return true;
}
Stakeholders
- CTA Dev team
Proposal
Include in the logging information the values that we failed to compare, the one that came along with the data and the computed one.
Edited by Pablo Oliver Cortes