Closed bxparks closed 2 years ago
Thanks for catching this. I'm surprised cppcheck hasn't caught this bug.
I have released v2.0.5 to include this fix and added @bxparks to the list of contributors.
Thanks, Steve
It looks like cppcheck(1) removed that check around 2014/2015: https://sourceforge.net/p/cppcheck/discussion/general/thread/1b4c27f5/ because the author thinks that it generates too many false positives.
C++17 and C23 adds a [[fallthough]]
annotation which is nice, but doesn't help Arduino code.
Most Arduino compilers on various Cores will catch this if you check the "Compiler warnings" box in the IDE. I sometimes run my Arduino code through clang++ on a Linux box, which will sometimes catch bugs that g++ does not.
The compiler issues the following warning message:
SoftWire.cpp:206:8: warning: this statement may fall through [-Wimplicit-fallthrough=] stop();
And the compiler is correct. The function incorrectly issues 2 stop() conditions, and returns 'timedOut' instead of 'nack' due to the incorrect fallthru.