From 41acfb52d4fe8bb534990720078f4b6ab48c3e16 Mon Sep 17 00:00:00 2001 From: twinaphex Date: Mon, 5 Jan 2015 15:44:20 +0100 Subject: [PATCH] fifo_buffer.c - nits --- fifo_buffer.c | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/fifo_buffer.c b/fifo_buffer.c index e2e65f9d7f..cfb5728637 100644 --- a/fifo_buffer.c +++ b/fifo_buffer.c @@ -48,7 +48,7 @@ void fifo_free(fifo_buffer_t *buffer) size_t fifo_read_avail(fifo_buffer_t *buffer) { size_t first = buffer->first; - size_t end = buffer->end; + size_t end = buffer->end; if (end < first) end += buffer->bufsize; return end - first; @@ -57,7 +57,7 @@ size_t fifo_read_avail(fifo_buffer_t *buffer) size_t fifo_write_avail(fifo_buffer_t *buffer) { size_t first = buffer->first; - size_t end = buffer->end; + size_t end = buffer->end; if (end < first) end += buffer->bufsize; @@ -67,7 +67,8 @@ size_t fifo_write_avail(fifo_buffer_t *buffer) void fifo_write(fifo_buffer_t *buffer, const void *in_buf, size_t size) { size_t first_write = size; - size_t rest_write = 0; + size_t rest_write = 0; + if (buffer->end + size > buffer->bufsize) { first_write = buffer->bufsize - buffer->end; @@ -84,7 +85,7 @@ void fifo_write(fifo_buffer_t *buffer, const void *in_buf, size_t size) void fifo_read(fifo_buffer_t *buffer, void *in_buf, size_t size) { size_t first_read = size; - size_t rest_read = 0; + size_t rest_read = 0; if (buffer->first + size > buffer->bufsize) { first_read = buffer->bufsize - buffer->first;