firmware/sniffer: Avoid extra call for rbuf_is_full

rbuf_write() will tell us in the return value if the buffer was full
(error) or not (success).  Let's use that return value rather than a
theoretically race-y call to rbuf_is_full() before.

It's theoretical as the write happens from IRQ context and the read from
normal process context, so the fill-level cannot really change while
we're in the USART interrupt.  So it doesn't fix a bug, just improves
coding style and also avoids an extra function call + irq-disable/re-enable.

Change-Id: Icf570d0aa48d67a19e63c6e2b6caa14438fe88e3
This commit is contained in:
Harald Welte
2022-11-16 10:46:07 +01:00
committed by laforge
parent 4836f23fa3
commit cc295f6945

View File

@@ -826,11 +826,8 @@ void Sniffer_usart_isr(void)
/* Reset WT timer */ /* Reset WT timer */
wt_remaining = wt; wt_remaining = wt;
/* Store sniffed data into buffer (also clear interrupt */ /* Store sniffed data into buffer (also clear interrupt */
if (rbuf_is_full(&sniff_buffer)) { if (rbuf_write(&sniff_buffer, byte) != 0)
TRACE_ERROR("USART buffer full\n\r"); TRACE_ERROR("USART buffer full\n\r");
} else {
rbuf_write(&sniff_buffer, byte);
}
} }
/* Verify it WT timeout occurred, to detect unresponsive card */ /* Verify it WT timeout occurred, to detect unresponsive card */