andrzej-kaczmarek commented on code in PR #3365:
URL: https://github.com/apache/mynewt-core/pull/3365#discussion_r1967358944


##########
sys/log/full/include/log/log_fcb.h:
##########
@@ -103,19 +111,34 @@ struct fcb_log {
  * the log is walked, the starting point of the walk is added to the set of
  * bookmarks.
  *
- * FCB rotation invalidates all bookmarks.  It is up to the client code to
+ * FCB rotation invalidates all bookmarks. It is up to the client code to
  * clear a log's bookmarks whenever rotation occurs.
  */
 
 /**
  * @brief Configures an fcb_log to use the specified buffer for bookmarks.
+ *        If sector bookmarks are enabled, buffer should be big enough
+ *        to accomodate bookmarks for the entire flash area that is allocated
+ *        for the FCB log, i,e; sizeof(struct log_fcb_bmark) *
+ *        my_log.fl_fcb.f_sector_cnt + MYNEWT_VAL(LOG_FCB_NUM_ABS_BOOKMARKS)

Review Comment:
   It's not complicated. It's just a simple if statement added to 
`log_fcb_init_sector_bmarks` so `log_fcb_add_bmark` is not called for every 
sector.
   
   You can simply calculate max number of bookmarks from the buffer size and 
then either add at most that number of bookmarks or, even better, divide number 
of sectors by that number and insert bookmark every n-th sector only so it 
doesn't overflow buffer. I don't ask you to handle any special cases, e.g. if 
the buffer is too big then it will simply have some free space left.



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