From: erik quanstrom <quanstro@quanstro.net>
To: 9fans@cse.psu.edu
Subject: Re: [9fans] snap checksum
Date: Sat, 12 Jan 2008 14:30:07 -0500 [thread overview]
Message-ID: <bb7edde3eee4fe672ae6c478b61d2642@quanstro.net> (raw)
In-Reply-To: <20080112190615.5E7541E8C3A@holo.morphisms.net>
> > does anyone know if the function /sys/src/cmd/snap/take.c:/^sumr
> > can return 0 for a buffer that is not all zeros?
> >
> > i think it can not, since for sum&1, the next sum at least
> > has 0x8000 set and otherwise if (sum&1) == 0, then either
> > sum == 0 or sum>>1 != 0.
>
> >> if(sum & 1)
> >> sum = 0xffff & ((sum>>1)+*s+0x8000);
> >> else
> >> sum = 0xffff & ((sum>>1)+*s);
>
> your logic does not account for the addition of *s,
> which can cause an overflow that clears the 0x8000 bit.
> ff 80 80 80 80 80 80 80 80 01.
>
d'oh. i must need more sleep. i forgot to add *s back in.
thanks for the historical perspective.
- erik
next prev parent reply other threads:[~2008-01-12 19:30 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2008-01-12 19:06 Russ Cox
2008-01-12 19:30 ` erik quanstrom [this message]
2008-01-16 9:43 ` Douglas A. Gwyn
-- strict thread matches above, loose matches on Subject: below --
2008-01-11 19:39 erik quanstrom
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=bb7edde3eee4fe672ae6c478b61d2642@quanstro.net \
--to=quanstro@quanstro.net \
--cc=9fans@cse.psu.edu \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).