From 3f0d2668f1acbda95fa6d8b341c6ade8b56ee02b Mon Sep 17 00:00:00 2001 From: Zixun LI Date: Tue, 25 Nov 2025 16:12:20 +0100 Subject: [PATCH] fifo: fix IAR Warning[Pa082]: undefined behavior: the order of volatile accesses is undefined --- src/common/tusb_fifo.h | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/common/tusb_fifo.h b/src/common/tusb_fifo.h index 9d8b864e9..2fb4f37d4 100644 --- a/src/common/tusb_fifo.h +++ b/src/common/tusb_fifo.h @@ -175,7 +175,9 @@ bool tu_fifo_full(const tu_fifo_t *f); bool tu_fifo_overflowed(const tu_fifo_t *f); TU_ATTR_ALWAYS_INLINE static inline bool tu_fifo_empty(const tu_fifo_t *f) { - return f->wr_idx == f->rd_idx; + uint16_t wr_idx = f->wr_idx; + uint16_t rd_idx = f->rd_idx; + return wr_idx == rd_idx; } TU_ATTR_ALWAYS_INLINE static inline uint16_t tu_fifo_depth(const tu_fifo_t *f) {