From 4f4d34e664d1273cbde55c27169c31645258a1db Mon Sep 17 00:00:00 2001 From: Kurtis Rader Date: Tue, 1 Nov 2016 22:36:30 -0700 Subject: [PATCH] lint: missing break in switch statement --- src/builtin.cpp | 16 ++++++++++++---- src/builtin_printf.cpp | 35 ++++++++++++++++++++++------------- src/builtin_test.cpp | 2 +- src/env.cpp | 2 +- src/event.cpp | 5 ++++- src/exec.cpp | 6 +++--- src/expand.cpp | 1 + src/fish.cpp | 3 +++ src/pager.cpp | 9 +++++---- src/parse_tree.cpp | 2 +- src/parser.cpp | 2 +- src/path.cpp | 1 + src/tokenizer.cpp | 8 ++++++-- 13 files changed, 61 insertions(+), 31 deletions(-) diff --git a/src/builtin.cpp b/src/builtin.cpp index 61572fdb4..2740c119e 100644 --- a/src/builtin.cpp +++ b/src/builtin.cpp @@ -665,6 +665,7 @@ static int builtin_block(parser_t &parser, io_streams_t &streams, wchar_t **argv } case GLOBAL: { block = NULL; + break; } case UNSET: { while (block != NULL && block->type() != FUNCTION_CALL && @@ -672,6 +673,7 @@ static int builtin_block(parser_t &parser, io_streams_t &streams, wchar_t **argv // Set it in function scope block = parser.block_at_index(++block_idx); } + break; } default: { DIE("unexpected scope"); @@ -962,7 +964,10 @@ static wcstring functions_def(const wcstring &name) { append_format(out, L" --on-event %ls", next->str_param1.c_str()); break; } - default: { DIE("unexpected next->type"); } + default: { + DIE("unexpected next->type"); + break; + } } } @@ -1361,7 +1366,7 @@ static int builtin_echo(parser_t &parser, io_streams_t &streams, wchar_t **argv) } default: { DIE("unexpected character in builtin_echo argument"); - abort(); + break; } } } @@ -2854,7 +2859,7 @@ static const wcstring hist_cmd_to_string(hist_cmd_t hist_cmd) { return L"save"; default: DIE("unhandled hist_cmd_t constant"); - abort(); + break; } } @@ -3014,7 +3019,10 @@ static int builtin_history(parser_t &parser, io_streams_t &streams, wchar_t **ar w.nextchar = NULL; break; } - default: { DIE("unexpected retval from wgetopt_long"); } + default: { + DIE("unexpected retval from wgetopt_long"); + break; + } } } diff --git a/src/builtin_printf.cpp b/src/builtin_printf.cpp index d43927250..e2d2d14ad 100644 --- a/src/builtin_printf.cpp +++ b/src/builtin_printf.cpp @@ -508,42 +508,45 @@ void builtin_printf_state_t::print_direc(const wchar_t *start, size_t length, wc case L'G': { long double arg = string_to_scalar_type(argument, this); if (!have_field_width) { - if (!have_precision) + if (!have_precision) { this->append_format_output(fmt.c_str(), arg); - else + } else { this->append_format_output(fmt.c_str(), precision, arg); + } } else { - if (!have_precision) + if (!have_precision) { this->append_format_output(fmt.c_str(), field_width, arg); - else + } else { this->append_format_output(fmt.c_str(), field_width, precision, arg); + } } break; } case L'c': { - if (!have_field_width) + if (!have_field_width) { this->append_format_output(fmt.c_str(), *argument); - else + } else { this->append_format_output(fmt.c_str(), field_width, *argument); + } break; } case L's': { if (!have_field_width) { if (!have_precision) { this->append_format_output(fmt.c_str(), argument); - } else + } else { this->append_format_output(fmt.c_str(), precision, argument); + } } else { - if (!have_precision) + if (!have_precision) { this->append_format_output(fmt.c_str(), field_width, argument); - else + } else { this->append_format_output(fmt.c_str(), field_width, precision, argument); + } } break; } default: { - // TODO: Determine if this should call DIE() - // WTF DIE("unexpected opt"); break; } @@ -615,7 +618,10 @@ int builtin_printf_state_t::print_formatted(const wchar_t *format, int argc, wch modify_allowed_format_specifiers(ok, "cs", false); break; } - default: { goto no_more_flag_characters; } + default: { + goto no_more_flag_characters; + break; + } } } no_more_flag_characters:; @@ -693,7 +699,10 @@ int builtin_printf_state_t::print_formatted(const wchar_t *format, int argc, wch f += print_esc(f, false); break; } - default: { this->append_output(*f); } + default: { + this->append_output(*f); + break; + } } } return save_argc - argc; diff --git a/src/builtin_test.cpp b/src/builtin_test.cpp index b18e35707..cc2fcea23 100644 --- a/src/builtin_test.cpp +++ b/src/builtin_test.cpp @@ -519,7 +519,7 @@ expression *test_parser::parse_expression(unsigned int start, unsigned int end) switch (argc) { case 0: { DIE("argc should not be zero"); // should have been caught by the above test - abort(); + break; } case 1: { return error(L"Missing argument at index %u", start + 1); diff --git a/src/env.cpp b/src/env.cpp index 5c773bb70..e5c61eb7b 100644 --- a/src/env.cpp +++ b/src/env.cpp @@ -285,7 +285,7 @@ static void universal_callback(fish_message_type_t type, const wchar_t *name) { } default: { DIE("unhandled fish_message_type_t constant"); - abort(); + break; } } diff --git a/src/event.cpp b/src/event.cpp index c215d81fd..31651054c 100644 --- a/src/event.cpp +++ b/src/event.cpp @@ -230,7 +230,10 @@ static wcstring event_desc_compact(const event_t &event) { res = format_string(L"EVENT_GENERIC(%ls)", event.str_param1.c_str()); break; } - default: { res = format_string(L"unknown/illegal event(%x)", event.type); } + default: { + res = format_string(L"unknown/illegal event(%x)", event.type); + break; + } } if (event.function_name.size()) { return format_string(L"%ls: \"%ls\"", res.c_str(), event.function_name.c_str()); diff --git a/src/exec.cpp b/src/exec.cpp index d28917dcc..b3d3f5cc1 100644 --- a/src/exec.cpp +++ b/src/exec.cpp @@ -284,7 +284,7 @@ static bool io_transmogrify(const io_chain_t &in_chain, io_chain_t *out_chain, } default: { DIE("unhandled io_mode constant"); - abort(); + break; } } @@ -827,7 +827,7 @@ void exec_job(parser_t &parser, job_t *j) { case INTERNAL_EXEC: // We should have handled exec up above. DIE("INTERNAL_EXEC process found in pipeline, where it should never be. Aborting."); - abort(); + break; } if (exec_error) { @@ -1089,7 +1089,7 @@ void exec_job(parser_t &parser, job_t *j) { case INTERNAL_EXEC: { // We should have handled exec up above. DIE("INTERNAL_EXEC process found in pipeline, where it should never be. Aborting."); - abort(); + break; } } diff --git a/src/expand.cpp b/src/expand.cpp index 946f537f2..bee4c3ad7 100644 --- a/src/expand.cpp +++ b/src/expand.cpp @@ -982,6 +982,7 @@ static expand_error_t expand_brackets(const wcstring &instr, expand_flags_t flag } case BRACKET_SEP: { if (bracket_count == 1) last_sep = pos; + break; } } } diff --git a/src/fish.cpp b/src/fish.cpp index 5a135b396..cc84686c0 100644 --- a/src/fish.cpp +++ b/src/fish.cpp @@ -314,6 +314,7 @@ static int fish_parse_opt(int argc, char **argv, std::vector *cmds) case 0: { fwprintf(stderr, _(L"getopt_long() unexpectedly returned zero\n")); exit(127); + break; } case 'c': { cmds->push_back(optarg); @@ -358,6 +359,7 @@ static int fish_parse_opt(int argc, char **argv, std::vector *cmds) case 'v': { fwprintf(stdout, _(L"%s, version %s\n"), PACKAGE_NAME, get_fish_version()); exit(0); + break; } case 'D': { char *end; @@ -377,6 +379,7 @@ static int fish_parse_opt(int argc, char **argv, std::vector *cmds) default: { // We assume getopt_long() has already emitted a diagnostic msg. exit(1); + break; } } } diff --git a/src/pager.cpp b/src/pager.cpp index 6036e7ca9..0b33ae21a 100644 --- a/src/pager.cpp +++ b/src/pager.cpp @@ -616,7 +616,7 @@ bool pager_t::select_next_completion_in_direction(selection_direction_t directio } default: { DIE("unhandled selection_direction_t constant"); - abort(); + break; } } } @@ -649,10 +649,11 @@ bool pager_t::select_next_completion_in_direction(selection_direction_t directio switch (direction) { case direction_page_north: { - if (current_row > page_height) + if (current_row > page_height) { current_row = current_row - page_height; - else + } else { current_row = 0; + } break; } case direction_north: { @@ -712,7 +713,7 @@ bool pager_t::select_next_completion_in_direction(selection_direction_t directio } default: { DIE("unknown cardinal direction"); - abort(); + break; } } diff --git a/src/parse_tree.cpp b/src/parse_tree.cpp index 2d11c1d61..cb197ae26 100644 --- a/src/parse_tree.cpp +++ b/src/parse_tree.cpp @@ -333,7 +333,7 @@ static inline parse_token_type_t parse_token_type_from_tokenizer_token( fprintf(stderr, "Bad token type %d passed to %s\n", (int)tokenizer_token_type, __FUNCTION__); DIE("bad token type"); - abort(); + break; } } return result; diff --git a/src/parser.cpp b/src/parser.cpp index f3a9111dc..da5680a75 100644 --- a/src/parser.cpp +++ b/src/parser.cpp @@ -870,7 +870,7 @@ wcstring block_t::description() const { } default: { DIE("unhandled block_type_t constant"); - abort(); + break; } } diff --git a/src/path.cpp b/src/path.cpp index 2a71680ca..e4775cec5 100644 --- a/src/path.cpp +++ b/src/path.cpp @@ -84,6 +84,7 @@ static bool path_get_path_core(const wcstring &cmd, wcstring *out_path, default: { debug(1, MISSING_COMMAND_ERR_MSG, nxt_path.c_str()); wperror(L"access"); + break; } } } diff --git a/src/tokenizer.cpp b/src/tokenizer.cpp index 2f871645d..41743d7ae 100644 --- a/src/tokenizer.cpp +++ b/src/tokenizer.cpp @@ -219,6 +219,7 @@ void tokenizer_t::read_string() { if (!tok_is_string_character(*(this->buff), is_first)) { do_loop = 0; } + break; } } break; @@ -319,7 +320,7 @@ void tokenizer_t::read_string() { } default: { DIE("unexpected mode in read_string"); - abort(); + break; } } return; @@ -760,7 +761,10 @@ bool move_word_state_machine_t::consume_char(wchar_t c) { case move_word_style_whitespace: { return consume_char_whitespace(c); } - default: { abort(); } + default: { + DIE("unhandled style"); + break; + } } }