From c910767617d61f8dae6ce32bbce3d3cf078ce525 Mon Sep 17 00:00:00 2001 From: Jacob Vosmaer Date: Thu, 13 Aug 2020 21:54:46 +0200 Subject: [PATCH] Make ring buffer increment easier to read --- crowbx.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/crowbx.c b/crowbx.c index 7d62968..05fa679 100644 --- a/crowbx.c +++ b/crowbx.c @@ -561,8 +561,8 @@ static struct { void uart_buffer_push(uint8_t x) { ATOMIC_BLOCK(ATOMIC_RESTORESTATE) { uart_buffer.data[uart_buffer.tail] = x; - uart_buffer.tail = - (uart_buffer.tail + 1) % ARRAY_SIZE(uart_buffer.data); + uart_buffer.tail++; + uart_buffer.tail %= ARRAY_SIZE(uart_buffer.data); } } @@ -573,8 +573,8 @@ uint8_t uart_buffer_pop(uint8_t *x) { } *x = uart_buffer.data[uart_buffer.head]; - uart_buffer.head = - (uart_buffer.head + 1) % ARRAY_SIZE(uart_buffer.data); + uart_buffer.head++; + uart_buffer.head %= ARRAY_SIZE(uart_buffer.data); } return true; -- GitLab