Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
Sonar: remove nested blocks.
authorArnaud Giersch <arnaud.giersch@univ-fcomte.fr>
Sat, 28 Oct 2017 16:19:14 +0000 (18:19 +0200)
committerArnaud Giersch <arnaud.giersch@univ-fcomte.fr>
Sat, 28 Oct 2017 21:18:37 +0000 (23:18 +0200)
src/mc/DwarfExpression.cpp
src/mc/mc_request.cpp
src/surf/xml/surfxml_parseplatf.cpp

index b20366d..696d262 100644 (file)
@@ -31,6 +31,8 @@ void execute(
   for (size_t i = 0; i != n; ++i) {
     const Dwarf_Op *op = ops + i;
     std::uint8_t atom = op->atom;
+    intptr_t first;
+    intptr_t second;
 
     switch (atom) {
 
@@ -204,19 +206,17 @@ void execute(
       // and replace the top of the stack with the computed value
       // (stack.top() += stack.before_top()).
 
-    case DW_OP_plus: {
-      intptr_t first = stack.pop();
-      intptr_t second = stack.pop();
+    case DW_OP_plus:
+      first  = stack.pop();
+      second = stack.pop();
       stack.push(first + second);
       break;
-    }
 
-    case DW_OP_mul: {
-      intptr_t first = stack.pop();
-      intptr_t second = stack.pop();
+    case DW_OP_mul:
+      first  = stack.pop();
+      second = stack.pop();
       stack.push(first * second);
       break;
-    }
 
     case DW_OP_plus_uconst:
       stack.top() += op->number;
@@ -230,33 +230,29 @@ void execute(
       stack.top() = - (intptr_t) stack.top();
       break;
 
-    case DW_OP_minus: {
-      intptr_t first = stack.pop();
-      intptr_t second = stack.pop();
+    case DW_OP_minus:
+      first  = stack.pop();
+      second = stack.pop();
       stack.push(second - first);
       break;
-    }
 
-    case DW_OP_and: {
-      intptr_t first = stack.pop();
-      intptr_t second = stack.pop();
+    case DW_OP_and:
+      first  = stack.pop();
+      second = stack.pop();
       stack.push(first & second);
       break;
-    }
 
-    case DW_OP_or: {
-      intptr_t first = stack.pop();
-      intptr_t second = stack.pop();
+    case DW_OP_or:
+      first  = stack.pop();
+      second = stack.pop();
       stack.push(first | second);
       break;
-    }
 
-    case DW_OP_xor: {
-      intptr_t first = stack.pop();
-      intptr_t second = stack.pop();
+    case DW_OP_xor:
+      first  = stack.pop();
+      second = stack.pop();
       stack.push(first ^ second);
       break;
-    }
 
     case DW_OP_nop:
       break;
index 42d5c79..6a800b7 100644 (file)
@@ -407,10 +407,9 @@ bool request_is_enabled_by_idx(smx_simcall_t req, unsigned int idx)
     remote_act = simcall_comm_wait__getraw__comm(req);
     break;
 
-  case SIMCALL_COMM_WAITANY: {
+  case SIMCALL_COMM_WAITANY:
     read_element(mc_model_checker->process(), &remote_act, remote(simcall_comm_waitany__getraw__comms(req)), idx,
                  sizeof(remote_act));
-    }
     break;
 
   case SIMCALL_COMM_TESTANY:
@@ -470,7 +469,7 @@ std::string request_get_dot_output(smx_simcall_t req, int value)
       label = simgrid::xbt::string_printf("[(%lu)] iRecv", issuer->pid);
     break;
 
-  case SIMCALL_COMM_WAIT: {
+  case SIMCALL_COMM_WAIT:
     if (value == -1) {
       if (issuer->host)
         label = simgrid::xbt::string_printf("[(%lu)%s] WaitTimeout", issuer->pid, MC_smx_actor_get_host_name(issuer));
@@ -496,7 +495,6 @@ std::string request_get_dot_output(smx_simcall_t req, int value)
                     dst_proc ? dst_proc->pid : 0);
     }
     break;
-  }
 
   case SIMCALL_COMM_TEST: {
     simgrid::kernel::activity::ActivityImpl* remote_act = simcall_comm_test__getraw__comm(req);
index 38e43ad..d534780 100644 (file)
@@ -102,72 +102,72 @@ void parse_platform_file(const char *file)
       xbt_die("Lua call failed. See Log");
     }
     lua_close(L);
+    return;
   }
-  else
 #endif
-  { // Use XML parser
 
-    int parse_status;
+  // Use XML parser
 
-    /* init the flex parser */
-    after_config_done = 0;
-    surf_parse_open(file);
+  int parse_status;
 
-    /* Do the actual parsing */
-    parse_status = surf_parse();
+  /* init the flex parser */
+  after_config_done = 0;
+  surf_parse_open(file);
 
-    /* connect all traces relative to hosts */
-    for (auto const& elm : trace_connect_list_host_avail) {
-      xbt_assert(traces_set_list.find(elm.first) != traces_set_list.end(), "Trace %s undefined", elm.first.c_str());
-      tmgr_trace_t trace = traces_set_list.at(elm.first);
+  /* Do the actual parsing */
+  parse_status = surf_parse();
 
-      simgrid::s4u::Host* host = sg_host_by_name(elm.second.c_str());
-      xbt_assert(host, "Host %s undefined", elm.second.c_str());
-      simgrid::surf::Cpu *cpu = host->pimpl_cpu;
+  /* connect all traces relative to hosts */
+  for (auto const& elm : trace_connect_list_host_avail) {
+    xbt_assert(traces_set_list.find(elm.first) != traces_set_list.end(), "Trace %s undefined", elm.first.c_str());
+    tmgr_trace_t trace = traces_set_list.at(elm.first);
 
-      cpu->setStateTrace(trace);
-    }
-
-    for (auto const& elm : trace_connect_list_host_speed) {
-      xbt_assert(traces_set_list.find(elm.first) != traces_set_list.end(), "Trace %s undefined", elm.first.c_str());
-      tmgr_trace_t trace = traces_set_list.at(elm.first);
+    simgrid::s4u::Host* host = sg_host_by_name(elm.second.c_str());
+    xbt_assert(host, "Host %s undefined", elm.second.c_str());
+    simgrid::surf::Cpu* cpu = host->pimpl_cpu;
 
-      simgrid::s4u::Host* host = sg_host_by_name(elm.second.c_str());
-      xbt_assert(host, "Host %s undefined", elm.second.c_str());
-      simgrid::surf::Cpu *cpu = host->pimpl_cpu;
+    cpu->setStateTrace(trace);
+  }
 
-      cpu->setSpeedTrace(trace);
-    }
+  for (auto const& elm : trace_connect_list_host_speed) {
+    xbt_assert(traces_set_list.find(elm.first) != traces_set_list.end(), "Trace %s undefined", elm.first.c_str());
+    tmgr_trace_t trace = traces_set_list.at(elm.first);
 
-    for (auto const& elm : trace_connect_list_link_avail) {
-      xbt_assert(traces_set_list.find(elm.first) != traces_set_list.end(), "Trace %s undefined", elm.first.c_str());
-      tmgr_trace_t trace = traces_set_list.at(elm.first);
+    simgrid::s4u::Host* host = sg_host_by_name(elm.second.c_str());
+    xbt_assert(host, "Host %s undefined", elm.second.c_str());
+    simgrid::surf::Cpu* cpu = host->pimpl_cpu;
 
-      sg_link_t link = simgrid::s4u::Link::byName(elm.second.c_str());
-      xbt_assert(link, "Link %s undefined", elm.second.c_str());
-      link->setStateTrace(trace);
-    }
+    cpu->setSpeedTrace(trace);
+  }
 
-    for (auto const& elm : trace_connect_list_link_bw) {
-      xbt_assert(traces_set_list.find(elm.first) != traces_set_list.end(), "Trace %s undefined", elm.first.c_str());
-      tmgr_trace_t trace = traces_set_list.at(elm.first);
-      sg_link_t link = simgrid::s4u::Link::byName(elm.second.c_str());
-      xbt_assert(link, "Link %s undefined", elm.second.c_str());
-      link->setBandwidthTrace(trace);
-    }
+  for (auto const& elm : trace_connect_list_link_avail) {
+    xbt_assert(traces_set_list.find(elm.first) != traces_set_list.end(), "Trace %s undefined", elm.first.c_str());
+    tmgr_trace_t trace = traces_set_list.at(elm.first);
 
-    for (auto const& elm : trace_connect_list_link_lat) {
-      xbt_assert(traces_set_list.find(elm.first) != traces_set_list.end(), "Trace %s undefined", elm.first.c_str());
-      tmgr_trace_t trace = traces_set_list.at(elm.first);
-      sg_link_t link = simgrid::s4u::Link::byName(elm.second.c_str());
-      xbt_assert(link, "Link %s undefined", elm.second.c_str());
-      link->setLatencyTrace(trace);
-    }
+    sg_link_t link = simgrid::s4u::Link::byName(elm.second.c_str());
+    xbt_assert(link, "Link %s undefined", elm.second.c_str());
+    link->setStateTrace(trace);
+  }
 
-    surf_parse_close();
+  for (auto const& elm : trace_connect_list_link_bw) {
+    xbt_assert(traces_set_list.find(elm.first) != traces_set_list.end(), "Trace %s undefined", elm.first.c_str());
+    tmgr_trace_t trace = traces_set_list.at(elm.first);
+    sg_link_t link     = simgrid::s4u::Link::byName(elm.second.c_str());
+    xbt_assert(link, "Link %s undefined", elm.second.c_str());
+    link->setBandwidthTrace(trace);
+  }
 
-    if (parse_status)
-      surf_parse_error(std::string("Parse error in ") + file);
+  for (auto const& elm : trace_connect_list_link_lat) {
+    xbt_assert(traces_set_list.find(elm.first) != traces_set_list.end(), "Trace %s undefined", elm.first.c_str());
+    tmgr_trace_t trace = traces_set_list.at(elm.first);
+    sg_link_t link     = simgrid::s4u::Link::byName(elm.second.c_str());
+    xbt_assert(link, "Link %s undefined", elm.second.c_str());
+    link->setLatencyTrace(trace);
   }
+
+  surf_parse_close();
+
+  if (parse_status)
+    surf_parse_error(std::string("Parse error in ") + file);
 }
 }