mirror of
https://github.com/tstack/lnav
synced 2024-11-01 21:40:34 +00:00
ArenaAlloc/arenaallocimpl.h: avoid shift overflow on 32-bit hosts.
Use the constants defined by <stdint.h> to avoid right-shift by 32 on a 32-bit host by comparing SIZE_MAX to UINT32_MAX, since `value` is a size_t. Found by building on NetBSD/macppc with -Wshift-count-overflow (which is default on in the pkgsrc setup, which this is from). ./third-party/ArenaAlloc/arenaallocimpl.h:111:22: warning: right shift count >= width of type [-Wshift-count-overflow] 111 | value |= value >> 32; | ~~~~~~^~~~~
This commit is contained in:
parent
34f026e444
commit
0b51752974
4
src/third-party/ArenaAlloc/arenaallocimpl.h
vendored
4
src/third-party/ArenaAlloc/arenaallocimpl.h
vendored
@ -13,6 +13,8 @@
|
||||
#include <stdio.h>
|
||||
#endif
|
||||
|
||||
#include <stdint.h>
|
||||
|
||||
namespace ArenaAlloc
|
||||
{
|
||||
|
||||
@ -108,7 +110,9 @@ namespace ArenaAlloc
|
||||
value |= value >> 4;
|
||||
value |= value >> 8;
|
||||
value |= value >> 16;
|
||||
#if SIZE_MAX > UINT32_MAX
|
||||
value |= value >> 32;
|
||||
#endif
|
||||
|
||||
return value + 1;
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user