Getting rid of this warning is cleaner solved using a 'fall through' comment,
because it clarifies intent to a human reader.

This patch adjust a few places that cause -Wimplicit-fallthrough to trigger:

- Fix typos in the comment.
- Remove redundant 'no break' that trips up gcc from comment.
- Move the comment out of the block when the 'case' is completely surrounded
  by braces.
- Add comments where I could determine that the fall through was intentional.
- Add returns where the fall through technically was correct, but looked odd.

Changes tested on

    gcc (Debian 9.3.0-13) 9.3.0
    Copyright (C) 2019 Free Software Foundation, Inc.
    This is free software; see the source for copying conditions.  There is NO
    warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.

using

    make -j4 all TARGET=linux-glibc USE_OPENSSL=1 USE_LUA=1 USE_ZLIB=1 
USE_PCRE2=1 USE_PCRE2_JIT=1 USE_GETADDRINFO=1

After this patch is applied 3 warnings are still in place where I could not
determine what the correct code is. The one in pattern.c looks like an actual
bug, though.
---
 Makefile     | 1 -
 src/acl.c    | 2 ++
 src/checks.c | 4 ++--
 src/hlua.c   | 2 ++
 src/peers.c  | 8 ++++----
 5 files changed, 10 insertions(+), 7 deletions(-)

diff --git a/Makefile b/Makefile
index 4f1b59530..40184746d 100644
--- a/Makefile
+++ b/Makefile
@@ -185,7 +185,6 @@ SPEC_CFLAGS += $(call cc-nowarn,sign-compare)
 SPEC_CFLAGS += $(call cc-nowarn,unused-parameter)
 SPEC_CFLAGS += $(call cc-nowarn,clobbered)
 SPEC_CFLAGS += $(call cc-nowarn,missing-field-initializers)
-SPEC_CFLAGS += $(call cc-nowarn,implicit-fallthrough)
 SPEC_CFLAGS += $(call cc-nowarn,stringop-overflow)
 SPEC_CFLAGS += $(call cc-nowarn,cast-function-type)
 SPEC_CFLAGS += $(call cc-nowarn,string-plus-int)
diff --git a/src/acl.c b/src/acl.c
index fa8ae9238..f509e10fa 100644
--- a/src/acl.c
+++ b/src/acl.c
@@ -612,6 +612,7 @@ struct acl_expr *parse_acl_expr(const char **args, char 
**err, struct arg_list *
 
                                case STD_OP_GT:
                                        value++; /* gt = ge + 1 */
+                                       /* fall through */
 
                                case STD_OP_GE:
                                        if (expr->pat.parse == pat_parse_int)
@@ -624,6 +625,7 @@ struct acl_expr *parse_acl_expr(const char **args, char 
**err, struct arg_list *
 
                                case STD_OP_LT:
                                        value--; /* lt = le - 1 */
+                                       /* fall through */
 
                                case STD_OP_LE:
                                        if (expr->pat.parse == pat_parse_int)
diff --git a/src/checks.c b/src/checks.c
index b5270b07d..af0718080 100644
--- a/src/checks.c
+++ b/src/checks.c
@@ -457,7 +457,7 @@ void __health_adjust(struct server *s, short status)
                        if (s->check.health > s->check.rise)
                                s->check.health = s->check.rise + 1;
 
-                       /* no break - fall through */
+                       /* fall through */
 
                case HANA_ONERR_FAILCHK:
                /* simulate a failed health check */
@@ -5462,7 +5462,7 @@ static int check_proxy_tcpcheck(struct proxy *px)
                case TCPCHK_ACT_CONNECT:
                        if (!chk->comment && comment)
                                chk->comment = strdup(comment);
-                       /* fall though */
+                       /* fall through */
                case TCPCHK_ACT_ACTION_KW:
                        free(comment);
                        comment = NULL;
diff --git a/src/hlua.c b/src/hlua.c
index f0d7e0f9e..efbff48d8 100644
--- a/src/hlua.c
+++ b/src/hlua.c
@@ -6251,6 +6251,7 @@ static int hlua_sample_conv_wrapper(const struct arg 
*arg_p, struct sample *smp,
        case HLUA_E_ERR:
                /* Display log. */
                SEND_ERR(stream->be, "Lua converter '%s' returns an unknown 
error.\n", fcn->name);
+               return 0;
 
        default:
                return 0;
@@ -6384,6 +6385,7 @@ static int hlua_sample_fetch_wrapper(const struct arg 
*arg_p, struct sample *smp
        case HLUA_E_ERR:
                /* Display log. */
                SEND_ERR(smp->px, "Lua sample-fetch '%s' returns an unknown 
error.\n", fcn->name);
+               return 0;
 
        default:
                return 0;
diff --git a/src/peers.c b/src/peers.c
index 2e54ab94d..af54f17d9 100644
--- a/src/peers.c
+++ b/src/peers.c
@@ -2247,8 +2247,8 @@ switchstate:
                                appctx->ctx.peers.ptr = curpeer;
                                appctx->st0 = PEER_SESS_ST_SENDSUCCESS;
                                _HA_ATOMIC_ADD(&active_peers, 1);
-                               /* fall through */
                        }
+                               /* fall through */
                        case PEER_SESS_ST_SENDSUCCESS: {
                                prev_state = appctx->st0;
                                if (!curpeer) {
@@ -2294,8 +2294,8 @@ switchstate:
 
                                /* switch to the waiting statuscode state */
                                appctx->st0 = PEER_SESS_ST_GETSTATUS;
-                               /* fall through */
                        }
+                               /* fall through */
                        case PEER_SESS_ST_GETSTATUS: {
                                prev_state = appctx->st0;
                                if (!curpeer) {
@@ -2336,8 +2336,8 @@ switchstate:
                                }
                                _HA_ATOMIC_ADD(&connected_peers, 1);
                                appctx->st0 = PEER_SESS_ST_WAITMSG;
-                               /* fall through */
                        }
+                               /* fall through */
                        case PEER_SESS_ST_WAITMSG: {
                                uint32_t msg_len = 0;
                                char *msg_cur = trash.area;
@@ -2422,8 +2422,8 @@ send_msgs:
                                        goto out;
                                appctx->st0 = PEER_SESS_ST_END;
                                prev_state = appctx->st0;
-                               /* fall through */
                        }
+                               /* fall through */
                        case PEER_SESS_ST_END: {
                                if (prev_state == PEER_SESS_ST_WAITMSG)
                                        _HA_ATOMIC_SUB(&connected_peers, 1);
-- 
2.26.2


Reply via email to