espruino / Espruino

The Espruino JavaScript interpreter - Official Repo
http://www.espruino.com/
Other
2.73k stars 741 forks source link

nrf5x_dfu/main.c highlight potential impossible code path #2524

Closed d3nd3 closed 1 week ago

d3nd3 commented 1 week ago

https://github.com/espruino/Espruino/blob/a0740a24cc0fdb6fa731c544b722564368f5712c/targets/nrf5x_dfu/main.c#L373 My calculation is that every line which uses : && (r&0xF)==0 Will never be reached, because of https://github.com/espruino/Espruino/blob/a0740a24cc0fdb6fa731c544b722564368f5712c/targets/nrf5x_dfu/main.c#L367

I hope I am wrong though, just I can't erase it from my mind.

gfwilliams commented 1 week ago

To get past 367, r&0xF is either 0 or 4?

So that if statement can be reached just fine?

Definitely when you first apply power to a flat watch it doesn't turn on, which implies to me that line is working??

d3nd3 commented 1 week ago

Alrightey, I think I was mixing up the % operator, You're right there.