Skip to content

Commit

Permalink
Merge pull request #618 from bxparks/saferingbuffer
Browse files Browse the repository at this point in the history
SafeRingBuffer.h: Prevent compiler warning about reaching end of non-void function (see #580)
  • Loading branch information
facchinm authored Apr 6, 2021
2 parents eb0a10a + 9d55719 commit cfa2899
Showing 1 changed file with 7 additions and 1 deletion.
8 changes: 7 additions & 1 deletion cores/arduino/SafeRingBuffer.h
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,12 @@ int SafeRingBufferN<N>::read_char() {
synchronized {
return RingBufferN<N>::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 <int N>
Expand All @@ -53,4 +59,4 @@ void SafeRingBufferN<N>::store_char(uint8_t c) {
}

#endif /* _SAFE_RING_BUFFER_ */
#endif /* __cplusplus */
#endif /* __cplusplus */

0 comments on commit cfa2899

Please sign in to comment.