]> git.ipfire.org Git - thirdparty/haproxy.git/commitdiff
BUILD: hash: use __fallthrough in hash_djb2()
authorWilly Tarreau <w@1wt.eu>
Mon, 14 Nov 2022 06:18:42 +0000 (07:18 +0100)
committerWilly Tarreau <w@1wt.eu>
Mon, 14 Nov 2022 10:14:02 +0000 (11:14 +0100)
This avoids 5 build warnings when preprocessing happens before compiling
with gcc >= 7.

src/hash.c

index a20b90cc04c690bad57520b0f2d5baef61b5649a..5c92e944f84c023a5cc3aeec82e289958c67f0eb 100644 (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;
        }