BUILD: Re-enable -Wimplicit-fallthrough

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
This commit is contained in:
Tim Duesterhus 2020-05-29 14:35:51 +02:00 committed by Willy Tarreau
parent 2fc761e827
commit 588b3148d9
8 changed files with 14 additions and 7 deletions

View File

@ -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)

View File

@ -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)

View 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 */

View File

@ -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;

View 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;

View 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);

View 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);

View 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;