Skip to content

Commit 3f0d266

Browse files
committed
fifo: fix IAR Warning[Pa082]: undefined behavior: the order of volatile accesses is undefined
1 parent 91c3b33 commit 3f0d266

File tree

1 file changed

+3
-1
lines changed

1 file changed

+3
-1
lines changed

src/common/tusb_fifo.h

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -175,7 +175,9 @@ bool tu_fifo_full(const tu_fifo_t *f);
175175
bool tu_fifo_overflowed(const tu_fifo_t *f);
176176

177177
TU_ATTR_ALWAYS_INLINE static inline bool tu_fifo_empty(const tu_fifo_t *f) {
178-
return f->wr_idx == f->rd_idx;
178+
uint16_t wr_idx = f->wr_idx;
179+
uint16_t rd_idx = f->rd_idx;
180+
return wr_idx == rd_idx;
179181
}
180182

181183
TU_ATTR_ALWAYS_INLINE static inline uint16_t tu_fifo_depth(const tu_fifo_t *f) {

0 commit comments

Comments
 (0)