Re: mutt: 11 new changesets
On Thursday, 18 December 2008 at 15:12, Rocco Rutte wrote:
> Hi,
>
> * Brendan Cully wrote:
>
>> http://dev.mutt.org/hg/mutt/rev/7b46e23ae476
>> changeset: 5607:7b46e23ae476
>> branch: HEAD
>> user: Erik Hovland <erik@xxxxxxxxxxx>
>> date: Tue Dec 16 12:53:19 2008 -0800
>> summary: Remove redundant int clamping
>
> I think this change is actually wrong. The sign of a%b in C is
> machine-dependent for negative values. Thus,
>
> h = (h * SOMEPRIME) % n;
> h = (h >= 0) ? h : h + n;
>
> ensures that h is always positive. So at least the former line needs to
> go in again or it must be sure that the final return value is in the
> range 0..n-1.
Sorry, I forgot to reply to this earlier. I think since h is now
unsigned, h * SOMEPRIME is unsigned and so (h * SOMEPRIME) % n will
also be signed. (n should never be negative -- I am not sure why it
isn't typed as unsigned).
We might also want to use a better hash function -- there are many
available. In fact, I'll look into that now.