Skip to content

Commit

Permalink
fix
Browse files Browse the repository at this point in the history
  • Loading branch information
vrahane committed Jun 4, 2024
1 parent 32c6f41 commit 9136484
Showing 1 changed file with 11 additions and 10 deletions.
21 changes: 11 additions & 10 deletions sys/log/full/src/log_fcb2.c
Original file line number Diff line number Diff line change
Expand Up @@ -270,8 +270,6 @@ log_fcb2_append_body(struct log *log, const struct log_entry_hdr *hdr,
return rc;
}

loc.fe_data_off += chunk_sz;

/* Append the remainder of the message body. */

u8p += hdr_alignment;
Expand All @@ -281,9 +279,9 @@ log_fcb2_append_body(struct log *log, const struct log_entry_hdr *hdr,
/* Calculate trailer alignment */
trailer_alignment = log_fcb2_hdr_body_bytes(loc.fe_range->fsr_align, chunk_sz + body_len);
if (trailer_alignment > trailer_len) {
chunk_sz = trailer_len;
chunk_sz += trailer_len;
} else {
chunk_sz = trailer_alignment;
chunk_sz += trailer_alignment;
}

#if MYNEWT_VAL(LOG_FLAGS_TLV_SUPPORT) && MYNEWT_VAL(LOG_TLV_NUM_ENTRIES)
Expand All @@ -298,7 +296,7 @@ log_fcb2_append_body(struct log *log, const struct log_entry_hdr *hdr,
return rc;
}

loc.fe_data_off += body_len - padding;
chunk_sz += body_len - padding;

u8p = u8p + body_len - padding;
memcpy(buf, u8p, padding);
Expand All @@ -310,30 +308,33 @@ log_fcb2_append_body(struct log *log, const struct log_entry_hdr *hdr,
offset += sizeof(struct log_tlv);

memcpy(buf + offset, &log->l_num_entries, LOG_NUM_ENTRIES_SIZE);
log->l_num_entries++;
offset += LOG_NUM_ENTRIES_SIZE;

rc = fcb2_write(&loc, 0, buf, offset);
rc = fcb2_write(&loc, chunk_sz, buf, offset);
if (rc != 0) {
return rc;
}

loc.fe_data_off += offset;
log->l_num_entries++;

chunk_sz += offset;
}
#else
if (body_len > 0) {
rc = fcb2_write(&loc, 0, u8p, body_len);
rc = fcb2_write(&loc, chunk_sz, u8p, body_len);
if (rc != 0) {
return rc;
}
chunk_sz += body_len;
}
#endif
} else {
if (body_len > 0) {
rc = fcb2_write(&loc, 0, u8p, body_len);
rc = fcb2_write(&loc, chunk_sz, u8p, body_len);
if (rc != 0) {
return rc;
}
chunk_sz += body_len;
}
}

Expand Down

0 comments on commit 9136484

Please sign in to comment.