vrahane commented on code in PR #3168:
URL: https://github.com/apache/mynewt-core/pull/3168#discussion_r1669172300
##########
sys/log/full/src/log_fcb.c:
##########
@@ -346,23 +350,80 @@ log_fcb_append_body(struct log *log, const struct
log_entry_hdr *hdr,
if (hdr->ue_flags & LOG_FLAGS_IMG_HASH) {
memcpy(buf + LOG_BASE_ENTRY_HDR_SIZE, hdr->ue_imghash,
LOG_IMG_HASHLEN);
}
+
memcpy(buf + hdr_len, u8p, hdr_alignment);
rc = flash_area_write(loc.fe_area, loc.fe_data_off, buf, chunk_sz);
if (rc != 0) {
return rc;
}
+ loc.fe_data_off += chunk_sz;
+
/* Append the remainder of the message body. */
u8p += hdr_alignment;
body_len -= hdr_alignment;
- if (body_len > 0) {
- rc = flash_area_write(loc.fe_area, loc.fe_data_off + chunk_sz, u8p,
- body_len);
- if (rc != 0) {
- return rc;
+ if (hdr->ue_flags & LOG_FLAGS_TLV_SUPPORT) {
+ memset(buf, 0, sizeof(buf));
+ /* Calculate trailer alignment */
+ trailer_alignment = log_fcb_hdr_trailer_bytes(fcb->f_align, chunk_sz +
body_len);
+ if (trailer_alignment > trailer_len) {
+ chunk_sz = trailer_len;
+ } else {
+ chunk_sz = trailer_alignment;
+ }
+
+#if MYNEWT_VAL(LOG_FLAGS_TLV_SUPPORT) && MYNEWT_VAL(LOG_TLV_NUM_ENTRIES)
+ struct log_tlv tlv;
+ uint16_t offset = 0;
+ uint16_t padding = 0;
+
+ if (body_len > 0) {
+ padding = trailer_alignment ? fcb->f_align - trailer_alignment : 0;
+ rc = flash_area_write(loc.fe_area, loc.fe_data_off, u8p,
+ body_len - padding);
+ if (rc != 0) {
+ return rc;
+ }
+
+ loc.fe_data_off += body_len - padding;
+
+ u8p = u8p + body_len - padding;
+ memcpy(buf, u8p, padding);
+ offset = padding;
+ u8p = (void *)&tlv;
Review Comment:
No specific reason, fixing it.
--
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]