Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
[sonar] Handle default case in switch statements.
authorArnaud Giersch <arnaud.giersch@univ-fcomte.fr>
Thu, 11 Jul 2019 08:50:52 +0000 (10:50 +0200)
committerArnaud Giersch <arnaud.giersch@univ-fcomte.fr>
Thu, 11 Jul 2019 12:45:55 +0000 (14:45 +0200)
src/mc/compare.cpp
teshsuite/mc/random-bug/random-bug.cpp

index e2adf2d..2ad0a48 100644 (file)
@@ -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;
 }
index 23e96cb..6f8463d 100644 (file)
@@ -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();
   }
 }