[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <CANoiuGK-ys5Sf5Stw5cxRJ1y8SrH4RWYteZdhZwNxchoV4Hbvw@mail.gmail.com>
Date: Sun, 18 May 2014 15:43:10 -0700
From: David Matlack <matlackdavid@...il.com>
To: Joe Perches <joe@...ches.com>
Cc: gregkh@...uxfoundation.org, linux-kernel@...r.kernel.org,
devel@...verdev.osuosl.org, Lior Dotan <liodot@...il.com>,
charrer@...critech.com
Subject: Re: [PATCH 1/2] staging: slicoss: rewrite eeprom checksum code
On Sat, May 17, 2014 at 9:51 PM, David Matlack <matlackdavid@...il.com> wrote:
> On Sat, May 17, 2014 at 9:12 PM, Joe Perches <joe@...ches.com> wrote:
>> The if seems unnecessary.
>>
>> Perhaps declare a u16 return var or use
>>
>> return lower_16 + upper_16;
>
> I agree it's fishy... but using overflow doesn't produce the same result:
>
> (u16) 65536 == 0
> 65536 - 65535 == 1
>
> Now which is the correct result, I have no idea.
I think the checksum algorithm being used here is RFC 1071 [1]. Which means the
if is correct and just accounting for double overflow.
> The eeprom on this device is
> small (0x80 bytes max, not enough to trigger overflow) and I have no
Sorry, I was wrong about this. I was thinking in terms of summing bytes,
but the checksum is summing words. Overflow _does_ get triggered.
I think I'll go over this patch again while looking at the RFC to make sure
everything is ok. Thanks!
[1] http://tools.ietf.org/html/rfc1071
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@...r.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/
Powered by blists - more mailing lists