laforge has submitted this change. ( https://gerrit.osmocom.org/c/simtrace2/+/30180 )
Change subject: firmware/sniffer: Avoid extra call for rbuf_is_full ...................................................................... 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 --- M firmware/libcommon/source/sniffer.c 1 file changed, 1 insertion(+), 4 deletions(-) Approvals: laforge: Looks good to me, approved Hoernchen: Looks good to me, but someone else must approve Jenkins Builder: Verified diff --git a/firmware/libcommon/source/sniffer.c b/firmware/libcommon/source/sniffer.c index e3b7fbb..cbfa7c9 100644 --- a/firmware/libcommon/source/sniffer.c +++ b/firmware/libcommon/source/sniffer.c @@ -826,11 +826,8 @@ /* Reset WT timer */ wt_remaining = wt; /* 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"); - } else { - rbuf_write(&sniff_buffer, byte); - } } /* Verify it WT timeout occurred, to detect unresponsive card */ -- To view, visit https://gerrit.osmocom.org/c/simtrace2/+/30180 To unsubscribe, or for help writing mail filters, visit https://gerrit.osmocom.org/settings Gerrit-Project: simtrace2 Gerrit-Branch: master Gerrit-Change-Id: Icf570d0aa48d67a19e63c6e2b6caa14438fe88e3 Gerrit-Change-Number: 30180 Gerrit-PatchSet: 2 Gerrit-Owner: laforge <lafo...@osmocom.org> Gerrit-Reviewer: Hoernchen <ew...@sysmocom.de> Gerrit-Reviewer: Jenkins Builder Gerrit-Reviewer: laforge <lafo...@osmocom.org> Gerrit-Reviewer: tsaitgaist <kre...@sysmocom.de> Gerrit-MessageType: merged