kasjer commented on code in PR #3413:
URL: https://github.com/apache/mynewt-core/pull/3413#discussion_r2056797865


##########
sys/log/full/src/log_fcb.c:
##########
@@ -932,12 +933,21 @@ log_fcb_copy_entry(struct log *log, struct fcb_entry 
*entry,
         goto err;
     }
 
-    /* Changing the fcb to be logged to be dst fcb */
-    fcb_tmp = &((struct fcb_log *)log->l_arg)->fl_fcb;
+    /* Cache fcb_log pointer */
+    fcb_log_ptr = (struct fcb_log *)log->l_arg;
 
-    log->l_arg = dst_fcb;
+    /* Cache the fcb log, so that we preserve original fcb pointer and
+     * bookmark settings

Review Comment:
   Comment suggest that bookmark settings need to be preserved.
   It bookmarks can be affected by log_fcb_append() only part of bookmark data 
is preserved.
   log_fcb_bset as part of fcb_log would be preserved while elements of 
lfs_bmarks array could be modified.
   Finally fcl_log would have data intact but not in sync with bookmark array 
that could have pointer(s) to scratch area.



##########
sys/log/full/src/log_fcb.c:
##########
@@ -932,12 +933,21 @@ log_fcb_copy_entry(struct log *log, struct fcb_entry 
*entry,
         goto err;
     }
 
-    /* Changing the fcb to be logged to be dst fcb */
-    fcb_tmp = &((struct fcb_log *)log->l_arg)->fl_fcb;
+    /* Cache fcb_log pointer */
+    fcb_log_ptr = (struct fcb_log *)log->l_arg;
 
-    log->l_arg = dst_fcb;
+    /* Cache the fcb log, so that we preserve original fcb pointer and
+     * bookmark settings
+     */
+    memcpy(&fcb_log_tmp, log->l_arg, sizeof(struct fcb_log));
+    fcb_log_tmp.fl_fcb = *dst_fcb;

Review Comment:
   Those  two lines copy structures first line uses `memcpy()` second is using 
operator `=`
   More consistent would be to have
   ```c
   fcb_log_tmp = *fcb_log_ptr;
   fcb_log_tmp.fl_fcb = *dst_fcb;
   ```



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to