Skip to content

Commit 9d55719

Browse files
committedApr 2, 2021
SafeRingBuffer.h: Prevent compiler warning about reaching end of non-void function (see #580)
1 parent eb0a10a commit 9d55719

File tree

1 file changed

+7
-1
lines changed

1 file changed

+7
-1
lines changed
 

‎cores/arduino/SafeRingBuffer.h

+7-1
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,12 @@ int SafeRingBufferN<N>::read_char() {
4141
synchronized {
4242
return RingBufferN<N>::read_char();
4343
}
44+
45+
// We should never reached this line because the synchronized {} block gets
46+
// executed at least once. However the compiler gets confused and prints a
47+
// warning about control reaching the end of a non-void function. This
48+
// silences that warning.
49+
return -1;
4450
}
4551

4652
template <int N>
@@ -53,4 +59,4 @@ void SafeRingBufferN<N>::store_char(uint8_t c) {
5359
}
5460

5561
#endif /* _SAFE_RING_BUFFER_ */
56-
#endif /* __cplusplus */
62+
#endif /* __cplusplus */

0 commit comments

Comments
 (0)
Please sign in to comment.