]> git.ipfire.org Git - thirdparty/haproxy.git/commitdiff
BUILD: Re-enable -Wimplicit-fallthrough
authorTim Duesterhus <tim@bastelstu.be>
Fri, 29 May 2020 12:35:51 +0000 (14:35 +0200)
committerWilly Tarreau <w@1wt.eu>
Thu, 11 Jun 2020 14:49:37 +0000 (16:49 +0200)
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.

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

Makefile
src/acl.c
src/check.c
src/cli.c
src/hlua.c
src/peers.c
src/stream_interface.c
src/tcpcheck.c

index c4a8529e89c8e1c1c68adfcd157c471647315ff1..9d8d350de43dc1ef33111a48c4118a09958af6dd 100644 (file)
--- 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)
index c328844980ed8b043e9edd46207f6752121d0428..5fea5dcc2a76f993935e8d678a3ba40ac40c6435 100644 (file)
--- a/src/acl.c
+++ b/src/acl.c
@@ -607,6 +607,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)
@@ -619,6 +620,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)
index 18f83fa1b0a0fff2c5669c638398b4a747bd6e81..82f18e3a00ce5c351b567f0d4a5c45f238ccf71f 100644 (file)
@@ -445,7 +445,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 */
index f850dd7e54f1d850961903fc21ae28e7f134029e..a8d393403d04a82e69c0d7dc3871da49fb960838 100644 (file)
--- a/src/cli.c
+++ b/src/cli.c
@@ -1191,6 +1191,7 @@ static int cli_io_handler_show_cli_sock(struct appctx *appctx)
                                return 0;
                        }
                        appctx->st2 = STAT_ST_LIST;
+                       /* fall through */
 
                case STAT_ST_LIST:
                        if (global.stats_fe) {
@@ -1267,6 +1268,7 @@ static int cli_io_handler_show_cli_sock(struct appctx *appctx)
                                        appctx->ctx.cli.p0 = &bind_conf->by_fe; /* store the latest list node dumped */
                                }
                        }
+                       /* fall through */
                default:
                        appctx->st2 = STAT_ST_FIN;
                        return 1;
index 6a75e88f9c8db4cdc474995f86f7b99765ab82e4..18c830778c777ceeb6527ce5b6e51ed5025c4a38 100644 (file)
@@ -6255,6 +6255,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);
+               /* fall through */
 
        default:
                return 0;
@@ -6388,6 +6389,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);
+               /* fall through */
 
        default:
                return 0;
index 478cbd2e67d39874f86cd1f9ba2ea284c734e10b..f16ba8e7e7b7b9ee8fe5468cc595c75e253fdd1a 100644 (file)
@@ -2281,8 +2281,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) {
@@ -2328,8 +2328,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) {
@@ -2370,8 +2370,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;
@@ -2456,8 +2456,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);
index ef2fc0bee93aa62e72d9298115306a29b4557374..59cce13ac11bfe0c201d91f5b2f6641d3dad7e2c 100644 (file)
@@ -232,6 +232,7 @@ static void stream_int_shutw(struct stream_interface *si)
        case SI_ST_TAR:
                /* Note that none of these states may happen with applets */
                si->state = SI_ST_DIS;
+               /* fall through */
        default:
                si->flags &= ~SI_FL_NOLINGER;
                si_rx_shut_blk(si);
@@ -1667,6 +1668,7 @@ static void stream_int_shutw_applet(struct stream_interface *si)
                /* Note that none of these states may happen with applets */
                si_applet_release(si);
                si->state = SI_ST_DIS;
+               /* fall through */
        default:
                si->flags &= ~SI_FL_NOLINGER;
                si_rx_shut_blk(si);
index 2b7c0c5def83ad984f1c674f06cb64e2dc03d726..893c2252b62b55a075a36dfda08d9bb7df12c53b 100644 (file)
@@ -3565,7 +3565,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;