You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@mynewt.apache.org by GitBox <gi...@apache.org> on 2020/12/15 09:40:53 UTC

[GitHub] [mynewt-core] kasjer commented on a change in pull request #2425: log_fcb: optimize finding records towards the end of circular buffer

kasjer commented on a change in pull request #2425:
URL: https://github.com/apache/mynewt-core/pull/2425#discussion_r543180129



##########
File path: sys/log/full/src/log_fcb.c
##########
@@ -32,6 +32,41 @@
 
 static int log_fcb_rtr_erase(struct log *log);
 
+/**
+ * Helper function to find start point for walking, given an offset.
+ * for a non-zero offset, instead of walking from the beginning,
+ * walk from the last applicable area, check first entry and compare
+ * against the given offset. Repeat this until an offset less than the
+ * given offset is found, start walking from there.
+ */
+static int
+fcb_walk_back_find_start(struct fcb *fcb, struct log *log, struct log_offset *log_offset, struct fcb_entry *fcb_entry)
+{
+    struct flash_area *fap;
+    struct log_entry_hdr hdr;
+    struct fcb_entry iter_entry;
+    int rc;
+
+    fap = fcb->f_active.fe_area;
+
+    for (hdr.ue_index = log_offset->lo_index; hdr.ue_index >= log_offset->lo_index; fap--) {

Review comment:
       **fap** can't be just decremented, it is circular buffer, sometimes it wraps around so fap should be checked for this condition.




----------------------------------------------------------------
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.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org