summaryrefslogtreecommitdiff
path: root/apps
diff options
context:
space:
mode:
Diffstat (limited to 'apps')
-rw-r--r--apps/buffering.c14
1 files changed, 7 insertions, 7 deletions
diff --git a/apps/buffering.c b/apps/buffering.c
index 213826fda0..85028dc8e6 100644
--- a/apps/buffering.c
+++ b/apps/buffering.c
@@ -250,7 +250,7 @@ static struct memory_handle *add_handle(size_t data_size, bool can_wrap,
250 /* gives each handle a unique id */ 250 /* gives each handle a unique id */
251 static int cur_handle_id = 0; 251 static int cur_handle_id = 0;
252 size_t shift; 252 size_t shift;
253 size_t new_widx; 253 size_t widx, new_widx;
254 size_t len; 254 size_t len;
255 ssize_t overlap; 255 ssize_t overlap;
256 256
@@ -260,7 +260,7 @@ static struct memory_handle *add_handle(size_t data_size, bool can_wrap,
260 mutex_lock(&llist_mutex); 260 mutex_lock(&llist_mutex);
261 mutex_lock(&llist_mod_mutex); 261 mutex_lock(&llist_mod_mutex);
262 262
263 new_widx = buf_widx; 263 widx = buf_widx;
264 264
265 if (cur_handle && cur_handle->filerem > 0) { 265 if (cur_handle && cur_handle->filerem > 0) {
266 /* the current handle hasn't finished buffering. We can only add 266 /* the current handle hasn't finished buffering. We can only add
@@ -274,12 +274,12 @@ static struct memory_handle *add_handle(size_t data_size, bool can_wrap,
274 return NULL; 274 return NULL;
275 } else { 275 } else {
276 /* Allocate the remainder of the space for the current handle */ 276 /* Allocate the remainder of the space for the current handle */
277 new_widx = ringbuf_add(cur_handle->widx, cur_handle->filerem); 277 widx = ringbuf_add(cur_handle->widx, cur_handle->filerem);
278 } 278 }
279 } 279 }
280 280
281 /* align to 4 bytes up */ 281 /* align to 4 bytes up */
282 new_widx = ringbuf_add(new_widx, 3) & ~3; 282 new_widx = ringbuf_add(widx, 3) & ~3;
283 283
284 len = data_size + sizeof(struct memory_handle); 284 len = data_size + sizeof(struct memory_handle);
285 285
@@ -291,11 +291,11 @@ static struct memory_handle *add_handle(size_t data_size, bool can_wrap,
291 new_widx = 0; 291 new_widx = 0;
292 } 292 }
293 293
294 /* How far we shifted buf_widx to align things, must be < buffer_len */ 294 /* How far we shifted the new_widx to align things, must be < buffer_len */
295 shift = ringbuf_sub(new_widx, buf_widx); 295 shift = ringbuf_sub(new_widx, widx);
296 296
297 /* How much space are we short in the actual ring buffer? */ 297 /* How much space are we short in the actual ring buffer? */
298 overlap = ringbuf_add_cross(buf_widx, shift + len, buf_ridx); 298 overlap = ringbuf_add_cross(widx, shift + len, buf_ridx);
299 if (overlap >= 0 && (alloc_all || (size_t)overlap >= data_size)) { 299 if (overlap >= 0 && (alloc_all || (size_t)overlap >= data_size)) {
300 /* Not enough space for required allocations */ 300 /* Not enough space for required allocations */
301 mutex_unlock(&llist_mod_mutex); 301 mutex_unlock(&llist_mod_mutex);