Mehmet Fide

_CHECKSUM_ADD_WORD method -> only works when all the addresses/sizes are a multiple of 2

Discussion created by Mehmet Fide on Apr 14, 2008
Latest reply on Apr 15, 2008 by Mehmet Fide
Hi to all,
I'm using _CHECKSUM_ADD_WORD method to verify program content.
It works nice unless the addresses/sizes of the segments are odd number.
I have to check and modify segments sizes(with additional NOPs) evertime I compile the application with some new codes.
I start feeling tired to do this. :smileysad:
/* _Checksum_CheckAreaWordAdd: word summation checksum of an aera */_CheckSum2ByteType _Checksum_CheckAreaWordAdd(_CHECKSUM_ConstMemBytePtr start, unsigned int len) {  _CheckSum2ByteType checkVal=0;  const _CheckSum2ByteType*...;  while (len > 0) { <-- problem is here, when len is odd, it is always being bigger than 0         checkVal = (_CheckSum2ByteType)(checkVal + (*ptr));    ptr++;        len-= sizeof(*ptr); <-- "len -= 2"  }  return checkVal;}

I tried to patch the function above in checksum.c. I couldn't succeed because the calculated checkVal value nerver match with linker's.

Please save me from this irritating process.
Thank you,