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

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

commit 2b774468fcc5ab770dac5581ad929aaba745142e
Author: Vipul Rahane <[email protected]>
AuthorDate: Mon Feb 10 11:15:01 2025 -0800

    Remove conditionals, cleanup
---
 sys/log/full/include/log/log.h |  4 +---
 sys/log/full/src/log.c         | 16 +++++++++-------
 sys/log/full/src/log_cbmem.c   |  5 +----
 3 files changed, 11 insertions(+), 14 deletions(-)

diff --git a/sys/log/full/include/log/log.h b/sys/log/full/include/log/log.h
index 91cb31310..2be91efa6 100644
--- a/sys/log/full/include/log/log.h
+++ b/sys/log/full/include/log/log.h
@@ -243,7 +243,6 @@ struct log {
 #if !MYNEWT_VAL(LOG_GLOBAL_IDX)
     uint32_t l_idx;
 #endif
-#if MYNEWT_VAL(LOG_FLAGS_TRAILER_SUPPORT)
     log_trailer_len_cb *l_trailer_len_cb;
     log_trailer_append_cb *l_trailer_append_cb;
     log_process_trailer_cb *l_process_trailer_cb;
@@ -251,7 +250,6 @@ struct log {
     log_cbmem_trailer_append_cb *l_cbmem_trailer_append_cb;
     log_cbmem_trailer_mbuf_append_cb *l_cbmem_trailer_mbuf_append_cb;
     void *l_trailer_arg;
-#endif
 #if MYNEWT_VAL(LOG_STATS)
     STATS_SECT_DECL(logs) l_stats;
 #endif
@@ -794,7 +792,6 @@ log_fill_current_img_hash(struct log_entry_hdr *hdr);
 int
 log_len_in_medium(struct log *log, uint16_t len);
 
-#if MYNEWT_VAL(LOG_FLAGS_TRAILER_SUPPORT)
 /**
  * @brief Reads the trailer length
  *
@@ -847,6 +844,7 @@ int
 log_read_last_hdr_trailer(struct log *log, struct log_entry_hdr *out_hdr,
                           bool *trailer_exists);
 
+#if MYNEWT_VAL(LOG_FLAGS_TRAILER_SUPPORT)
 /**
  * Register trailer callbacks
  *
diff --git a/sys/log/full/src/log.c b/sys/log/full/src/log.c
index a1eda0b3f..957560fb6 100644
--- a/sys/log/full/src/log.c
+++ b/sys/log/full/src/log.c
@@ -323,13 +323,15 @@ log_read_hdr_trailer_walk(struct log *log, struct 
log_offset *log_offset,
     }
 
     if (arg->hdr->ue_flags & LOG_FLAGS_TRAILER_SUPPORT) {
-        rc = log->l_process_trailer_cb(log, arg->arg_trailer, dptr, len);
-        if (!rc) {
-            arg->read_success = 1;
-            arg->trailer_exists = true;
-        } else {
-            arg->read_success = 0;
-            arg->trailer_exists = false;
+        if (log->l_process_trailer_cb) {
+            rc = log->l_process_trailer_cb(log, arg->arg_trailer, dptr, len);
+            if (!rc) {
+                arg->read_success = 1;
+                arg->trailer_exists = true;
+            } else {
+                arg->read_success = 0;
+                arg->trailer_exists = false;
+            }
         }
     }
 
diff --git a/sys/log/full/src/log_cbmem.c b/sys/log/full/src/log_cbmem.c
index 94a12b7b5..9940384b8 100644
--- a/sys/log/full/src/log_cbmem.c
+++ b/sys/log/full/src/log_cbmem.c
@@ -32,6 +32,7 @@ log_cbmem_append_body(struct log *log, const struct 
log_entry_hdr *hdr,
     struct cbmem_scat_gath *sg = (struct cbmem_scat_gath *)&trailer[0];
 
     trailer_len = log_trailer_len(log, hdr);
+
     *sg = (struct cbmem_scat_gath) {
         .entries = (struct cbmem_scat_gath_entry[]) {
             {
@@ -59,7 +60,6 @@ log_cbmem_append_body(struct log *log, const struct 
log_entry_hdr *hdr,
     }
 
     if (hdr->ue_flags & LOG_FLAGS_TRAILER_SUPPORT) {
-#if MYNEWT_VAL(LOG_FLAGS_TRAILER_SUPPORT)
         if (log->l_cbmem_trailer_append_cb) {
             rc = log->l_cbmem_trailer_append_cb(log, trailer, trailer_len);
             if (!rc) {
@@ -67,7 +67,6 @@ log_cbmem_append_body(struct log *log, const struct 
log_entry_hdr *hdr,
                 sg->entries[3].flat_len = trailer_len;
             }
         }
-#endif
     }
 
     cbmem = (struct cbmem *) log->l_arg;
@@ -116,11 +115,9 @@ log_cbmem_append_mbuf_body(struct log *log, const struct 
log_entry_hdr *hdr,
     }
 
     if (hdr->ue_flags & LOG_FLAGS_TRAILER_SUPPORT) {
-#if MYNEWT_VAL(LOG_FLAGS_TRAILER_SUPPORT)
         if (log->l_cbmem_trailer_mbuf_append_cb) {
             log->l_cbmem_trailer_mbuf_append_cb(log, om);
         }
-#endif
     }
 
     cbmem = (struct cbmem *) log->l_arg;

Reply via email to