Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fixed gcc fallthrough warnings #46

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
76 changes: 39 additions & 37 deletions src/MurmurHash3.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -114,9 +114,9 @@ void MurmurHash3_x86_32 ( const void * key, int len,
k1 *= c1;
k1 = ROTL32(k1,15);
k1 *= c2;

h1 ^= k1;
h1 = ROTL32(h1,13);
h1 = ROTL32(h1,13);
h1 = h1*5+0xe6546b64;
}

Expand All @@ -130,9 +130,12 @@ void MurmurHash3_x86_32 ( const void * key, int len,
switch(len & 3)
{
case 3: k1 ^= tail[2] << 16;
/* fallthrough */
case 2: k1 ^= tail[1] << 8;
/* fallthrough */
case 1: k1 ^= tail[0];
k1 *= c1; k1 = ROTL32(k1,15); k1 *= c2; h1 ^= k1;
/* fallthrough */
};

//----------
Expand All @@ -143,7 +146,7 @@ void MurmurHash3_x86_32 ( const void * key, int len,
h1 = fmix32(h1);

*(uint32_t*)out = h1;
}
}

//-----------------------------------------------------------------------------

Expand All @@ -158,9 +161,9 @@ void MurmurHash3_x86_128 ( const void * key, const int len,
uint32_t h3 = seed;
uint32_t h4 = seed;

const uint32_t c1 = 0x239b961b;
const uint32_t c1 = 0x239b961b;
const uint32_t c2 = 0xab0e9789;
const uint32_t c3 = 0x38b34ae5;
const uint32_t c3 = 0x38b34ae5;
const uint32_t c4 = 0xa1e38b93;

//----------
Expand Down Expand Up @@ -204,28 +207,28 @@ void MurmurHash3_x86_128 ( const void * key, const int len,

switch(len & 15)
{
case 15: k4 ^= tail[14] << 16;
case 14: k4 ^= tail[13] << 8;
case 15: k4 ^= tail[14] << 16; /* fallthrough */
case 14: k4 ^= tail[13] << 8; /* fallthrough */
case 13: k4 ^= tail[12] << 0;
k4 *= c4; k4 = ROTL32(k4,18); k4 *= c1; h4 ^= k4;
k4 *= c4; k4 = ROTL32(k4,18); k4 *= c1; h4 ^= k4; /* fallthrough */

case 12: k3 ^= tail[11] << 24;
case 11: k3 ^= tail[10] << 16;
case 10: k3 ^= tail[ 9] << 8;
case 12: k3 ^= tail[11] << 24; /* fallthrough */
case 11: k3 ^= tail[10] << 16; /* fallthrough */
case 10: k3 ^= tail[ 9] << 8; /* fallthrough */
case 9: k3 ^= tail[ 8] << 0;
k3 *= c3; k3 = ROTL32(k3,17); k3 *= c4; h3 ^= k3;
k3 *= c3; k3 = ROTL32(k3,17); k3 *= c4; h3 ^= k3; /* fallthrough */

case 8: k2 ^= tail[ 7] << 24;
case 7: k2 ^= tail[ 6] << 16;
case 6: k2 ^= tail[ 5] << 8;
case 8: k2 ^= tail[ 7] << 24; /* fallthrough */
case 7: k2 ^= tail[ 6] << 16; /* fallthrough */
case 6: k2 ^= tail[ 5] << 8; /* fallthrough */
case 5: k2 ^= tail[ 4] << 0;
k2 *= c2; k2 = ROTL32(k2,16); k2 *= c3; h2 ^= k2;
k2 *= c2; k2 = ROTL32(k2,16); k2 *= c3; h2 ^= k2; /* fallthrough */

case 4: k1 ^= tail[ 3] << 24;
case 3: k1 ^= tail[ 2] << 16;
case 2: k1 ^= tail[ 1] << 8;
case 4: k1 ^= tail[ 3] << 24; /* fallthrough */
case 3: k1 ^= tail[ 2] << 16; /* fallthrough */
case 2: k1 ^= tail[ 1] << 8; /* fallthrough */
case 1: k1 ^= tail[ 0] << 0;
k1 *= c1; k1 = ROTL32(k1,15); k1 *= c2; h1 ^= k1;
k1 *= c1; k1 = ROTL32(k1,15); k1 *= c2; h1 ^= k1; /* fallthrough */
};

//----------
Expand Down Expand Up @@ -293,24 +296,24 @@ void MurmurHash3_x64_128 ( const void * key, const int len,

switch(len & 15)
{
case 15: k2 ^= ((uint64_t)tail[14]) << 48;
case 14: k2 ^= ((uint64_t)tail[13]) << 40;
case 13: k2 ^= ((uint64_t)tail[12]) << 32;
case 12: k2 ^= ((uint64_t)tail[11]) << 24;
case 11: k2 ^= ((uint64_t)tail[10]) << 16;
case 10: k2 ^= ((uint64_t)tail[ 9]) << 8;
case 15: k2 ^= ((uint64_t)tail[14]) << 48; /* fallthrough */
case 14: k2 ^= ((uint64_t)tail[13]) << 40; /* fallthrough */
case 13: k2 ^= ((uint64_t)tail[12]) << 32; /* fallthrough */
case 12: k2 ^= ((uint64_t)tail[11]) << 24; /* fallthrough */
case 11: k2 ^= ((uint64_t)tail[10]) << 16; /* fallthrough */
case 10: k2 ^= ((uint64_t)tail[ 9]) << 8; /* fallthrough */
case 9: k2 ^= ((uint64_t)tail[ 8]) << 0;
k2 *= c2; k2 = ROTL64(k2,33); k2 *= c1; h2 ^= k2;

case 8: k1 ^= ((uint64_t)tail[ 7]) << 56;
case 7: k1 ^= ((uint64_t)tail[ 6]) << 48;
case 6: k1 ^= ((uint64_t)tail[ 5]) << 40;
case 5: k1 ^= ((uint64_t)tail[ 4]) << 32;
case 4: k1 ^= ((uint64_t)tail[ 3]) << 24;
case 3: k1 ^= ((uint64_t)tail[ 2]) << 16;
case 2: k1 ^= ((uint64_t)tail[ 1]) << 8;
k2 *= c2; k2 = ROTL64(k2,33); k2 *= c1; h2 ^= k2; /* fallthrough */

case 8: k1 ^= ((uint64_t)tail[ 7]) << 56; /* fallthrough */
case 7: k1 ^= ((uint64_t)tail[ 6]) << 48; /* fallthrough */
case 6: k1 ^= ((uint64_t)tail[ 5]) << 40; /* fallthrough */
case 5: k1 ^= ((uint64_t)tail[ 4]) << 32; /* fallthrough */
case 4: k1 ^= ((uint64_t)tail[ 3]) << 24; /* fallthrough */
case 3: k1 ^= ((uint64_t)tail[ 2]) << 16; /* fallthrough */
case 2: k1 ^= ((uint64_t)tail[ 1]) << 8; /* fallthrough */
case 1: k1 ^= ((uint64_t)tail[ 0]) << 0;
k1 *= c1; k1 = ROTL64(k1,31); k1 *= c2; h1 ^= k1;
k1 *= c1; k1 = ROTL64(k1,31); k1 *= c2; h1 ^= k1; /* fallthrough */
};

//----------
Expand All @@ -332,4 +335,3 @@ void MurmurHash3_x64_128 ( const void * key, const int len,
}

//-----------------------------------------------------------------------------