Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

checksum algorithm returns boolean instead of byte #355

Closed
ChristianRinn opened this issue Jan 18, 2018 · 2 comments
Closed

checksum algorithm returns boolean instead of byte #355

ChristianRinn opened this issue Jan 18, 2018 · 2 comments

Comments

@ChristianRinn
Copy link

ChristianRinn commented Jan 18, 2018

Typical use of a boolean operator ('||') where the bitwise operator was meant ('|'). Fortunately there are compiler warnings.

grbl/eeprom.c:133:26: warning: '<<' in boolean context, did you mean '<' ? [-Wint-in-bool-context]
     checksum = (checksum << 1) || (checksum >> 7);
                ~~~~~~~~~~^~~~~
grbl/eeprom.c: In function 'memcpy_from_eeprom_with_checksum':
grbl/eeprom.c:144:26: warning: '<<' in boolean context, did you mean '<' ? [-Wint-in-bool-context]
     checksum = (checksum << 1) || (checksum >> 7);
                ~~~~~~~~~~^~~~~

Affected are the functions memcpy_to_eeprom_with_checksum() and memcpy_from_eeprom_with_checksum() here: https://github.com/gnea/grbl/blob/master/grbl/eeprom.c#L130

PS:
To fix this bug we would have to wipe every EEPROM again because otherwise the checksum would be "wrong".

@chamnit
Copy link
Contributor

chamnit commented Jan 18, 2018

Yep. I found this a couple years ago and came to the same conclusion that it would wipe every EEPROM since the checksum would be wrong. Decided to leave it alone until the next major version.

@chamnit chamnit closed this as completed Jan 18, 2018
@micromouseonline
Copy link

Perhaps a comment in the source code pointing to this issue would help others (like me) from 're-discovering' this error periodically?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants