From a6c6d47c34f60557c93aa6f5f209e4b66528c3f1 Mon Sep 17 00:00:00 2001 From: Arnaud Giersch Date: Wed, 18 Oct 2017 15:18:02 +0200 Subject: [PATCH] Add default case to switch statements. --- include/xbt/future.hpp | 7 +++++++ src/mc/mc_dwarf.cpp | 4 ++++ src/mc/mc_request.cpp | 2 ++ src/simix/popping_generated.cpp | 3 ++- src/simix/simcalls.py | 3 ++- src/surf/xml/surfxml_sax_cb.cpp | 2 ++ src/xbt/automaton/automaton.c | 9 +++++++++ src/xbt/automaton/automatonparse_promela.c | 6 ++++++ src/xbt/log.c | 1 + 9 files changed, 35 insertions(+), 2 deletions(-) diff --git a/include/xbt/future.hpp b/include/xbt/future.hpp index 68040f532a..a7448c9525 100644 --- a/include/xbt/future.hpp +++ b/include/xbt/future.hpp @@ -14,6 +14,7 @@ #include #include #include +#include namespace simgrid { namespace xbt { @@ -53,6 +54,8 @@ public: case ResultStatus::exception: new (&exception_) T(that.exception); break; + default: + THROW_IMPOSSIBLE; } return *this; } @@ -74,6 +77,8 @@ public: new (&exception_) T(std::move(that.exception)); that.exception.~exception_ptr(); break; + default: + THROW_IMPOSSIBLE; } that.status_ = ResultStatus::invalid; return *this; @@ -94,6 +99,8 @@ public: case ResultStatus::exception: exception_.~exception_ptr(); break; + default: + THROW_IMPOSSIBLE; } status_ = ResultStatus::invalid; } diff --git a/src/mc/mc_dwarf.cpp b/src/mc/mc_dwarf.cpp index e6414db3f7..440de3a4ae 100644 --- a/src/mc/mc_dwarf.cpp +++ b/src/mc/mc_dwarf.cpp @@ -681,6 +681,10 @@ static simgrid::mc::Type MC_dwarf_die_to_type( } switch (type.type) { + default: + XBT_DEBUG("Unhandled type: %d (%s)", type.type, simgrid::dwarf::tagname(type.type)); + break; + case DW_TAG_array_type: type.element_count = MC_dwarf_array_element_count(die, unit); // TODO, handle DW_byte_stride and (not) DW_bit_stride diff --git a/src/mc/mc_request.cpp b/src/mc/mc_request.cpp index b2afcbcac1..42d5c79432 100644 --- a/src/mc/mc_request.cpp +++ b/src/mc/mc_request.cpp @@ -205,6 +205,8 @@ std::string simgrid::mc::request_to_string(smx_simcall_t req, int value, simgrid case simgrid::mc::RequestType::internal: use_remote_comm = false; break; + default: + THROW_IMPOSSIBLE; } const char* type = nullptr; diff --git a/src/simix/popping_generated.cpp b/src/simix/popping_generated.cpp index dfed3e3ff0..13531f7a2c 100644 --- a/src/simix/popping_generated.cpp +++ b/src/simix/popping_generated.cpp @@ -231,6 +231,7 @@ case SIMCALL_RUN_BLOCKING: sg_host_get_name(simcall->issuer->host) ); break; - + default: + THROW_IMPOSSIBLE; } } diff --git a/src/simix/simcalls.py b/src/simix/simcalls.py index 093fe97b15..1e14a2a945 100755 --- a/src/simix/simcalls.py +++ b/src/simix/simcalls.py @@ -349,7 +349,8 @@ if __name__ == '__main__': fd.write(' sg_host_get_name(simcall->issuer->host)\n') fd.write(' );\n') fd.write(' break;\n') - fd.write('\n') + fd.write(' default:\n') + fd.write(' THROW_IMPOSSIBLE;\n') fd.write(' }\n') fd.write('}\n') diff --git a/src/surf/xml/surfxml_sax_cb.cpp b/src/surf/xml/surfxml_sax_cb.cpp index dfb894da7e..f67afd6ed4 100644 --- a/src/surf/xml/surfxml_sax_cb.cpp +++ b/src/surf/xml/surfxml_sax_cb.cpp @@ -818,6 +818,8 @@ void ETag_surfxml_zoneRoute() case A_surfxml_zoneRoute_symmetrical_NO: ASroute.symmetrical = false; break; + default: + THROW_IMPOSSIBLE; } sg_platf_new_route(&ASroute); diff --git a/src/xbt/automaton/automaton.c b/src/xbt/automaton/automaton.c index ee8be8e002..2e15eebb0a 100644 --- a/src/xbt/automaton/automaton.c +++ b/src/xbt/automaton/automaton.c @@ -7,6 +7,9 @@ #include "xbt/automaton.h" #include /* printf */ +#include + +XBT_LOG_NEW_DEFAULT_SUBCATEGORY(xbt_automaton, xbt, "Automaton"); struct xbt_automaton_propositional_symbol{ char* pred; @@ -82,6 +85,12 @@ xbt_automaton_exp_label_t xbt_automaton_exp_label_new(int type, ...){ p = va_arg(ap, char*); label->u.predicat = xbt_strdup(p); break; + case 4: + break; + default: + XBT_DEBUG("Invalid type: %d", type); + xbt_free(label); + break; } va_end(ap); return label; diff --git a/src/xbt/automaton/automatonparse_promela.c b/src/xbt/automaton/automatonparse_promela.c index f35835daad..c6abfb5634 100644 --- a/src/xbt/automaton/automatonparse_promela.c +++ b/src/xbt/automaton/automatonparse_promela.c @@ -12,6 +12,9 @@ #if HAVE_UNISTD_H # include /* isatty */ #endif +#include + +XBT_LOG_EXTERNAL_DEFAULT_CATEGORY(xbt_automaton); static xbt_automaton_t parsed_automaton; char* state_id_src; @@ -89,6 +92,9 @@ static xbt_automaton_exp_label_t new_label(int type, ...){ case 4 : label = xbt_automaton_exp_label_new(type); break; + default: + XBT_DEBUG("Invalid type: %d", type); + break; } va_end(ap); return label; diff --git a/src/xbt/log.c b/src/xbt/log.c index 8c0a3b4216..5479e4d968 100644 --- a/src/xbt/log.c +++ b/src/xbt/log.c @@ -108,6 +108,7 @@ static void xbt_log_connect_categories(void) XBT_LOG_CONNECT(xbt_dict_elm); XBT_LOG_CONNECT(xbt_dyn); XBT_LOG_CONNECT(xbt_ex); + XBT_LOG_CONNECT(xbt_automaton); XBT_LOG_CONNECT(xbt_backtrace); XBT_LOG_CONNECT(xbt_exception); XBT_LOG_CONNECT(xbt_graph); -- 2.20.1