MDEV-20425: Fix -Wimplicit-fallthrough

With --skip-debug-assert, DBUG_ASSERT(false) will allow execution to
continue. Hence, we will need /* fall through */ after them.

Some DBUG_ASSERT(0) were replaced by break; when the switch () statement
was followed by DBUG_ASSERT(0).
This commit is contained in:
Marko Mäkelä 2019-08-30 12:51:37 +03:00
parent a379f151b1
commit f42a23178e
11 changed files with 16 additions and 7 deletions

View File

@ -1,4 +1,4 @@
/* Copyright (C) 2010, 2017, MariaDB Corporation Ab /* Copyright (C) 2010, 2019, MariaDB Corporation.
This program is free software; you can redistribute it and/or modify This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by it under the terms of the GNU General Public License as published by
@ -132,7 +132,8 @@ static bool set_one_value(ha_create_table_option *opt,
switch (opt->type) switch (opt->type)
{ {
case HA_OPTION_TYPE_SYSVAR: case HA_OPTION_TYPE_SYSVAR:
DBUG_ASSERT(0); // HA_OPTION_TYPE_SYSVAR's are replaced in resolve_sysvars() // HA_OPTION_TYPE_SYSVAR's are replaced in resolve_sysvars()
break; // to DBUG_ASSERT(0)
case HA_OPTION_TYPE_ULL: case HA_OPTION_TYPE_ULL:
{ {
ulonglong *val= (ulonglong*)value_ptr(base, opt); ulonglong *val= (ulonglong*)value_ptr(base, opt);

View File

@ -1,7 +1,7 @@
#ifndef FIELD_INCLUDED #ifndef FIELD_INCLUDED
#define FIELD_INCLUDED #define FIELD_INCLUDED
/* Copyright (c) 2000, 2015, Oracle and/or its affiliates. /* Copyright (c) 2000, 2015, Oracle and/or its affiliates.
Copyright (c) 2008, 2017, MariaDB Corporation. Copyright (c) 2008, 2019, MariaDB Corporation.
This program is free software; you can redistribute it and/or modify This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by it under the terms of the GNU General Public License as published by
@ -461,6 +461,7 @@ inline bool is_temporal_type_with_date(enum_field_types type)
case MYSQL_TYPE_DATETIME2: case MYSQL_TYPE_DATETIME2:
case MYSQL_TYPE_TIMESTAMP2: case MYSQL_TYPE_TIMESTAMP2:
DBUG_ASSERT(0); // field->real_type() should not get to here. DBUG_ASSERT(0); // field->real_type() should not get to here.
/* fall through */
default: default:
return false; return false;
} }

View File

@ -2911,6 +2911,7 @@ void st_select_lex_unit::print(String *str, enum_query_type query_type)
{ {
default: default:
DBUG_ASSERT(0); DBUG_ASSERT(0);
/* fall through */
case UNION_TYPE: case UNION_TYPE:
str->append(STRING_WITH_LEN(" union ")); str->append(STRING_WITH_LEN(" union "));
if (union_all) if (union_all)

View File

@ -3579,6 +3579,7 @@ mysql_execute_command(THD *thd)
case GET_NO_ARG: case GET_NO_ARG:
case GET_DISABLED: case GET_DISABLED:
DBUG_ASSERT(0); DBUG_ASSERT(0);
/* fall through */
case 0: case 0:
case GET_FLAGSET: case GET_FLAGSET:
case GET_ENUM: case GET_ENUM:

View File

@ -2569,6 +2569,7 @@ static const LEX_CSTRING *view_algorithm(TABLE_LIST *table)
return &merge; return &merge;
default: default:
DBUG_ASSERT(0); // never should happen DBUG_ASSERT(0); // never should happen
/* fall through */
case VIEW_ALGORITHM_UNDEFINED: case VIEW_ALGORITHM_UNDEFINED:
return &undefined; return &undefined;
} }

View File

@ -9114,7 +9114,7 @@ bool vers_select_conds_t::eq(const vers_select_conds_t &conds) const
case SYSTEM_TIME_ALL: case SYSTEM_TIME_ALL:
return true; return true;
case SYSTEM_TIME_BEFORE: case SYSTEM_TIME_BEFORE:
DBUG_ASSERT(0); break;
case SYSTEM_TIME_AS_OF: case SYSTEM_TIME_AS_OF:
return start.eq(conds.start); return start.eq(conds.start);
case SYSTEM_TIME_FROM_TO: case SYSTEM_TIME_FROM_TO:

View File

@ -826,6 +826,7 @@ static void fil_flush_low(fil_space_t* space, bool metadata = false)
switch (space->purpose) { switch (space->purpose) {
case FIL_TYPE_TEMPORARY: case FIL_TYPE_TEMPORARY:
ut_ad(0); // we already checked for this ut_ad(0); // we already checked for this
/* fall through */
case FIL_TYPE_TABLESPACE: case FIL_TYPE_TABLESPACE:
case FIL_TYPE_IMPORT: case FIL_TYPE_IMPORT:
fil_n_pending_tablespace_flushes++; fil_n_pending_tablespace_flushes++;

View File

@ -2135,7 +2135,7 @@ innobase_col_to_mysql(
case DATA_SYS: case DATA_SYS:
/* These column types should never be shipped to MySQL. */ /* These column types should never be shipped to MySQL. */
ut_ad(0); ut_ad(0);
/* fall through */
case DATA_FLOAT: case DATA_FLOAT:
case DATA_DOUBLE: case DATA_DOUBLE:
case DATA_DECIMAL: case DATA_DECIMAL:

View File

@ -754,7 +754,7 @@ mtr_t::Command::prepare_write()
switch (m_impl->m_log_mode) { switch (m_impl->m_log_mode) {
case MTR_LOG_SHORT_INSERTS: case MTR_LOG_SHORT_INSERTS:
ut_ad(0); ut_ad(0);
/* fall through (write no redo log) */ /* fall through */
case MTR_LOG_NO_REDO: case MTR_LOG_NO_REDO:
case MTR_LOG_NONE: case MTR_LOG_NONE:
ut_ad(m_impl->m_log.size() == 0); ut_ad(m_impl->m_log.size() == 0);

View File

@ -1790,6 +1790,7 @@ row_log_table_apply_insert(
break; break;
default: default:
ut_ad(0); ut_ad(0);
/* fall through */
case DB_INVALID_NULL: case DB_INVALID_NULL:
ut_ad(row == NULL); ut_ad(row == NULL);
return(error); return(error);
@ -2078,6 +2079,7 @@ row_log_table_apply_update(
break; break;
default: default:
ut_ad(0); ut_ad(0);
/* fall through */
case DB_INVALID_NULL: case DB_INVALID_NULL:
ut_ad(row == NULL); ut_ad(row == NULL);
return(error); return(error);

View File

@ -1,7 +1,7 @@
/***************************************************************************** /*****************************************************************************
Copyright (c) 1997, 2017, Oracle and/or its affiliates. All Rights Reserved. Copyright (c) 1997, 2017, Oracle and/or its affiliates. All Rights Reserved.
Copyright (c) 2017, 2018, MariaDB Corporation. Copyright (c) 2017, 2019, MariaDB Corporation.
This program is free software; you can redistribute it and/or modify it under This program is free software; you can redistribute it and/or modify it under
the terms of the GNU General Public License as published by the Free Software the terms of the GNU General Public License as published by the Free Software
@ -583,6 +583,7 @@ row_undo_ins(
switch (node->rec_type) { switch (node->rec_type) {
default: default:
ut_ad(!"wrong undo record type"); ut_ad(!"wrong undo record type");
/* fall through */
case TRX_UNDO_INSERT_REC: case TRX_UNDO_INSERT_REC:
/* Skip the clustered index (the first index) */ /* Skip the clustered index (the first index) */
node->index = dict_table_get_next_index(node->index); node->index = dict_table_get_next_index(node->index);