BUILD: hash: use __fallthrough in hash_djb2()

This avoids 5 build warnings when preprocessing happens before compiling
with gcc >= 7.
This commit is contained in:
Willy Tarreau 2022-11-14 07:18:42 +01:00
parent 7910825409
commit cff89874ea
1 changed files with 7 additions and 6 deletions

View File

@ -14,6 +14,7 @@
*/
#include <haproxy/compiler.h>
#include <haproxy/hash.h>
@ -62,12 +63,12 @@ unsigned int hash_djb2(const void *input, int len)
hash = ((hash << 5) + hash) + *key++;
}
switch (len) {
case 7: hash = ((hash << 5) + hash) + *key++; /* fallthrough... */
case 6: hash = ((hash << 5) + hash) + *key++; /* fallthrough... */
case 5: hash = ((hash << 5) + hash) + *key++; /* fallthrough... */
case 4: hash = ((hash << 5) + hash) + *key++; /* fallthrough... */
case 3: hash = ((hash << 5) + hash) + *key++; /* fallthrough... */
case 2: hash = ((hash << 5) + hash) + *key++; /* fallthrough... */
case 7: hash = ((hash << 5) + hash) + *key++; __fallthrough;
case 6: hash = ((hash << 5) + hash) + *key++; __fallthrough;
case 5: hash = ((hash << 5) + hash) + *key++; __fallthrough;
case 4: hash = ((hash << 5) + hash) + *key++; __fallthrough;
case 3: hash = ((hash << 5) + hash) + *key++; __fallthrough;
case 2: hash = ((hash << 5) + hash) + *key++; __fallthrough;
case 1: hash = ((hash << 5) + hash) + *key++; break;
default: /* case 0: */ break;
}