From: Keith Packard Date: Tue, 9 Jun 2020 04:03:31 +0000 (-0700) Subject: altos: Round selected log size down to ao_storage_block multiple X-Git-Tag: 1.9.3~1^2~21 X-Git-Url: https://git.gag.com/?p=fw%2Faltos;a=commitdiff_plain;h=89726f5b1adceb243c5e2d5c958fc13c10f9a2d0 altos: Round selected log size down to ao_storage_block multiple There was some (broken) code that complained if the value set wasn't correct, that has been replaced by code that accepts any value and just rounds it down to a multiple of ao_storage_block. The code also stops complaining when set to the current value when storage isn't empty. Signed-off-by: Keith Packard --- diff --git a/src/kernel/ao_config.c b/src/kernel/ao_config.c index e4fc73c9..9fbc64bd 100644 --- a/src/kernel/ao_config.c +++ b/src/kernel/ao_config.c @@ -625,24 +625,24 @@ ao_config_log_set(void) #if FLIGHT_LOG_APPEND printf("Flight log fixed size %d kB\n", ao_storage_log_max >> 10); #else - uint16_t block = (uint16_t) (ao_storage_block >> 10); - uint16_t log_max = (uint16_t) (ao_storage_log_max >> 10); uint32_t r; r = ao_cmd_decimal(); if (ao_cmd_status != ao_cmd_success) return; - if (ao_log_present()) - printf("Storage must be empty before changing log size\n"); - else if (block > 1024 && (r & (block - 1))) - printf("Flight log size must be multiple of %d kB\n", block); - else if (r > log_max) - printf("Flight log max %d kB\n", log_max); - else { - _ao_config_edit_start(); - ao_config.flight_log_max = r << 10; - _ao_config_edit_finish(); + r = r << 10; + if (ao_log_present()) { + if (r != ao_config.flight_log_max) + printf("Storage must be empty before changing log size\n"); + return; + } + if (r > ao_storage_log_max) { + printf("Flight log max %d kB\n", ao_storage_log_max >> 10); + return; } + _ao_config_edit_start(); + ao_config.flight_log_max = r & ~(ao_storage_block - 1); + _ao_config_edit_finish(); #endif } #endif /* HAS_LOG */