From: Arnaud Giersch Date: Thu, 11 Jul 2019 08:50:52 +0000 (+0200) Subject: [sonar] Handle default case in switch statements. X-Git-Tag: v3.24~316 X-Git-Url: http://info.iut-bm.univ-fcomte.fr/pub/gitweb/simgrid.git/commitdiff_plain/5ce2cc84f1f1154453e9534505c394fbd2b89e05?ds=sidebyside [sonar] Handle default case in switch statements. --- diff --git a/src/mc/compare.cpp b/src/mc/compare.cpp index e2adf2dc52..2ad0a481aa 100644 --- a/src/mc/compare.cpp +++ b/src/mc/compare.cpp @@ -738,6 +738,10 @@ static int compare_heap_area_with_type(simgrid::mc::StateComparator& state, cons case DW_TAG_union_type: return not heap_area_equal_without_type(state, real_area1, real_area2, snapshot1, snapshot2, previous, type->byte_size, check_ignore); + + default: + XBT_VERB("Unknown case: %d", type->type); + break; } return 0; } diff --git a/teshsuite/mc/random-bug/random-bug.cpp b/teshsuite/mc/random-bug/random-bug.cpp index 23e96cb34f..6f8463d135 100644 --- a/teshsuite/mc/random-bug/random-bug.cpp +++ b/teshsuite/mc/random-bug/random-bug.cpp @@ -18,16 +18,13 @@ static void app() int x = MC_random(0, 5); int y = MC_random(0, 5); - switch (behavior) { - case ABORT: - abort(); - case ASSERT: - MC_assert(x != 3 || y != 4); - break; - case PRINTF: - if (x == 3 && y == 4) - XBT_ERROR("Error reached"); - break; + if (behavior == ASSERT) { + MC_assert(x != 3 || y != 4); + } else if (behavior == PRINTF) { + if (x == 3 && y == 4) + XBT_ERROR("Error reached"); + } else { // behavior == ABORT + abort(); } }