mirror of
https://github.com/zeek/zeek.git
synced 2025-10-14 20:48:21 +00:00
Fix strict-aliasing compiler warning
This commit is contained in:
parent
ffe895a0f1
commit
0c9878f136
1 changed files with 9 additions and 6 deletions
|
@ -118,16 +118,19 @@ Hasher::digest UHF::hash(const void* x, size_t n) const
|
||||||
return outdigest;
|
return outdigest;
|
||||||
}
|
}
|
||||||
|
|
||||||
unsigned char d[16];
|
union {
|
||||||
MD5(reinterpret_cast<const unsigned char*>(x), n, d);
|
unsigned char d[16];
|
||||||
|
Hasher::digest rval;
|
||||||
|
} u;
|
||||||
|
|
||||||
|
MD5(reinterpret_cast<const unsigned char*>(x), n, u.d);
|
||||||
|
|
||||||
const unsigned char* s = reinterpret_cast<const unsigned char*>(&seed);
|
const unsigned char* s = reinterpret_cast<const unsigned char*>(&seed);
|
||||||
for ( size_t i = 0; i < 16; ++i )
|
for ( size_t i = 0; i < 16; ++i )
|
||||||
d[i] ^= s[i % sizeof(seed)];
|
u.d[i] ^= s[i % sizeof(seed)];
|
||||||
|
|
||||||
MD5(d, 16, d);
|
MD5(u.d, 16, u.d);
|
||||||
|
return u.rval;
|
||||||
return *reinterpret_cast<const Hasher::digest*>(d);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
DefaultHasher::DefaultHasher(size_t k, Hasher::seed_t seed)
|
DefaultHasher::DefaultHasher(size_t k, Hasher::seed_t seed)
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue