bl_iot_sdk
bl_iot_sdk copied to clipboard
Bug in static void i2c_transferbytes(i2c_msg_t *pstmsg)?
In static void i2c_transferbytes(i2c_msg_t *pstmsg) there are 2 if conditions that have a single =.
if ((pstmsg->direct == I2C_M_WRITE) && (pstmsg->event = EV_I2C_TXF_INT)) {
and
} else if ((pstmsg->direct == I2C_M_READ) && (pstmsg->event = EV_I2C_RXF_INT)){
This looks suspiciously like they should be == equality tests.
The Assignment in the Condition looks suspicious because pstmsg->event
has already been set by the calling function i2c_interrupt_entry
... Yet pstmsg->event
isn't used after i2c_transferbytes
returns to i2c_interrupt_entry
Hi
This may be an issue. We will check this code, thanks for your information.
@lupyuen @Kongduino This issue will be fixed, thanks!
Awesome thank you :-)
好的👌!
@shchen-Lab , has a fix for this been committed? If so, please close this. Bonus points for referencing the git hash of the submit that fix it, but omitting that is OK. Leaving this dangling for two years isn't great. Thanx.
To prevent this kind of thing in the future, please consider integrating one of the many GCC/Clang flags to detect (if foo = bar) vs if ((foo == bar)). They're not totally satisfying, but automation in a large code base can really help.