sparkfun/SparkFun_AS3935_Lightning_Detector_Arduino_Library

malformed if() clauses

Closed this issue · 3 comments

In the library code, there are some instances of IF statements at the beginnings of methods to check for legal values. For example, checking if parameter "a" is one of the legal values 1 or 2:

if ((a!=1) | ( a!=2)) return;

Those IF statements can never be true because of the bitwise OR operator. As a result, those methods always silently return without doing anything.

Sorry, I meant "are always TRUE", hence the return is always taken.

Nice find! Thank you. The engineer behind this repo is on paternity leave. We'll get this cleaned up asap. If you or anyone else wants to put a PR together we would love to review it.

For my own notes, lines effected:

https://github.com/sparkfun/SparkFun_AS3935_Lightning_Detector_Library/blob/master/src/SparkFun_AS3935.cpp#L85

https://github.com/sparkfun/SparkFun_AS3935_Lightning_Detector_Library/blob/master/src/SparkFun_AS3935.cpp#L139

https://github.com/sparkfun/SparkFun_AS3935_Lightning_Detector_Library/blob/master/src/SparkFun_AS3935.cpp#L203

Let me know if you see any others.

Thanks for the issue @wjcarpenter and thanks for highlighting the specific lines @nseidle. Those particular lines have been fixed in this commit:
d33f3f3