On Thu, Apr 17, 2008 at 6:51 PM, Matthew Smith <[EMAIL PROTECTED]> wrote:
> Quoth Chris Kuethe at 2008-04-18 10:59...
>
> > int
>  > oncore_checksum(char *buf, int len){
>  >       unsigned char a, b;
>  >       int i;
>  >
>  >       a = buf[len-3];
>  >       b = '\0';
>  >       for(i = 2; i < len - 3; i++)
>  >               b ^= buf[i];
>  >       if (a == b)
>  >               return 0;
>  >       return 1;
>  > }
>
>  'Scuse me for being something of a C newbie, but does that not return
>  either a 1 or a 0, but not the checksum?
>
>  Otherwise, I can follow the logic.  Thanks.

yeah, i should've mentioned, that's function i use to check the sum,
not compute it. return b instead, or just patch the buffer inside the
function:

void
oncore_add_checksum(char *buf, int len){
        unsigned char b;
        int i;

        b = '\0';
        for(i = 2; i < len - 3; i++)
                b ^= buf[i];
        buf[len-3] = b;
}


-- 
GDB has a 'break' feature; why doesn't it have 'fix' too?

_______________________________________________
time-nuts mailing list -- time-nuts@febo.com
To unsubscribe, go to https://www.febo.com/cgi-bin/mailman/listinfo/time-nuts
and follow the instructions there.

Reply via email to