Example glitches

I was looking at some of our code, which is bases upon a sample that came with the Dynamic C 2000 / 3000 serie tools.

The glitch found is a small buffer offset problem:

file: Samples cpip\serialexa.c, line 479


if(bytes_written!=state->offset) {
   memcpy(state->buffer,state->buffer+bytes_written,state->offset-bytes_written);
   state->offset = bytes_written;
} else
   state->offset = 0;

should be:


if(bytes_written!=state->offset) {
   memcpy(state->buffer,state->buffer+bytes_written,state->offset-bytes_written);
   state->offset -= bytes_written;
} else
   state->offset = 0;

Anybody else found any glitches they share or is there another forum thread to post/read these?