Skip to content

Commit

Permalink
OTHER: _xmmsv_dict_hash: make hash function endianness-agnostic
Browse files Browse the repository at this point in the history
The following code:
    uint32_t k;
    memcpy (&k, data, sizeof (k));
computes different data depending on platform endianness.

That causes test_xmmsv_serialize_coll_match test to fail
as collection order is serialized in wrong order.

Signed-off-by: Sergei Trofimovich <slyfox@gentoo.org>
  • Loading branch information
Sergei Trofimovich authored and dsvensson committed Aug 27, 2017
1 parent 1bdccd0 commit dedc33d
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions src/lib/xmmstypes/xmmsv_dict.c
Original file line number Diff line number Diff line change
Expand Up @@ -66,8 +66,10 @@ _xmmsv_dict_hash (const void *key, int len)

while (len >= 4)
{
uint32_t k;
memcpy (&k, data, sizeof (k));
uint32_t k = data [0]
| data [1] << 8
| data [2] << 16
| data [3] << 24;

k *= m;
k ^= k >> r;
Expand Down

0 comments on commit dedc33d

Please sign in to comment.