diff --git a/src/builtin.cpp b/src/builtin.cpp index 331d05606..e0a37d29d 100644 --- a/src/builtin.cpp +++ b/src/builtin.cpp @@ -2831,7 +2831,8 @@ static const wcstring hist_cmd_to_string(hist_cmd_t hist_cmd) { case HIST_SAVE: return L"save"; default: - DIE("Unhandled history command"); + assert(0 && "Unhandled hist_cmd_t constant!"); + abort(); } } diff --git a/src/common.h b/src/common.h index 5798775de..380e101cf 100644 --- a/src/common.h +++ b/src/common.h @@ -131,14 +131,19 @@ enum selection_direction_t { inline bool selection_direction_is_cardinal(selection_direction_t dir) { switch (dir) { case direction_north: - case direction_page_north: case direction_east: - case direction_page_south: case direction_south: - case direction_west: { + case direction_west: + case direction_page_north: + case direction_page_south: { return true; } - default: { return false; } + case direction_next: + case direction_prev: + case direction_deselect: { + return false; + } + default: { abort(); } } } diff --git a/src/env.cpp b/src/env.cpp index b2b1a8e1e..cf0f0d02b 100644 --- a/src/env.cpp +++ b/src/env.cpp @@ -280,7 +280,10 @@ static void universal_callback(fish_message_type_t type, const wchar_t *name, co str = L"ERASE"; break; } - default: { break; } + default: { + assert(0 && "Unhandled fish_message_type_t constant!"); + abort(); + } } if (str) { diff --git a/src/exec.cpp b/src/exec.cpp index d79b1e7f4..d10efecd4 100644 --- a/src/exec.cpp +++ b/src/exec.cpp @@ -283,9 +283,8 @@ static bool io_transmogrify(const io_chain_t &in_chain, io_chain_t *out_chain, } default: { // Unknown type, should never happen. - fprintf(stderr, "Unknown io_mode %ld\n", (long)in->io_mode); + assert(0 && "Unhandled io_mode constant"); abort(); - break; } } diff --git a/src/history.cpp b/src/history.cpp index 55a5cff64..5e154c244 100644 --- a/src/history.cpp +++ b/src/history.cpp @@ -449,7 +449,7 @@ bool history_item_t::matches_search(const wcstring &term, enum history_search_ty } default: { sanity_lose(); - return false; + abort(); } } } diff --git a/src/pager.cpp b/src/pager.cpp index def797a9d..90e9aa8f4 100644 --- a/src/pager.cpp +++ b/src/pager.cpp @@ -3,6 +3,7 @@ // IWYU pragma: no_include #include #include +#include #include #include #include @@ -602,11 +603,14 @@ bool pager_t::select_next_completion_in_direction(selection_direction_t directio case direction_page_north: case direction_east: case direction_west: - case direction_deselect: - default: { + case direction_deselect: { // These do nothing. return false; } + default: { + assert(0 && "Unhandled selection_direction_t constant"); + abort(); + } } } diff --git a/src/parser.cpp b/src/parser.cpp index 5b9b6a08e..17ada81c0 100644 --- a/src/parser.cpp +++ b/src/parser.cpp @@ -3,6 +3,7 @@ #include #include +#include #include #include #include @@ -255,7 +256,7 @@ block_t *parser_t::block_at_index(size_t idx) { return idx < count ? block_stack.at(count - idx - 1) : NULL; } -block_t *const parser_t::current_block() { return block_stack.empty() ? NULL : block_stack.back(); } +block_t *parser_t::current_block() { return block_stack.empty() ? NULL : block_stack.back(); } void parser_t::forbid_function(const wcstring &function) { forbidden_function.push_back(function); } @@ -869,8 +870,8 @@ wcstring block_t::description() const { break; } default: { - append_format(result, L"unknown type %ld", (long)this->type()); - break; + assert(0 && "Unhandled block_type_t constant"); + abort(); } } diff --git a/src/parser.h b/src/parser.h index 36f01563f..301665ac1 100644 --- a/src/parser.h +++ b/src/parser.h @@ -271,7 +271,7 @@ class parser_t { block_t *block_at_index(size_t idx); /// Returns the current (innermost) block. - block_t *const current_block(); + block_t *current_block(); /// Count of blocks. size_t block_count() const { return block_stack.size(); } diff --git a/src/tokenizer.cpp b/src/tokenizer.cpp index 2bff944b8..cc19615c3 100644 --- a/src/tokenizer.cpp +++ b/src/tokenizer.cpp @@ -5,6 +5,7 @@ #include #include #include +#include #include #include #include @@ -759,7 +760,7 @@ bool move_word_state_machine_t::consume_char(wchar_t c) { case move_word_style_whitespace: { return consume_char_whitespace(c); } - default: { return false; } + default: { abort(); } } }