summaryrefslogtreecommitdiff
path: root/include
diff options
context:
space:
mode:
authorEugene Kosov <claprix@yandex.ru>2018-10-03 12:22:03 +0300
committerSergey Vojtovich <svoj@mariadb.org>2018-10-16 21:50:22 +0400
commit853dee854c60d13dfac7f7b52bd376a1bc63a4c3 (patch)
treea0b37855ccff5dec2386c6f3f6804eb870a69b27 /include
parentbebe24b03b859d3d01b0bd56356047531a26fac4 (diff)
downloadmariadb-git-853dee854c60d13dfac7f7b52bd376a1bc63a4c3.tar.gz
MDEV-17358 my_reverse_bits() is incorrect due to UB
my_reverse_bits(): add a cast to fix a bit shift
Diffstat (limited to 'include')
-rw-r--r--include/my_bit.h8
1 files changed, 4 insertions, 4 deletions
diff --git a/include/my_bit.h b/include/my_bit.h
index 174e0f70083..494d899c54f 100644
--- a/include/my_bit.h
+++ b/include/my_bit.h
@@ -115,10 +115,10 @@ static inline uint32 my_clear_highest_bit(uint32 v)
static inline uint32 my_reverse_bits(uint32 key)
{
return
- (_my_bits_reverse_table[ key & 255] << 24) |
- (_my_bits_reverse_table[(key>> 8) & 255] << 16) |
- (_my_bits_reverse_table[(key>>16) & 255] << 8) |
- _my_bits_reverse_table[(key>>24) ];
+ ((uint32)_my_bits_reverse_table[ key & 255] << 24) |
+ ((uint32)_my_bits_reverse_table[(key>> 8) & 255] << 16) |
+ ((uint32)_my_bits_reverse_table[(key>>16) & 255] << 8) |
+ (uint32)_my_bits_reverse_table[(key>>24) ];
}
C_MODE_END