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


The following commit(s) were added to refs/heads/master by this push:
     new 24fc28100 fs/fcb: Coverity fix
24fc28100 is described below

commit 24fc2810053f3b0006098853dc8b5a1cab4f062d
Author: Jerzy Kasenberg <[email protected]>
AuthorDate: Wed Sep 11 12:17:15 2024 +0200

    fs/fcb: Coverity fix
    
    There was no real problem with the code
    356                         loc1.fe_area = fcb_get_prev_area(fcb, 
loc->fe_area);
    >>>     CID 418283:  Code maintainability issues  (UNUSED_VALUE)
    >>>     Assigning value "0UL" to "loc1.fe_elem_off" here, but that stored 
value is overwritten before it can be used.
    357                         loc1.fe_elem_off = 0;
    
    This should satisfy coverity
    
    Signed-off-by: Jerzy Kasenberg <[email protected]>
---
 fs/fcb/src/fcb_getnext.c | 10 ++++------
 1 file changed, 4 insertions(+), 6 deletions(-)

diff --git a/fs/fcb/src/fcb_getnext.c b/fs/fcb/src/fcb_getnext.c
index 6c9d17c63..196a9c457 100644
--- a/fs/fcb/src/fcb_getnext.c
+++ b/fs/fcb/src/fcb_getnext.c
@@ -347,15 +347,13 @@ fcb_step(struct fcb *fcb, struct fcb_entry *loc, int 
previous_error)
             loc1.fe_data_len = 0;
 
             /* Begin of sector ? */
-            if (loc->fe_elem_off == first_entry_offset) {
+            if (loc->fe_elem_off == first_entry_offset || target_ix < 0) {
                 /* Oldest sector, nowhere to go */
                 if (fcb->f_oldest == loc->fe_area) {
                     rc = FCB_ERR_NOVAR;
                 } else {
                     /* Switch to previous sector and find last entry */
                     loc1.fe_area = fcb_get_prev_area(fcb, loc->fe_area);
-                    loc1.fe_elem_off = 0;
-                    loc1.fe_elem_ix = 0;
                 }
             }
             if (rc != FCB_ERR_NOVAR) {
@@ -418,14 +416,14 @@ fcb_step(struct fcb *fcb, struct fcb_entry *loc, int 
previous_error)
     } else {
         if (loc->fe_area == NULL) {
             loc->fe_area = fcb->f_oldest;
-            loc->fe_elem_off = fcb_start_offset(fcb);
+            loc->fe_elem_off = first_entry_offset;
             loc->fe_elem_ix = 0;
             loc->fe_data_len = 0;
         } else if (previous_error == FCB_ERR_NOVAR) {
             /* If there are more sectors, move to next one */
             if (loc->fe_area != fcb->f_active.fe_area) {
                 loc->fe_area = fcb_getnext_area(fcb, loc->fe_area);
-                loc->fe_elem_off = fcb_start_offset(fcb);
+                loc->fe_elem_off = first_entry_offset;
                 loc->fe_elem_ix = 0;
                 loc->fe_data_len = 0;
             } else {
@@ -433,7 +431,7 @@ fcb_step(struct fcb *fcb, struct fcb_entry *loc, int 
previous_error)
                 rc = FCB_ERR_NOVAR;
             }
         } else if (loc->fe_elem_off == 0) {
-            loc->fe_elem_off = fcb_start_offset(fcb);
+            loc->fe_elem_off = first_entry_offset;
             loc->fe_elem_ix = 0;
             loc->fe_data_len = 0;
         } else {

Reply via email to