lint: missing break in switch statement

This commit is contained in:
Kurtis Rader 2016-11-01 22:36:30 -07:00
parent f6047f02d6
commit 4f4d34e664
13 changed files with 61 additions and 31 deletions

View file

@ -665,6 +665,7 @@ static int builtin_block(parser_t &parser, io_streams_t &streams, wchar_t **argv
} }
case GLOBAL: { case GLOBAL: {
block = NULL; block = NULL;
break;
} }
case UNSET: { case UNSET: {
while (block != NULL && block->type() != FUNCTION_CALL && 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 // Set it in function scope
block = parser.block_at_index(++block_idx); block = parser.block_at_index(++block_idx);
} }
break;
} }
default: { default: {
DIE("unexpected scope"); 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()); append_format(out, L" --on-event %ls", next->str_param1.c_str());
break; 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: { default: {
DIE("unexpected character in builtin_echo argument"); 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"; return L"save";
default: default:
DIE("unhandled hist_cmd_t constant"); 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; w.nextchar = NULL;
break; break;
} }
default: { DIE("unexpected retval from wgetopt_long"); } default: {
DIE("unexpected retval from wgetopt_long");
break;
}
} }
} }

View file

@ -508,42 +508,45 @@ void builtin_printf_state_t::print_direc(const wchar_t *start, size_t length, wc
case L'G': { case L'G': {
long double arg = string_to_scalar_type<long double>(argument, this); long double arg = string_to_scalar_type<long double>(argument, this);
if (!have_field_width) { if (!have_field_width) {
if (!have_precision) if (!have_precision) {
this->append_format_output(fmt.c_str(), arg); this->append_format_output(fmt.c_str(), arg);
else } else {
this->append_format_output(fmt.c_str(), precision, arg); this->append_format_output(fmt.c_str(), precision, arg);
}
} else { } else {
if (!have_precision) if (!have_precision) {
this->append_format_output(fmt.c_str(), field_width, arg); this->append_format_output(fmt.c_str(), field_width, arg);
else } else {
this->append_format_output(fmt.c_str(), field_width, precision, arg); this->append_format_output(fmt.c_str(), field_width, precision, arg);
}
} }
break; break;
} }
case L'c': { case L'c': {
if (!have_field_width) if (!have_field_width) {
this->append_format_output(fmt.c_str(), *argument); this->append_format_output(fmt.c_str(), *argument);
else } else {
this->append_format_output(fmt.c_str(), field_width, *argument); this->append_format_output(fmt.c_str(), field_width, *argument);
}
break; break;
} }
case L's': { case L's': {
if (!have_field_width) { if (!have_field_width) {
if (!have_precision) { if (!have_precision) {
this->append_format_output(fmt.c_str(), argument); this->append_format_output(fmt.c_str(), argument);
} else } else {
this->append_format_output(fmt.c_str(), precision, argument); this->append_format_output(fmt.c_str(), precision, argument);
}
} else { } else {
if (!have_precision) if (!have_precision) {
this->append_format_output(fmt.c_str(), field_width, argument); this->append_format_output(fmt.c_str(), field_width, argument);
else } else {
this->append_format_output(fmt.c_str(), field_width, precision, argument); this->append_format_output(fmt.c_str(), field_width, precision, argument);
}
} }
break; break;
} }
default: { default: {
// TODO: Determine if this should call DIE()
// WTF
DIE("unexpected opt"); DIE("unexpected opt");
break; 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); modify_allowed_format_specifiers(ok, "cs", false);
break; break;
} }
default: { goto no_more_flag_characters; } default: {
goto no_more_flag_characters;
break;
}
} }
} }
no_more_flag_characters:; 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); f += print_esc(f, false);
break; break;
} }
default: { this->append_output(*f); } default: {
this->append_output(*f);
break;
}
} }
} }
return save_argc - argc; return save_argc - argc;

View file

@ -519,7 +519,7 @@ expression *test_parser::parse_expression(unsigned int start, unsigned int end)
switch (argc) { switch (argc) {
case 0: { case 0: {
DIE("argc should not be zero"); // should have been caught by the above test DIE("argc should not be zero"); // should have been caught by the above test
abort(); break;
} }
case 1: { case 1: {
return error(L"Missing argument at index %u", start + 1); return error(L"Missing argument at index %u", start + 1);

View file

@ -285,7 +285,7 @@ static void universal_callback(fish_message_type_t type, const wchar_t *name) {
} }
default: { default: {
DIE("unhandled fish_message_type_t constant"); DIE("unhandled fish_message_type_t constant");
abort(); break;
} }
} }

View file

@ -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()); res = format_string(L"EVENT_GENERIC(%ls)", event.str_param1.c_str());
break; 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()) { if (event.function_name.size()) {
return format_string(L"%ls: \"%ls\"", res.c_str(), event.function_name.c_str()); return format_string(L"%ls: \"%ls\"", res.c_str(), event.function_name.c_str());

View file

@ -284,7 +284,7 @@ static bool io_transmogrify(const io_chain_t &in_chain, io_chain_t *out_chain,
} }
default: { default: {
DIE("unhandled io_mode constant"); DIE("unhandled io_mode constant");
abort(); break;
} }
} }
@ -827,7 +827,7 @@ void exec_job(parser_t &parser, job_t *j) {
case INTERNAL_EXEC: case INTERNAL_EXEC:
// We should have handled exec up above. // We should have handled exec up above.
DIE("INTERNAL_EXEC process found in pipeline, where it should never be. Aborting."); DIE("INTERNAL_EXEC process found in pipeline, where it should never be. Aborting.");
abort(); break;
} }
if (exec_error) { if (exec_error) {
@ -1089,7 +1089,7 @@ void exec_job(parser_t &parser, job_t *j) {
case INTERNAL_EXEC: { case INTERNAL_EXEC: {
// We should have handled exec up above. // We should have handled exec up above.
DIE("INTERNAL_EXEC process found in pipeline, where it should never be. Aborting."); DIE("INTERNAL_EXEC process found in pipeline, where it should never be. Aborting.");
abort(); break;
} }
} }

View file

@ -982,6 +982,7 @@ static expand_error_t expand_brackets(const wcstring &instr, expand_flags_t flag
} }
case BRACKET_SEP: { case BRACKET_SEP: {
if (bracket_count == 1) last_sep = pos; if (bracket_count == 1) last_sep = pos;
break;
} }
} }
} }

View file

@ -314,6 +314,7 @@ static int fish_parse_opt(int argc, char **argv, std::vector<std::string> *cmds)
case 0: { case 0: {
fwprintf(stderr, _(L"getopt_long() unexpectedly returned zero\n")); fwprintf(stderr, _(L"getopt_long() unexpectedly returned zero\n"));
exit(127); exit(127);
break;
} }
case 'c': { case 'c': {
cmds->push_back(optarg); cmds->push_back(optarg);
@ -358,6 +359,7 @@ static int fish_parse_opt(int argc, char **argv, std::vector<std::string> *cmds)
case 'v': { case 'v': {
fwprintf(stdout, _(L"%s, version %s\n"), PACKAGE_NAME, get_fish_version()); fwprintf(stdout, _(L"%s, version %s\n"), PACKAGE_NAME, get_fish_version());
exit(0); exit(0);
break;
} }
case 'D': { case 'D': {
char *end; char *end;
@ -377,6 +379,7 @@ static int fish_parse_opt(int argc, char **argv, std::vector<std::string> *cmds)
default: { default: {
// We assume getopt_long() has already emitted a diagnostic msg. // We assume getopt_long() has already emitted a diagnostic msg.
exit(1); exit(1);
break;
} }
} }
} }

View file

@ -616,7 +616,7 @@ bool pager_t::select_next_completion_in_direction(selection_direction_t directio
} }
default: { default: {
DIE("unhandled selection_direction_t constant"); 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) { switch (direction) {
case direction_page_north: { case direction_page_north: {
if (current_row > page_height) if (current_row > page_height) {
current_row = current_row - page_height; current_row = current_row - page_height;
else } else {
current_row = 0; current_row = 0;
}
break; break;
} }
case direction_north: { case direction_north: {
@ -712,7 +713,7 @@ bool pager_t::select_next_completion_in_direction(selection_direction_t directio
} }
default: { default: {
DIE("unknown cardinal direction"); DIE("unknown cardinal direction");
abort(); break;
} }
} }

View file

@ -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, fprintf(stderr, "Bad token type %d passed to %s\n", (int)tokenizer_token_type,
__FUNCTION__); __FUNCTION__);
DIE("bad token type"); DIE("bad token type");
abort(); break;
} }
} }
return result; return result;

View file

@ -870,7 +870,7 @@ wcstring block_t::description() const {
} }
default: { default: {
DIE("unhandled block_type_t constant"); DIE("unhandled block_type_t constant");
abort(); break;
} }
} }

View file

@ -84,6 +84,7 @@ static bool path_get_path_core(const wcstring &cmd, wcstring *out_path,
default: { default: {
debug(1, MISSING_COMMAND_ERR_MSG, nxt_path.c_str()); debug(1, MISSING_COMMAND_ERR_MSG, nxt_path.c_str());
wperror(L"access"); wperror(L"access");
break;
} }
} }
} }

View file

@ -219,6 +219,7 @@ void tokenizer_t::read_string() {
if (!tok_is_string_character(*(this->buff), is_first)) { if (!tok_is_string_character(*(this->buff), is_first)) {
do_loop = 0; do_loop = 0;
} }
break;
} }
} }
break; break;
@ -319,7 +320,7 @@ void tokenizer_t::read_string() {
} }
default: { default: {
DIE("unexpected mode in read_string"); DIE("unexpected mode in read_string");
abort(); break;
} }
} }
return; return;
@ -760,7 +761,10 @@ bool move_word_state_machine_t::consume_char(wchar_t c) {
case move_word_style_whitespace: { case move_word_style_whitespace: {
return consume_char_whitespace(c); return consume_char_whitespace(c);
} }
default: { abort(); } default: {
DIE("unhandled style");
break;
}
} }
} }