Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
Add default case to switch statements.
authorArnaud Giersch <arnaud.giersch@univ-fcomte.fr>
Wed, 18 Oct 2017 13:18:02 +0000 (15:18 +0200)
committerArnaud Giersch <arnaud.giersch@univ-fcomte.fr>
Wed, 18 Oct 2017 16:45:42 +0000 (18:45 +0200)
include/xbt/future.hpp
src/mc/mc_dwarf.cpp
src/mc/mc_request.cpp
src/simix/popping_generated.cpp
src/simix/simcalls.py
src/surf/xml/surfxml_sax_cb.cpp
src/xbt/automaton/automaton.c
src/xbt/automaton/automatonparse_promela.c
src/xbt/log.c

index 68040f5..a7448c9 100644 (file)
@@ -14,6 +14,7 @@
 #include <stdexcept>
 #include <type_traits>
 #include <utility>
 #include <stdexcept>
 #include <type_traits>
 #include <utility>
+#include <xbt/ex.h>
 
 namespace simgrid {
 namespace xbt {
 
 namespace simgrid {
 namespace xbt {
@@ -53,6 +54,8 @@ public:
       case ResultStatus::exception:
         new (&exception_) T(that.exception);
         break;
       case ResultStatus::exception:
         new (&exception_) T(that.exception);
         break;
+      default:
+        THROW_IMPOSSIBLE;
     }
     return *this;
   }
     }
     return *this;
   }
@@ -74,6 +77,8 @@ public:
         new (&exception_) T(std::move(that.exception));
         that.exception.~exception_ptr();
         break;
         new (&exception_) T(std::move(that.exception));
         that.exception.~exception_ptr();
         break;
+      default:
+        THROW_IMPOSSIBLE;
     }
     that.status_ = ResultStatus::invalid;
     return *this;
     }
     that.status_ = ResultStatus::invalid;
     return *this;
@@ -94,6 +99,8 @@ public:
       case ResultStatus::exception:
         exception_.~exception_ptr();
         break;
       case ResultStatus::exception:
         exception_.~exception_ptr();
         break;
+      default:
+        THROW_IMPOSSIBLE;
     }
     status_ = ResultStatus::invalid;
   }
     }
     status_ = ResultStatus::invalid;
   }
index e6414db..440de3a 100644 (file)
@@ -681,6 +681,10 @@ static simgrid::mc::Type MC_dwarf_die_to_type(
   }
 
   switch (type.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
   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
index b2afcbc..42d5c79 100644 (file)
@@ -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;
   case simgrid::mc::RequestType::internal:
     use_remote_comm = false;
     break;
+  default:
+    THROW_IMPOSSIBLE;
   }
 
   const char* type = nullptr;
   }
 
   const char* type = nullptr;
index dfed3e3..13531f7 100644 (file)
@@ -231,6 +231,7 @@ case SIMCALL_RUN_BLOCKING:
           sg_host_get_name(simcall->issuer->host)
           );
       break;
           sg_host_get_name(simcall->issuer->host)
           );
       break;
-
+    default:
+      THROW_IMPOSSIBLE;
   }
 }
   }
 }
index 093fe97..1e14a2a 100755 (executable)
@@ -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('          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')
 
     fd.write('  }\n')
     fd.write('}\n')
 
index dfb894d..f67afd6 100644 (file)
@@ -818,6 +818,8 @@ void ETag_surfxml_zoneRoute()
   case A_surfxml_zoneRoute_symmetrical_NO:
     ASroute.symmetrical = false;
     break;
   case A_surfxml_zoneRoute_symmetrical_NO:
     ASroute.symmetrical = false;
     break;
+  default:
+    THROW_IMPOSSIBLE;
   }
 
   sg_platf_new_route(&ASroute);
   }
 
   sg_platf_new_route(&ASroute);
index ee8be8e..2e15eeb 100644 (file)
@@ -7,6 +7,9 @@
 
 #include "xbt/automaton.h"
 #include <stdio.h> /* printf */
 
 #include "xbt/automaton.h"
 #include <stdio.h> /* printf */
+#include <xbt/log.h>
+
+XBT_LOG_NEW_DEFAULT_SUBCATEGORY(xbt_automaton, xbt, "Automaton");
 
 struct xbt_automaton_propositional_symbol{
   char* pred;
 
 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;
     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;
   }
   va_end(ap);
   return label;
index f35835d..c6abfb5 100644 (file)
@@ -12,6 +12,9 @@
 #if HAVE_UNISTD_H
 # include <unistd.h>   /* isatty */
 #endif
 #if HAVE_UNISTD_H
 # include <unistd.h>   /* isatty */
 #endif
+#include <xbt/log.h>
+
+XBT_LOG_EXTERNAL_DEFAULT_CATEGORY(xbt_automaton);
 
 static xbt_automaton_t parsed_automaton;
 char* state_id_src;
 
 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;
   case 4 :
     label = xbt_automaton_exp_label_new(type);
     break;
+  default:
+    XBT_DEBUG("Invalid type: %d", type);
+    break;
   }
   va_end(ap);
   return label;
   }
   va_end(ap);
   return label;
index 8c0a3b4..5479e4d 100644 (file)
@@ -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_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);
   XBT_LOG_CONNECT(xbt_backtrace);
   XBT_LOG_CONNECT(xbt_exception);
   XBT_LOG_CONNECT(xbt_graph);