> grbl/eeprom.c: In function ‘memcpytoeepromwithchecksum’: grbl/eeprom.c:133:26: warning: ‘<<' in boolean context, did you mean '' ? [-Wint-in-bool-context] 133 | checksum = (checksum << 1) || (checksum >> 7); | ~~~~~~~~~~^~~~~ grbl/eeprom.c: In function ‘memcpyfromeepromwithchecksum’: grbl/eeprom.c:144:26: warning: ‘<<' in boolean context, did you mean '' ? [-Wint-in-bool-context] 144 | checksum = (checksum << 1) || (checksum >> 7); | ~~~~~~~~~~^~~~~
That looks like it was a typo — it squashes the checksum down to a single bit of information, when it looks like it intended to roll it right one bit, so the final checksum ends up either zero or one larger than the last character in the data:
Maybe it was supposed to be
checksum = (checksum << 1) | (checksum >> 7);
Originally posted by @drf5n in https://github.com/gnea/grbl-Mega/issues/157#issuecomment-1095029184
评论 (2)
#2 – drf5n 于 2023-04-01
See also GRBL issue # https://github.com/grbl/grbl/issues/1249
#1 – drf5n 于 2022-04-11
See grblHAL’s checksum implementation in https://github.com/grblHAL/core/blob/3a84b58d301f04279268b4ef1045fd6bc0961be5/nuts_bolts.c#L267-L278