SparkFun_Bio_Sensor_Hub_Library icon indicating copy to clipboard operation
SparkFun_Bio_Sensor_Hub_Library copied to clipboard

Extremely dangerous read methods

Open perezmeyer opened this issue 3 years ago • 5 comments

Hi! I'm afraid the code has extremely dangerous read methods: one can not differentiate a byte properly read from a wrong status byte.

Example: https://github.com/sparkfun/SparkFun_Bio_Sensor_Hub_Library/blob/master/src/SparkFun_Bio_Sensor_Hub_Library.cpp#L1263

In line 1277 if he read access fails the status byte is returned, but if the byte is read then the proper byte is returned. The user of the method does not has a way to differentiate between both. A proper solution would be to pass a uint8_t "statusByte" by reference and return the status byte in it, the user must then check it before using the result.

There are many methods with this kind of errors. If you would like me to present MRs please just say so.

Kinds regards, Lisandro.

perezmeyer avatar Nov 25 '20 19:11 perezmeyer