mirror of
https://github.com/openvswitch/ovs
synced 2025-08-22 01:51:26 +00:00
hash: Add explicit typecasts to fix C++ compilation issues.
C++ does not allow implicit conversion from void pointer to a specific pointer type. This change removes the cast from uint32_t* to void* in `hash_words_32aligned` and adds an explicit typecast from uint32_t* to uint64_t* in `hash_words_inline`. This issue was initially discovered on G++ v9.2.0 when a downstream C++ application included the hash.h header file and was compiled on an AMD Ryzen Zen 2 CPU (__SSE4_2__ && __x86_64__). On the latest G++ version, it would throw an error. On the latest GCC version with `-Wc++-compat`, it would throw a warning. Acked-by: Mike Pattrick <mkp@redhat.com> Signed-off-by: James Raphael Tiovalen <jamestiotio@gmail.com> Signed-off-by: Ilya Maximets <i.maximets@ovn.org>
This commit is contained in:
parent
880a2bbb4b
commit
a40c55eff9
@ -198,9 +198,8 @@ hash_finish32(uint64_t hash, uint32_t final, uint32_t semifinal)
|
||||
}
|
||||
|
||||
static inline uint32_t
|
||||
hash_words_32aligned(const uint32_t *p_, size_t n_words, uint32_t basis)
|
||||
hash_words_32aligned(const uint32_t *p, size_t n_words, uint32_t basis)
|
||||
{
|
||||
const uint32_t *p = (const void *) p_;
|
||||
uint32_t hash1 = basis;
|
||||
uint32_t hash2 = 0;
|
||||
uint32_t hash3 = n_words;
|
||||
@ -254,7 +253,7 @@ hash_words_32aligned(const uint32_t *p_, size_t n_words, uint32_t basis)
|
||||
static inline uint32_t
|
||||
hash_words_inline(const uint32_t *p_, size_t n_words, uint32_t basis)
|
||||
{
|
||||
const uint64_t *p = (const void *)p_;
|
||||
const uint64_t *p = ALIGNED_CAST(const uint64_t *, p_);
|
||||
uint64_t hash1 = basis;
|
||||
uint64_t hash2 = 0;
|
||||
uint64_t hash3 = n_words;
|
||||
|
Loading…
x
Reference in New Issue
Block a user