[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: hash resizing bug
From: |
Eric Blake |
Subject: |
Re: hash resizing bug |
Date: |
Thu, 18 Jun 2009 13:00:50 -0600 |
User-agent: |
Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.8.1.21) Gecko/20090302 Thunderbird/2.0.0.21 Mnenhy/0.7.6.666 |
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1
According to Jim Meyering on 6/18/2009 11:37 AM:
>> + size_t val = data;
>> + val = (val >> 3) | (val << (CHAR_BIT * sizeof val - 3));
>> + return val % n;
>
> That looks fine.
Added as:
size_t val = (size_t) data;
val = ((val >> 3) | (val << (CHAR_BIT * sizeof val - 3))) & SIZE_MAX;
to address concerns about casting (I didn't get any warning with the
implicit cast, but understand that void*->size_t is different than
void*->intptr_t, so the cast makes it obvious), and to address the
possibility that size_t might be less than int (is there such a platform?).
> Though how about adding size_t variants to lib/bitrotate.h?
> Then we can use this:
>
> val = rotr<something> (val, 3);
For rotr64, it is probably superfluous; but for sizes smaller than int
smaller sizes it makes a difference. I think that warrants a separate
patch, since it also changes the dependencies for hash.c, as well as
touching the bitrotate module. But it does sound like a nice idea.
>
> Then there's the question of the name.
> rotr_sz? rotr_size_t is not kosher since it ends in _t,
> which is reserved. I don't like rotr_sizet.
> Maybe rotrsz, but I prefer with the underscore.
I'm leaning towards rotr_sz.
>
- --
Don't work too hard, make some time for fun as well!
Eric Blake address@hidden
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.9 (Cygwin)
Comment: Public key at home.comcast.net/~ericblake/eblake.gpg
Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org
iEYEARECAAYFAko6juEACgkQ84KuGfSFAYCHtACgv2mr8BcPhMD9jzBPaSx4e1mM
oBUAoIuB4LvJH2dc8As7TJU78p4ML8tY
=b3FU
-----END PGP SIGNATURE-----
- Re: hash resizing bug, (continued)
- Re: hash resizing bug, Jim Meyering, 2009/06/17
- Re: hash resizing bug, Eric Blake, 2009/06/18
- Re: hash resizing bug, Jim Meyering, 2009/06/18
- Re: hash resizing bug, Jim Meyering, 2009/06/18
- Re: hash resizing bug, Jim Meyering, 2009/06/18
- Re: hash resizing bug, Eric Blake, 2009/06/18
- Re: hash resizing bug, Jim Meyering, 2009/06/18
- Re: hash resizing bug,
Eric Blake <=
- hash and bitrotate (was: hash resizing bug), Eric Blake, 2009/06/18
- Re: hash and bitrotate, Eric Blake, 2009/06/18
- Re: hash and bitrotate, Jim Meyering, 2009/06/18
- Re: hash and bitrotate, Simon Josefsson, 2009/06/18
- Re: hash resizing bug, Jim Meyering, 2009/06/18
- Re: hash resizing bug, Ben Pfaff, 2009/06/18
- another hash cleanup (was: hash resizing bug), Eric Blake, 2009/06/18
- Re: another hash cleanup, Jim Meyering, 2009/06/18
- Re: another hash cleanup, Eric Blake, 2009/06/18
- Re: another hash cleanup, Jim Meyering, 2009/06/18