From 52c9a467b42c4448251753a295343496a9265b4f Mon Sep 17 00:00:00 2001 From: Reinhard Panhuber Date: Wed, 23 Sep 2020 21:36:30 +0200 Subject: [PATCH] Fix bug in modulo substitute. --- src/common/tusb_fifo.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/common/tusb_fifo.c b/src/common/tusb_fifo.c index 84fc9bb8b..cf4e6a51a 100644 --- a/src/common/tusb_fifo.c +++ b/src/common/tusb_fifo.c @@ -82,8 +82,8 @@ bool tu_fifo_config(tu_fifo_t *f, void* buffer, uint16_t depth, uint16_t item_si static inline uint16_t _ff_mod(uint16_t idx, uint16_t depth) { // return idx % depth; - idx -= depth & -(idx > depth); - return idx -= depth & -(idx > depth); + idx -= depth & -(idx >= depth); + return idx -= depth & -(idx >= depth); } // send one item to FIFO WITHOUT updating write pointer