-
Notifications
You must be signed in to change notification settings - Fork 73
Open
Description
There's a compile warning in grbl-LPC about the checksum calculation routine in flash.cpp. There's a logical OR in the code which should be a bitwise OR. Existing code shouldn't generate spurious errors, but I don't think it will really catch any errors either. It basically returns the last character in the memory block potentially with 1 added.
I've included a patch below.
Thanks, Gil
diff --git a/grbl-lpc/flash.cpp b/grbl-lpc/flash.cpp
index a42b843..aabc422 100644
--- a/grbl-lpc/flash.cpp
+++ b/grbl-lpc/flash.cpp
@@ -77,7 +77,7 @@ static unsigned char memcpy_with_checksum(char *dest, char *src, unsigned size)
unsigned char checksum = 0;
while (size--)
{
- checksum = ((checksum << 1) || (checksum >> 7)) + *src;
+ checksum = ((checksum << 1) | (checksum >> 7)) + *src;
*dest++ = *src++;
}
return checksum;
Metadata
Metadata
Assignees
Labels
No labels