PVS-Studio

This commit is contained in:
Alexey Milovidov 2021-05-03 18:25:14 +03:00
parent eea47a65d2
commit 9cbdcc1ab5
2 changed files with 10 additions and 11 deletions

View File

@ -91,39 +91,38 @@ inline UInt32 updateWeakHash32(const DB::UInt8 * pos, size_t size, DB::UInt32 up
{
if (size < 8)
{
DB::UInt64 value = 0;
auto * value_ptr = reinterpret_cast<unsigned char *>(&value);
UInt64 value = 0;
switch (size)
{
case 0:
break;
case 1:
__builtin_memcpy(value_ptr, pos, 1);
__builtin_memcpy(&value, pos, 1);
break;
case 2:
__builtin_memcpy(value_ptr, pos, 2);
__builtin_memcpy(&value, pos, 2);
break;
case 3:
__builtin_memcpy(value_ptr, pos, 3);
__builtin_memcpy(&value, pos, 3);
break;
case 4:
__builtin_memcpy(value_ptr, pos, 4);
__builtin_memcpy(&value, pos, 4);
break;
case 5:
__builtin_memcpy(value_ptr, pos, 5);
__builtin_memcpy(&value, pos, 5);
break;
case 6:
__builtin_memcpy(value_ptr, pos, 6);
__builtin_memcpy(&value, pos, 6);
break;
case 7:
__builtin_memcpy(value_ptr, pos, 7);
__builtin_memcpy(&value, pos, 7);
break;
default:
__builtin_unreachable();
}
value_ptr[7] = size;
reinterpret_cast<unsigned char *>(&value)[7] = size;
return intHashCRC32(value, updated_value);
}

View File

@ -85,7 +85,7 @@ public:
struct Counter
{
Counter() {}
Counter() = default; //-V730
Counter(const TKey & k, UInt64 c = 0, UInt64 e = 0, size_t h = 0)
: key(k), slot(0), hash(h), count(c), error(e) {}