This is an automated email from the ASF dual-hosted git repository.

jerzy pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/mynewt-core.git

commit 526237ba31bce4accb6058b09183c4de33dc7e74
Author: Jerzy Kasenberg <[email protected]>
AuthorDate: Wed Jun 26 12:49:43 2024 +0200

    fs/fcb2: Fix data access for flash with big data alignment
    
    In one place size of structure that was stored in flash was
    assumed to be FCB2_ENTRY_SIZE while in fact it was greater
    for flash with write alignment >= 8.
    
    Now entry locate takes into account actual space needed by
    entry.
    
    Signed-off-by: Jerzy Kasenberg <[email protected]>
---
 fs/fcb2/src/fcb_getnext.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/fs/fcb2/src/fcb_getnext.c b/fs/fcb2/src/fcb_getnext.c
index ea18be4f7..8a4f8f305 100644
--- a/fs/fcb2/src/fcb_getnext.c
+++ b/fs/fcb2/src/fcb_getnext.c
@@ -36,7 +36,8 @@ fcb2_getnext_in_area(struct fcb2 *fcb, struct fcb2_entry *loc)
                                                  
fcb2_len_in_flash(loc->fe_range, 2);
         /* Possible entry offset for next data */
         next_entry_offset = fcb->f_active.fe_range->fsr_sector_size -
-                            (FCB2_ENTRY_SIZE * (loc->fe_entry_num + 1));
+                            (fcb2_len_in_flash(fcb->f_active.fe_range, 
FCB2_ENTRY_SIZE) *
+                             (loc->fe_entry_num + 1));
         loc->fe_data_len = 0;
         loc->fe_entry_num++;
         /* If there is no space for next entry just finish search */

Reply via email to