From d9ad5a26270ca6504d6708603364f9b8f345c028 Mon Sep 17 00:00:00 2001 From: Rosen Penev Date: Sat, 4 Apr 2020 19:42:23 -0700 Subject: [PATCH] remove unreachable break statements Found with clang's -Wunreachable-code-break Signed-off-by: Rosen Penev --- src/builtin.cpp | 1 - src/builtin_argparse.cpp | 1 - src/builtin_bind.cpp | 1 - src/builtin_block.cpp | 2 -- src/builtin_builtin.cpp | 1 - src/builtin_command.cpp | 1 - src/builtin_commandline.cpp | 3 --- src/builtin_complete.cpp | 1 - src/builtin_contains.cpp | 1 - src/builtin_echo.cpp | 1 - src/builtin_exit.cpp | 1 - src/builtin_function.cpp | 1 - src/builtin_functions.cpp | 2 -- src/builtin_history.cpp | 2 -- src/builtin_jobs.cpp | 2 -- src/builtin_math.cpp | 1 - src/builtin_printf.cpp | 1 - src/builtin_pwd.cpp | 1 - src/builtin_read.cpp | 1 - src/builtin_return.cpp | 1 - src/builtin_set.cpp | 3 --- src/builtin_set_color.cpp | 1 - src/builtin_status.cpp | 1 - src/builtin_test.cpp | 1 - src/builtin_ulimit.cpp | 1 - src/builtin_wait.cpp | 1 - src/exec.cpp | 1 - src/expand.cpp | 1 - src/fish.cpp | 3 --- src/fish_indent.cpp | 4 ---- src/pager.cpp | 1 - src/parse_execution.cpp | 2 -- src/parse_productions.cpp | 1 - src/parse_util.cpp | 1 - src/utf8.cpp | 1 - src/wildcard.cpp | 1 - 36 files changed, 50 deletions(-) diff --git a/src/builtin.cpp b/src/builtin.cpp index 41e524086..3914f59a5 100644 --- a/src/builtin.cpp +++ b/src/builtin.cpp @@ -137,7 +137,6 @@ int parse_help_only_cmd_opts(struct help_only_cmd_opts_t &opts, int *optind, int } default: { DIE("unexpected retval from wgetopt_long"); - break; } } } diff --git a/src/builtin_argparse.cpp b/src/builtin_argparse.cpp index c4a4dd353..3e16d135c 100644 --- a/src/builtin_argparse.cpp +++ b/src/builtin_argparse.cpp @@ -398,7 +398,6 @@ static int parse_cmd_opts(argparse_cmd_opts_t &opts, int *optind, //!OCLINT(hig } default: { DIE("unexpected retval from wgetopt_long"); - break; } } } diff --git a/src/builtin_bind.cpp b/src/builtin_bind.cpp index 78522a4cc..3c7c088e1 100644 --- a/src/builtin_bind.cpp +++ b/src/builtin_bind.cpp @@ -404,7 +404,6 @@ int parse_cmd_opts(bind_cmd_opts_t &opts, int *optind, //!OCLINT(high ncss meth } default: { DIE("unexpected retval from wgetopt_long"); - break; } } } diff --git a/src/builtin_block.cpp b/src/builtin_block.cpp index f1f566553..fcf2dd3a2 100644 --- a/src/builtin_block.cpp +++ b/src/builtin_block.cpp @@ -61,7 +61,6 @@ static int parse_cmd_opts(block_cmd_opts_t &opts, int *optind, //!OCLINT(high n } default: { DIE("unexpected retval from wgetopt_long"); - break; } } } @@ -125,7 +124,6 @@ int builtin_block(parser_t &parser, io_streams_t &streams, wchar_t **argv) { } default: { DIE("unexpected scope"); - break; } } if (block) { diff --git a/src/builtin_builtin.cpp b/src/builtin_builtin.cpp index f04a9c32f..7e94ee2a1 100644 --- a/src/builtin_builtin.cpp +++ b/src/builtin_builtin.cpp @@ -54,7 +54,6 @@ static int parse_cmd_opts(builtin_cmd_opts_t &opts, int *optind, int argc, wchar } default: { DIE("unexpected retval from wgetopt_long"); - break; } } } diff --git a/src/builtin_command.cpp b/src/builtin_command.cpp index d63bdbefa..6de2347ac 100644 --- a/src/builtin_command.cpp +++ b/src/builtin_command.cpp @@ -63,7 +63,6 @@ static int parse_cmd_opts(command_cmd_opts_t &opts, int *optind, int argc, wchar } default: { DIE("unexpected retval from wgetopt_long"); - break; } } } diff --git a/src/builtin_commandline.cpp b/src/builtin_commandline.cpp index e8cf67f7f..bfa4211b2 100644 --- a/src/builtin_commandline.cpp +++ b/src/builtin_commandline.cpp @@ -74,7 +74,6 @@ static void replace_part(const wchar_t *begin, const wchar_t *end, const wchar_t } default: { DIE("unexpected append_mode"); - break; } } out.append(end); @@ -275,7 +274,6 @@ int builtin_commandline(parser_t &parser, io_streams_t &streams, wchar_t **argv) } default: { DIE("unexpected retval from wgetopt_long"); - break; } } } @@ -414,7 +412,6 @@ int builtin_commandline(parser_t &parser, io_streams_t &streams, wchar_t **argv) } default: { DIE("unexpected buffer_part"); - break; } } diff --git a/src/builtin_complete.cpp b/src/builtin_complete.cpp index 6bdc11592..38d3873bb 100644 --- a/src/builtin_complete.cpp +++ b/src/builtin_complete.cpp @@ -261,7 +261,6 @@ int builtin_complete(parser_t &parser, io_streams_t &streams, wchar_t **argv) { } default: { DIE("unexpected retval from wgetopt_long"); - break; } } } diff --git a/src/builtin_contains.cpp b/src/builtin_contains.cpp index a9e018859..91ddb3c14 100644 --- a/src/builtin_contains.cpp +++ b/src/builtin_contains.cpp @@ -48,7 +48,6 @@ static int parse_cmd_opts(contains_cmd_opts_t &opts, int *optind, int argc, wcha } default: { DIE("unexpected retval from wgetopt_long"); - break; } } } diff --git a/src/builtin_echo.cpp b/src/builtin_echo.cpp index d2bd798f1..bac2adf85 100644 --- a/src/builtin_echo.cpp +++ b/src/builtin_echo.cpp @@ -56,7 +56,6 @@ static int parse_cmd_opts(echo_cmd_opts_t &opts, int *optind, int argc, wchar_t } default: { DIE("unexpected retval from wgetopt_long"); - break; } } } diff --git a/src/builtin_exit.cpp b/src/builtin_exit.cpp index 920107116..8073dee53 100644 --- a/src/builtin_exit.cpp +++ b/src/builtin_exit.cpp @@ -49,7 +49,6 @@ static int parse_cmd_opts(exit_cmd_opts_t &opts, int *optind, //!OCLINT(high nc } default: { DIE("unexpected retval from wgetopt_long"); - break; } } } diff --git a/src/builtin_function.cpp b/src/builtin_function.cpp index ab10aeff7..065603e4f 100644 --- a/src/builtin_function.cpp +++ b/src/builtin_function.cpp @@ -164,7 +164,6 @@ static int parse_cmd_opts(function_cmd_opts_t &opts, int *optind, //!OCLINT(hig } default: { DIE("unexpected retval from wgetopt_long"); - break; } } } diff --git a/src/builtin_functions.cpp b/src/builtin_functions.cpp index bfd840e41..aaec72d0b 100644 --- a/src/builtin_functions.cpp +++ b/src/builtin_functions.cpp @@ -120,7 +120,6 @@ static int parse_cmd_opts(functions_cmd_opts_t &opts, int *optind, //!OCLINT(hi } default: { DIE("unexpected retval from wgetopt_long"); - break; } } } @@ -194,7 +193,6 @@ static wcstring functions_def(const wcstring &name) { case event_type_t::any: default: { DIE("unexpected next->type"); - break; } } } diff --git a/src/builtin_history.cpp b/src/builtin_history.cpp index 6facf2bbb..0009f58d2 100644 --- a/src/builtin_history.cpp +++ b/src/builtin_history.cpp @@ -191,7 +191,6 @@ static int parse_cmd_opts(history_cmd_opts_t &opts, int *optind, //!OCLINT(high } default: { DIE("unexpected retval from wgetopt_long"); - break; } } } @@ -306,7 +305,6 @@ int builtin_history(parser_t &parser, io_streams_t &streams, wchar_t **argv) { } case HIST_UNDEF: { DIE("Unexpected HIST_UNDEF seen"); - break; } } diff --git a/src/builtin_jobs.cpp b/src/builtin_jobs.cpp index e8065666e..6b0aa84fb 100644 --- a/src/builtin_jobs.cpp +++ b/src/builtin_jobs.cpp @@ -105,7 +105,6 @@ static void builtin_jobs_print(const job_t *j, int mode, int header, io_streams_ } default: { DIE("unexpected mode"); - break; } } } @@ -165,7 +164,6 @@ int builtin_jobs(parser_t &parser, io_streams_t &streams, wchar_t **argv) { } default: { DIE("unexpected retval from wgetopt_long"); - break; } } } diff --git a/src/builtin_math.cpp b/src/builtin_math.cpp index be998b1e1..ac0caee6b 100644 --- a/src/builtin_math.cpp +++ b/src/builtin_math.cpp @@ -76,7 +76,6 @@ static int parse_cmd_opts(math_cmd_opts_t &opts, int *optind, //!OCLINT(high nc } default: { DIE("unexpected retval from wgetopt_long"); - break; } } } diff --git a/src/builtin_printf.cpp b/src/builtin_printf.cpp index 8b46a20ba..662d24a58 100644 --- a/src/builtin_printf.cpp +++ b/src/builtin_printf.cpp @@ -570,7 +570,6 @@ void builtin_printf_state_t::print_direc(const wchar_t *start, size_t length, wc } default: { DIE("unexpected opt"); - break; } } } diff --git a/src/builtin_pwd.cpp b/src/builtin_pwd.cpp index 6216230f5..e3619881f 100644 --- a/src/builtin_pwd.cpp +++ b/src/builtin_pwd.cpp @@ -43,7 +43,6 @@ int builtin_pwd(parser_t &parser, io_streams_t &streams, wchar_t **argv) { } default: { DIE("unexpected retval from wgetopt_long"); - break; } } } diff --git a/src/builtin_read.cpp b/src/builtin_read.cpp index 93d67409b..1e3d78097 100644 --- a/src/builtin_read.cpp +++ b/src/builtin_read.cpp @@ -186,7 +186,6 @@ static int parse_cmd_opts(read_cmd_opts_t &opts, int *optind, //!OCLINT(high nc } default: { DIE("unexpected retval from wgetopt_long"); - break; } } } diff --git a/src/builtin_return.cpp b/src/builtin_return.cpp index 767f503cb..8c0fb302b 100644 --- a/src/builtin_return.cpp +++ b/src/builtin_return.cpp @@ -48,7 +48,6 @@ static int parse_cmd_opts(return_cmd_opts_t &opts, int *optind, //!OCLINT(high } default: { DIE("unexpected retval from wgetopt_long"); - break; } } } diff --git a/src/builtin_set.cpp b/src/builtin_set.cpp index 9e20f4a96..2f7632ef1 100644 --- a/src/builtin_set.cpp +++ b/src/builtin_set.cpp @@ -163,7 +163,6 @@ static int parse_cmd_opts(set_cmd_opts_t &opts, int *optind, //!OCLINT(high ncs } default: { DIE("unexpected retval from wgetopt_long"); - break; } } } @@ -336,7 +335,6 @@ static void handle_env_return(int retval, const wchar_t *cmd, const wchar_t *key } default: { DIE("unexpected vars.set() ret val"); - break; } } } @@ -572,7 +570,6 @@ static void show_scope(const wchar_t *var_name, int scope, io_streams_t &streams } default: { DIE("invalid scope"); - break; } } diff --git a/src/builtin_set_color.cpp b/src/builtin_set_color.cpp index f820a3539..66acaf470 100644 --- a/src/builtin_set_color.cpp +++ b/src/builtin_set_color.cpp @@ -145,7 +145,6 @@ int builtin_set_color(parser_t &parser, io_streams_t &streams, wchar_t **argv) { } default: { DIE("unexpected retval from wgetopt_long"); - break; } } } diff --git a/src/builtin_status.cpp b/src/builtin_status.cpp index e35de167c..47e567789 100644 --- a/src/builtin_status.cpp +++ b/src/builtin_status.cpp @@ -259,7 +259,6 @@ static int parse_cmd_opts(status_cmd_opts_t &opts, int *optind, //!OCLINT(high } default: { DIE("unexpected retval from wgetopt_long"); - break; } } } diff --git a/src/builtin_test.cpp b/src/builtin_test.cpp index c2007f0dd..7f15c2efd 100644 --- a/src/builtin_test.cpp +++ b/src/builtin_test.cpp @@ -517,7 +517,6 @@ unique_ptr test_parser::parse_expression(unsigned int start, unsigne switch (argc) { case 0: { DIE("argc should not be zero"); // should have been caught by the above test - break; } case 1: { return error(L"Missing argument at index %u", start + 1); diff --git a/src/builtin_ulimit.cpp b/src/builtin_ulimit.cpp index 3fda263d1..df9621538 100644 --- a/src/builtin_ulimit.cpp +++ b/src/builtin_ulimit.cpp @@ -253,7 +253,6 @@ int builtin_ulimit(parser_t &parser, io_streams_t &streams, wchar_t **argv) { } default: { DIE("unexpected retval from wgetopt_long"); - break; } } } diff --git a/src/builtin_wait.cpp b/src/builtin_wait.cpp index 25a4b2328..c02edae96 100644 --- a/src/builtin_wait.cpp +++ b/src/builtin_wait.cpp @@ -205,7 +205,6 @@ int builtin_wait(parser_t &parser, io_streams_t &streams, wchar_t **argv) { } default: { DIE("unexpected retval from wgetopt_long"); - break; } } } diff --git a/src/exec.cpp b/src/exec.cpp index 793905c4b..30c831f00 100644 --- a/src/exec.cpp +++ b/src/exec.cpp @@ -867,7 +867,6 @@ static bool exec_process_in_job(parser_t &parser, process_t *p, const std::share // We should have handled exec up above. DIE("process_type_t::exec process found in pipeline, where it should never be. " "Aborting."); - break; } } return true; diff --git a/src/expand.cpp b/src/expand.cpp index 9983ea856..942461dff 100644 --- a/src/expand.cpp +++ b/src/expand.cpp @@ -615,7 +615,6 @@ static expand_result_t expand_cmdsubst(wcstring input, parser_t &parser, } default: { DIE("unhandled parse_ret value"); - break; } } diff --git a/src/fish.cpp b/src/fish.cpp index c75c52a1c..7849724bc 100644 --- a/src/fish.cpp +++ b/src/fish.cpp @@ -346,7 +346,6 @@ static int fish_parse_opt(int argc, char **argv, fish_cmd_opts_t *opts) { printf("%*ls %ls\n", -name_width, cat->name, _(cat->description)); } exit(0); - break; } case 'p': { s_profiling_output_filename = optarg; @@ -360,7 +359,6 @@ static int fish_parse_opt(int argc, char **argv, fish_cmd_opts_t *opts) { case 'v': { std::fwprintf(stdout, _(L"%s, version %s\n"), PACKAGE_NAME, get_fish_version()); exit(0); - break; } case 'D': { char *end; @@ -381,7 +379,6 @@ static int fish_parse_opt(int argc, char **argv, fish_cmd_opts_t *opts) { default: { // We assume getopt_long() has already emitted a diagnostic msg. exit(1); - break; } } } diff --git a/src/fish_indent.cpp b/src/fish_indent.cpp index 5967f1e44..fa4b79ae6 100644 --- a/src/fish_indent.cpp +++ b/src/fish_indent.cpp @@ -573,12 +573,10 @@ int main(int argc, char *argv[]) { case 'h': { print_help("fish_indent", 1); exit(0); - break; } case 'v': { std::fwprintf(stderr, _(L"%ls, version %s\n"), program_name, get_fish_version()); exit(0); - break; } case 'w': { output_type = output_type_file; @@ -634,7 +632,6 @@ int main(int argc, char *argv[]) { default: { // We assume getopt_long() has already emitted a diagnostic msg. exit(1); - break; } } } @@ -708,7 +705,6 @@ int main(int argc, char *argv[]) { } case output_type_pygments_csv: { DIE("pygments_csv should have been handled above"); - break; } } diff --git a/src/pager.cpp b/src/pager.cpp index 672005b70..78f3bb091 100644 --- a/src/pager.cpp +++ b/src/pager.cpp @@ -732,7 +732,6 @@ bool pager_t::select_next_completion_in_direction(selection_motion_t direction, } default: { DIE("unknown cardinal direction"); - break; } } diff --git a/src/parse_execution.cpp b/src/parse_execution.cpp index fc1335c5d..2935fcdd1 100644 --- a/src/parse_execution.cpp +++ b/src/parse_execution.cpp @@ -869,7 +869,6 @@ end_execution_reason_t parse_execution_context_t::expand_arguments_from_nodes( } default: { DIE("unexpected expand_string() return value"); - break; } } @@ -1009,7 +1008,6 @@ end_execution_reason_t parse_execution_context_t::apply_variable_assignments( default: { DIE("unexpected expand_string() return value"); - break; } } wcstring_list_t vals; diff --git a/src/parse_productions.cpp b/src/parse_productions.cpp index a88f54208..6622ebd82 100644 --- a/src/parse_productions.cpp +++ b/src/parse_productions.cpp @@ -178,7 +178,6 @@ RESOLVE(statement) { return production_for(); } } - break; } case parse_token_type_pipe: case parse_token_type_redirection: diff --git a/src/parse_util.cpp b/src/parse_util.cpp index 9b90737e3..e4ccf6fc0 100644 --- a/src/parse_util.cpp +++ b/src/parse_util.cpp @@ -1014,7 +1014,6 @@ parser_test_error_bits_t parse_util_detect_errors_in_argument(tnode_t