summaryrefslogtreecommitdiff
path: root/apps
diff options
context:
space:
mode:
Diffstat (limited to 'apps')
-rw-r--r--apps/buffering.c12
1 files changed, 5 insertions, 7 deletions
diff --git a/apps/buffering.c b/apps/buffering.c
index 664a178db0..afc7c7ad6b 100644
--- a/apps/buffering.c
+++ b/apps/buffering.c
@@ -755,8 +755,7 @@ static void reset_handle(int handle_id)
755 return; 755 return;
756 756
757 /* Align to desired storage alignment */ 757 /* Align to desired storage alignment */
758 alignment_pad = (h->offset - (size_t)(&buffer[h->start])) 758 alignment_pad = STORAGE_OVERLAP(h->offset - (size_t)(&buffer[h->start]));
759 & STORAGE_ALIGN_MASK;
760 h->ridx = h->widx = h->data = ringbuf_add(h->start, alignment_pad); 759 h->ridx = h->widx = h->data = ringbuf_add(h->start, alignment_pad);
761 760
762 if (h == cur_handle) 761 if (h == cur_handle)
@@ -1022,8 +1021,8 @@ int bufopen(const char *file, size_t offset, enum data_type type,
1022 adjusted_offset = 0; 1021 adjusted_offset = 0;
1023 1022
1024 /* Reserve extra space because alignment can move data forward */ 1023 /* Reserve extra space because alignment can move data forward */
1025 struct memory_handle *h = add_handle(size-adjusted_offset+STORAGE_ALIGN_MASK, 1024 size_t padded_size = STORAGE_PAD(size-adjusted_offset);
1026 can_wrap, false); 1025 struct memory_handle *h = add_handle(padded_size, can_wrap, false);
1027 if (!h) 1026 if (!h)
1028 { 1027 {
1029 DEBUGF("%s(): failed to add handle\n", __func__); 1028 DEBUGF("%s(): failed to add handle\n", __func__);
@@ -1045,8 +1044,7 @@ int bufopen(const char *file, size_t offset, enum data_type type,
1045 h->start = buf_widx; 1044 h->start = buf_widx;
1046 1045
1047 /* Align to desired storage alignment */ 1046 /* Align to desired storage alignment */
1048 alignment_pad = (adjusted_offset - (size_t)(&buffer[buf_widx])) 1047 alignment_pad = STORAGE_OVERLAP(adjusted_offset - (size_t)(&buffer[buf_widx]));
1049 & STORAGE_ALIGN_MASK;
1050 buf_widx = ringbuf_add(buf_widx, alignment_pad); 1048 buf_widx = ringbuf_add(buf_widx, alignment_pad);
1051 } 1049 }
1052 1050
@@ -1582,7 +1580,7 @@ bool buffering_reset(char *buf, size_t buflen)
1582 1580
1583 buffer = buf; 1581 buffer = buf;
1584 /* Preserve alignment when wrapping around */ 1582 /* Preserve alignment when wrapping around */
1585 buffer_len = buflen & ~STORAGE_ALIGN_MASK; 1583 buffer_len = STORAGE_ALIGN_DOWN(buflen);
1586 guard_buffer = buf + buflen; 1584 guard_buffer = buf + buflen;
1587 1585
1588 buf_widx = 0; 1586 buf_widx = 0;