From 9d557196eabd8576079e9add05db260fa18d8705 Mon Sep 17 00:00:00 2001 From: Brian Park Date: Fri, 2 Apr 2021 12:24:11 -0700 Subject: [PATCH] SafeRingBuffer.h: Prevent compiler warning about reaching end of non-void function (see #580) --- cores/arduino/SafeRingBuffer.h | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/cores/arduino/SafeRingBuffer.h b/cores/arduino/SafeRingBuffer.h index 7526ae54a..235406fac 100644 --- a/cores/arduino/SafeRingBuffer.h +++ b/cores/arduino/SafeRingBuffer.h @@ -41,6 +41,12 @@ int SafeRingBufferN::read_char() { synchronized { return RingBufferN::read_char(); } + + // We should never reached this line because the synchronized {} block gets + // executed at least once. However the compiler gets confused and prints a + // warning about control reaching the end of a non-void function. This + // silences that warning. + return -1; } template @@ -53,4 +59,4 @@ void SafeRingBufferN::store_char(uint8_t c) { } #endif /* _SAFE_RING_BUFFER_ */ -#endif /* __cplusplus */ \ No newline at end of file +#endif /* __cplusplus */