AP_FlashStorage: correct format-string warnings

This commit is contained in:
Peter Barker 2019-10-28 16:22:17 +11:00 committed by Andrew Tridgell
parent a4a1536614
commit f5635a557a
1 changed files with 11 additions and 3 deletions

View File

@ -56,7 +56,9 @@ bool FlashTest::flash_write(uint8_t sector, uint32_t offset, const uint8_t *data
uint8_t *b = &flash[sector][offset]; uint8_t *b = &flash[sector][offset];
if ((offset & 1) || (length & 1)) { if ((offset & 1) || (length & 1)) {
AP_HAL::panic("FATAL: invalid write at %u:%u len=%u\n", AP_HAL::panic("FATAL: invalid write at %u:%u len=%u\n",
sector, offset, length); (unsigned)sector,
(unsigned)offset,
(unsigned)length);
} }
const uint16_t *data16 = (const uint16_t *)data; const uint16_t *data16 = (const uint16_t *)data;
uint16_t *b16 = (uint16_t *)&b[0]; uint16_t *b16 = (uint16_t *)&b[0];
@ -64,12 +66,18 @@ bool FlashTest::flash_write(uint8_t sector, uint32_t offset, const uint8_t *data
for (uint16_t i=0; i<len16; i++) { for (uint16_t i=0; i<len16; i++) {
if (data16[i] & !b16[i]) { if (data16[i] & !b16[i]) {
AP_HAL::panic("FATAL: invalid write16 at %u:%u 0x%04x 0x%04x\n", AP_HAL::panic("FATAL: invalid write16 at %u:%u 0x%04x 0x%04x\n",
sector, offset+i, b[i], data[i]); (unsigned)sector,
unsigned(offset+i),
b[i],
data[i]);
} }
#if !AP_FLASHSTORAGE_MULTI_WRITE #if !AP_FLASHSTORAGE_MULTI_WRITE
if (data16[i] != b16[i] && data16[i] != 0xFFFF && b16[i] != 0xFFFF) { if (data16[i] != b16[i] && data16[i] != 0xFFFF && b16[i] != 0xFFFF) {
AP_HAL::panic("FATAL: invalid write16 at %u:%u 0x%04x 0x%04x\n", AP_HAL::panic("FATAL: invalid write16 at %u:%u 0x%04x 0x%04x\n",
sector, offset+i, b[i], data[i]); (unsigned)sector,
unsigned(offset+i),
b[i],
data[i]);
} }
#endif #endif
b16[i] &= data16[i]; b16[i] &= data16[i];