AP_FlashStorage: fixed build error with -O0

This commit is contained in:
Andrew Tridgell 2019-05-11 18:33:12 +10:00
parent a7eb85e1c5
commit d2c9db3f1f
1 changed files with 3 additions and 1 deletions

View File

@ -315,7 +315,9 @@ bool AP_FlashStorage::write_all()
debug("write_all to sector %u at %u with reserved_space=%u\n",
current_sector, write_offset, reserved_space);
for (uint16_t ofs=0; ofs<storage_size; ofs += max_write) {
uint8_t n = MIN(max_write, storage_size-ofs);
// local variable needed to overcome problem with MIN() macro and -O0
const uint8_t max_write_local = max_write;
uint8_t n = MIN(max_write_local, storage_size-ofs);
if (!all_zero(ofs, n)) {
if (!write(ofs, n)) {
return false;