Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
Apply last sonar-related changes to the new function platform_graph_export_csv().
authorArnaud Giersch <arnaud.giersch@univ-fcomte.fr>
Tue, 10 May 2022 16:59:47 +0000 (18:59 +0200)
committerArnaud Giersch <arnaud.giersch@univ-fcomte.fr>
Tue, 10 May 2022 19:26:22 +0000 (21:26 +0200)
src/instr/instr_platform.cpp

index 0c78597..0db7a14 100644 (file)
@@ -248,7 +248,8 @@ void platform_graph_export_graphviz(const std::string& output_filename)
   xbt_graph_free_graph(g, xbt_free_f, xbt_free_f, nullptr);
 }
 
-void platform_graph_export_csv(const std::string& output_filename) {
+void platform_graph_export_csv(const std::string& output_filename)
+{
   auto* g         = xbt_graph_new_graph(0, nullptr);
   std::map<std::string, xbt_node_t, std::less<>> nodes;
   std::map<std::string, xbt_edge_t, std::less<>> edges;
@@ -259,10 +260,10 @@ void platform_graph_export_csv(const std::string& output_filename) {
   xbt_assert(not fs.fail(), "Failed to open %s", output_filename.c_str());
 
   fs << "src,dst" << std::endl;
-  for (auto const& elm : edges) {
-    const char* src_s = static_cast<char*>(elm.second->src->data);
-    const char* dst_s = static_cast<char*>(elm.second->dst->data);
-    fs << src_s << "," << dst_s << std::endl;
+  for (auto const& [_, edge] : edges) {
+    const char* src_s = static_cast<char*>(edge->src->data);
+    const char* dst_s = static_cast<char*>(edge->dst->data);
+    fs << src_s << "," << dst_s << "\n";
   }
   fs.close();
   xbt_graph_free_graph(g, xbt_free_f, xbt_free_f, nullptr);