From af12a8e8a77afe1ff7ffea2c7d7b132388dc5f6c Mon Sep 17 00:00:00 2001 From: jaffer Date: Sat, 10 Dec 2022 17:27:44 +0800 Subject: [PATCH 1/2] =?UTF-8?q?[fix]=E4=BC=98=E5=8C=96=E6=97=A5=E5=BF=97lo?= =?UTF-8?q?g=E8=AF=BB=E5=8F=96=E5=87=BD=E6=95=B0=E6=8E=A5=E5=8F=A3?= =?UTF-8?q?=E5=8F=82=E6=95=B0=E9=94=99=E8=AF=AF=E5=88=A4=E6=96=AD=E5=A4=84?= =?UTF-8?q?=E7=90=86?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: jaffer --- easyflash/src/ef_log.c | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/easyflash/src/ef_log.c b/easyflash/src/ef_log.c index 9d2b8c6..c6e8718 100644 --- a/easyflash/src/ef_log.c +++ b/easyflash/src/ef_log.c @@ -490,8 +490,14 @@ EfErrCode ef_log_read(size_t index, uint32_t *log, size_t size) { return result; } - EF_ASSERT(size % 4 == 0); - EF_ASSERT(index < cur_using_size); + if (size % 4 == 0) { + EF_DEBUG("Error: size must be word aligned."); + return EF_READ_ERR; + } + if (index < cur_using_size) { + EF_DEBUG("Error: index out of ranges, current using size is %d", cur_using_size); + return EF_READ_ERR; + } if (index + size > cur_using_size) { EF_DEBUG("Warning: Log read size out of bound. Cut read size.\n"); From a5f09478f7887db1407c92b77ab8f4ec411384cd Mon Sep 17 00:00:00 2001 From: jaffer Date: Sat, 10 Dec 2022 17:33:52 +0800 Subject: [PATCH 2/2] =?UTF-8?q?[fix]=E4=BF=AE=E5=A4=8Dlog=20index2addr=20?= =?UTF-8?q?=E6=BA=A2=E5=87=BA=E5=AE=9E=E9=99=85=E7=89=A9=E7=90=86=E5=9C=B0?= =?UTF-8?q?=E5=9D=80=E7=A9=BA=E9=97=B4=E9=A3=8E=E9=99=A9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: jaffer --- easyflash/src/ef_log.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/easyflash/src/ef_log.c b/easyflash/src/ef_log.c index c6e8718..49e9d7c 100644 --- a/easyflash/src/ef_log.c +++ b/easyflash/src/ef_log.c @@ -463,8 +463,7 @@ static uint32_t log_index2addr(size_t index) { if (log_start_addr + index + header_total_offset < log_area_start_addr + LOG_AREA_SIZE) { return log_start_addr + index + header_total_offset; } else { - return log_start_addr + index + header_total_offset - LOG_AREA_SIZE; - + return (log_start_addr + index + header_total_offset) % LOG_AREA_SIZE; } } }