Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
Merge branch 'master' of scm.gforge.inria.fr:/gitroot/simgrid/simgrid
authorMartin Quinson <martin.quinson@loria.fr>
Thu, 10 Aug 2017 19:25:24 +0000 (21:25 +0200)
committerMartin Quinson <martin.quinson@loria.fr>
Thu, 10 Aug 2017 19:25:24 +0000 (21:25 +0200)
17 files changed:
examples/s4u/actions-storage/s4u_actions-storage.cpp
examples/s4u/app-bittorrent/s4u_peer.cpp
examples/s4u/app-bittorrent/s4u_tracker.hpp
examples/s4u/io/s4u_io.cpp
include/simgrid/s4u/File.hpp
include/simgrid/s4u/Storage.hpp
src/kernel/routing/TorusZone.cpp
src/msg/msg_io.cpp
src/s4u/s4u_file.cpp
src/s4u/s4u_storage.cpp
src/surf/FileImpl.cpp
src/surf/FileImpl.hpp
src/surf/StorageImpl.cpp
src/surf/StorageImpl.hpp
src/surf/xml/platf.hpp
src/surf/xml/platf_private.hpp
src/surf/xml/surfxml_sax_cb.cpp

index 85e71e1..85ffb9d 100644 (file)
@@ -29,7 +29,7 @@ static void log_action(const char* const* action, double date)
   }
 }
 
-static simgrid::s4u::File* get_file_descriptor(const char* file_name)
+static simgrid::s4u::File* get_file_descriptor(std::string file_name)
 {
   std::string full_name = simgrid::s4u::this_actor::getName() + ":" + file_name;
 
@@ -60,11 +60,11 @@ public:
   /* My actions */
   static void open(const char* const* action)
   {
-    const char* file_name = action[2];
+    std::string file_name = action[2];
     double clock          = simgrid::s4u::Engine::getClock();
     std::string full_name = simgrid::s4u::this_actor::getName() + ":" + file_name;
 
-    ACT_DEBUG("Entering Open: %s (filename: %s)", NAME, file_name);
+    ACT_DEBUG("Entering Open: %s (filename: %s)", NAME, file_name.c_str());
     simgrid::s4u::File* file = new simgrid::s4u::File(file_name, NULL);
 
     opened_files.insert({full_name, file});
@@ -74,7 +74,7 @@ public:
 
   static void read(const char* const* action)
   {
-    const char* file_name = action[2];
+    std::string file_name = action[2];
     sg_size_t size        = std::stoul(action[3]);
     double clock          = simgrid::s4u::Engine::getClock();
 
@@ -88,12 +88,12 @@ public:
 
   static void close(const char* const* action)
   {
-    const char* file_name = action[2];
+    std::string file_name = action[2];
     double clock          = simgrid::s4u::Engine::getClock();
 
     simgrid::s4u::File* file = get_file_descriptor(file_name);
 
-    ACT_DEBUG("Entering Close: %s (filename: %s)", NAME, file_name);
+    ACT_DEBUG("Entering Close: %s (filename: %s)", NAME, file_name.c_str());
     delete file;
 
     log_action(action, simgrid::s4u::Engine::getClock() - clock);
index 659a4aa..79157bc 100644 (file)
@@ -88,7 +88,7 @@ bool Peer::getPeersFromTracker()
 {
   simgrid::s4u::MailboxPtr tracker_mailbox = simgrid::s4u::Mailbox::byName(TRACKER_MAILBOX);
   // Build the task to send to the tracker
-  TrackerQuery* peer_request = new TrackerQuery(id, mailbox_, 0, 0, FILE_SIZE);
+  TrackerQuery* peer_request = new TrackerQuery(id, mailbox_);
   try {
     XBT_DEBUG("Sending a peer request to the tracker.");
     tracker_mailbox->put(peer_request, TRACKER_COMM_SIZE, GET_PEERS_TIMEOUT);
index 1e43850..6aff63d 100644 (file)
 class TrackerQuery {
   int peer_id; // peer id
   simgrid::s4u::MailboxPtr return_mailbox;
-  int uploaded;   // how much the peer has already uploaded
-  int downloaded; // how much the peer has downloaded
-  int left;       // how much the peer has left
 public:
-  explicit TrackerQuery(int peer_id, simgrid::s4u::MailboxPtr return_mailbox, int uploaded, int downloaded, int left)
-      : peer_id(peer_id), return_mailbox(return_mailbox), uploaded(uploaded), downloaded(downloaded), left(left){};
+  explicit TrackerQuery(int peer_id, simgrid::s4u::MailboxPtr return_mailbox)
+      : peer_id(peer_id), return_mailbox(return_mailbox){};
   ~TrackerQuery() = default;
   int getPeerId() { return peer_id; }
   simgrid::s4u::MailboxPtr getReturnMailbox() { return return_mailbox; }
index 378f271..8c60b63 100644 (file)
@@ -16,7 +16,7 @@ public:
     XBT_INFO("Storage info on %s:", simgrid::s4u::Host::current()->getCname());
 
     for (const auto&kv : mounts) {
-      const char* mountpoint = kv.first.c_str();
+      std::string mountpoint         = kv.first;
       simgrid::s4u::Storage* storage = kv.second;
 
       // Retrieve disk's information
@@ -24,8 +24,8 @@ public:
       sg_size_t used_size = storage->getSizeUsed();
       sg_size_t size      = storage->getSize();
 
-      XBT_INFO("    %s (%s) Used: %llu; Free: %llu; Total: %llu.", storage->getName(), mountpoint, used_size, free_size,
-               size);
+      XBT_INFO("    %s (%s) Used: %llu; Free: %llu; Total: %llu.", storage->getName(), mountpoint.c_str(), used_size,
+               free_size, size);
     }
   }
 
@@ -36,11 +36,11 @@ public:
     show_info(mounts);
 
     // Open an non-existing file to create it
-    const char* filename = "/home/tmp/data.txt";
+    std::string filename     = "/home/tmp/data.txt";
     simgrid::s4u::File* file = new simgrid::s4u::File(filename, nullptr);
 
     sg_size_t write = file->write(200000);  // Write 200,000 bytes
-    XBT_INFO("Create a %llu bytes file named '%s' on /sd1", write, filename);
+    XBT_INFO("Create a %llu bytes file named '%s' on /sd1", write, filename.c_str());
 
     // check that sizes have changed
     show_info(mounts);
@@ -49,22 +49,22 @@ public:
     const sg_size_t file_size = file->size();
     file->seek(0);
     const sg_size_t read = file->read(file_size);
-    XBT_INFO("Read %llu bytes on %s", read, filename);
+    XBT_INFO("Read %llu bytes on %s", read, filename.c_str());
 
     // Now write 100,000 bytes in tmp/data.txt
     write = file->write(100000);  // Write 100,000 bytes
-    XBT_INFO("Write %llu bytes on %s", write, filename);
+    XBT_INFO("Write %llu bytes on %s", write, filename.c_str());
 
     simgrid::s4u::Storage* storage = simgrid::s4u::Storage::byName("Disk4");
 
     // Now rename file from ./tmp/data.txt to ./tmp/simgrid.readme
-    const char *newpath = "/home/tmp/simgrid.readme";
-    XBT_INFO("Move '%s' to '%s'", file->getPath(), newpath);
+    std::string newpath = "/home/tmp/simgrid.readme";
+    XBT_INFO("Move '%s' to '%s'", file->getPath(), newpath.c_str());
     file->move(newpath);
 
     // Test attaching some user data to the file
     file->setUserdata(xbt_strdup("777"));
-    XBT_INFO("User data attached to the file: %s", (char*)file->getUserdata());
+    XBT_INFO("User data attached to the file: %s", static_cast<char*>(file->getUserdata()));
     xbt_free(file->getUserdata());
 
     // Close the file
@@ -72,10 +72,10 @@ public:
 
     // Now attach some user data to disk1
     XBT_INFO("Get/set data for storage element: %s", storage->getName());
-    XBT_INFO("    Uninitialized storage data: '%s'", (char*)storage->getUserdata());
+    XBT_INFO("    Uninitialized storage data: '%s'", static_cast<char*>(storage->getUserdata()));
 
     storage->setUserdata(xbt_strdup("Some user data"));
-    XBT_INFO("    Set and get data: '%s'", (char*)storage->getUserdata());
+    XBT_INFO("    Set and get data: '%s'", static_cast<char*>(storage->getUserdata()));
 
     xbt_free(storage->getUserdata());
   }
index 18d2926..cdc9b97 100644 (file)
@@ -25,12 +25,12 @@ namespace s4u {
 XBT_PUBLIC_CLASS File
 {
 public:
-  File(const char* fullpath, void* userdata);
-  File(const char* fullpath, sg_host_t host, void* userdata);
+  File(std::string fullpath, void* userdata);
+  File(std::string fullpath, sg_host_t host, void* userdata);
   ~File();
 
   /** Retrieves the path to the file */
-  const char* getPath() { return path_; }
+  const char* getPath() { return path_.c_str(); }
 
   /** Simulates a local read action. Returns the size of data actually read */
   sg_size_t read(sg_size_t size);
@@ -53,23 +53,21 @@ public:
   /** Retrieves the current file position */
   sg_size_t tell();
 
-  /** Rename a file
-   *
-   * WARNING: It is forbidden to move the file to another mount point */
-  void move(const char* fullpath);
+  /** Rename a file. WARNING: It is forbidden to move the file to another mount point */
+  void move(std::string fullpath);
 
   /** Remove a file from disk */
   int unlink();
 
-  const char* storage_type;
-  const char* storageId;
+  std::string storage_type;
+  std::string storageId;
   std::string mount_point;
   int desc_id = 0;
 
 private:
   surf_file_t pimpl_ = nullptr;
-  const char* path_  = nullptr;
-  void* userdata_    = nullptr;
+  std::string path_;
+  void* userdata_ = nullptr;
 };
 }
 } // namespace simgrid::s4u
index 38e30b7..efad7b8 100644 (file)
@@ -28,7 +28,7 @@ public:
   explicit Storage(surf::StorageImpl * pimpl) : pimpl_(pimpl) {}
   virtual ~Storage() = default;
   /** Retrieve a Storage by its name. It must exist in the platform file */
-  static Storage* byName(const char* name);
+  static Storage* byName(std::string name);
   const char* getName();
   const char* getType();
   Host* getHost();
index e5c6ce7..cf31241 100644 (file)
@@ -81,12 +81,11 @@ void TorusZone::parse_specific_arguments(sg_platf_cluster_cbarg_t cluster)
 
   if (not dimensions.empty()) {
     /* We are in a torus cluster
-     * Parse attribute dimensions="dim1,dim2,dim3,...,dimN" and safe it in a vector.
+     * Parse attribute dimensions="dim1,dim2,dim3,...,dimN" and save them into a vector.
      * Additionally, we need to know how many ranks we have in total
      */
-    for (auto group : dimensions) {
-      dimensions_.push_back(surf_parse_get_int(group.c_str()));
-    }
+    for (auto group : dimensions)
+      dimensions_.push_back(surf_parse_get_int(group));
 
     linkCountPerNode_ = dimensions_.size();
   }
@@ -117,21 +116,16 @@ void TorusZone::getLocalRoute(NetPoint* src, NetPoint* dst, sg_platf_route_cbarg
   unsigned int current_node = src->id();
   unsigned int next_node    = 0;
   /*
-   * Arrays that hold the coordinates of the current node and
-   * the target; comparing the values at the i-th position of
-   * both arrays, we can easily assess whether we need to route
-   * into this dimension or not.
+   * Arrays that hold the coordinates of the current node andthe target; comparing the values at the i-th position of
+   * both arrays, we can easily assess whether we need to route into this dimension or not.
    */
   unsigned int myCoords[4];
   rankId_to_coords(src->id(), dimensions_, &myCoords);
   unsigned int targetCoords[4];
   rankId_to_coords(dst->id(), dimensions_, &targetCoords);
   /*
-   * linkOffset describes the offset where the link
-   * we want to use is stored
-   * (+1 is added because each node has a link from itself to itself,
-   * which can only be the case if src->m_id == dst->m_id -- see above
-   * for this special case)
+   * linkOffset describes the offset where the link we want to use is stored(+1 is added because each node has a link
+   * from itself to itself, which can only be the case if src->m_id == dst->m_id -- see above for this special case)
    */
   int nodeOffset = (dimensions_.size() + 1) * src->id();
 
index 776adfe..3b06983 100644 (file)
@@ -73,7 +73,8 @@ void MSG_file_dump (msg_file_t fd){
            "\t\tStorage Id: '%s'\n"
            "\t\tStorage Type: '%s'\n"
            "\t\tFile Descriptor Id: %d",
-           fd->getPath(), fd->size(), fd->mount_point.c_str(), fd->storageId, fd->storage_type, fd->desc_id);
+           fd->getPath(), fd->size(), fd->mount_point.c_str(), fd->storageId.c_str(), fd->storage_type.c_str(),
+           fd->desc_id);
 }
 
 /** \ingroup msg_file
index 043f6d5..35f59e7 100644 (file)
@@ -17,19 +17,19 @@ XBT_LOG_NEW_DEFAULT_CATEGORY(s4u_file,"S4U files");
 namespace simgrid {
 namespace s4u {
 
-File::File(const char* fullpath, void* userdata) : File(fullpath, Host::current(), userdata){};
+File::File(std::string fullpath, void* userdata) : File(fullpath, Host::current(), userdata){};
 
-File::File(const char* fullpath, sg_host_t host, void* userdata) : path_(fullpath), userdata_(userdata)
+File::File(std::string fullpath, sg_host_t host, void* userdata) : path_(fullpath), userdata_(userdata)
 {
   // this cannot fail because we get a xbt_die if the mountpoint does not exist
   Storage* st                  = nullptr;
   size_t longest_prefix_length = 0;
   std::string path;
-  XBT_DEBUG("Search for storage name for '%s' on '%s'", fullpath, host->getCname());
+  XBT_DEBUG("Search for storage name for '%s' on '%s'", fullpath.c_str(), host->getCname());
 
   for (auto mnt : host->getMountedStorages()) {
     XBT_DEBUG("See '%s'", mnt.first.c_str());
-    mount_point = std::string(fullpath).substr(0, mnt.first.size());
+    mount_point = fullpath.substr(0, mnt.first.length());
 
     if (mount_point == mnt.first && mnt.first.length() > longest_prefix_length) {
       /* The current mount name is found in the full path and is bigger than the previous*/
@@ -38,10 +38,10 @@ File::File(const char* fullpath, sg_host_t host, void* userdata) : path_(fullpat
     }
   }
   if (longest_prefix_length > 0) { /* Mount point found, split fullpath into mount_name and path+filename*/
-    mount_point = std::string(fullpath).substr(0, longest_prefix_length);
-    path        = std::string(fullpath).substr(longest_prefix_length, strlen(fullpath));
+    mount_point = fullpath.substr(0, longest_prefix_length);
+    path        = fullpath.substr(longest_prefix_length, fullpath.length());
   } else
-    xbt_die("Can't find mount point for '%s' on '%s'", fullpath, host->getCname());
+    xbt_die("Can't find mount point for '%s' on '%s'", fullpath.c_str(), host->getCname());
 
   pimpl_ =
       simgrid::simix::kernelImmediate([this, st, path] { return new simgrid::surf::FileImpl(st, path, mount_point); });
@@ -84,7 +84,7 @@ sg_size_t File::tell()
   return simgrid::simix::kernelImmediate([this] { return pimpl_->tell(); });
 }
 
-void File::move(const char* fullpath)
+void File::move(std::string fullpath)
 {
   simgrid::simix::kernelImmediate([this, fullpath] { pimpl_->move(fullpath); });
 }
index 38be665..3890ce3 100644 (file)
@@ -22,7 +22,7 @@ std::map<std::string, Storage*>* allStorages()
   return res;
 }
 
-Storage* Storage::byName(const char* name)
+Storage* Storage::byName(std::string name)
 {
   surf::StorageImpl* res = surf::StorageImpl::byName(name);
   if (res == nullptr)
index fbb70a7..ff0a830 100644 (file)
@@ -92,23 +92,23 @@ int FileImpl::unlink()
   }
 }
 
-void FileImpl::move(const char* fullpath)
+void FileImpl::move(std::string fullpath)
 {
   /* Check if the new full path is on the same mount point */
-  if (not strncmp(mount_point_.c_str(), fullpath, mount_point_.size())) {
+  if (not strncmp(mount_point_.c_str(), fullpath.c_str(), mount_point_.size())) {
     std::map<std::string, sg_size_t>* content = location_->getContent();
     auto sz = content->find(path_);
     if (sz != content->end()) { // src file exists
       sg_size_t new_size = sz->second;
       content->erase(path_);
-      std::string path = std::string(fullpath).substr(mount_point_.size(), strlen(fullpath));
+      std::string path = fullpath.substr(mount_point_.length(), fullpath.length());
       content->insert({path.c_str(), new_size});
-      XBT_DEBUG("Move file from %s to %s, size '%llu'", path_.c_str(), fullpath, new_size);
+      XBT_DEBUG("Move file from %s to %s, size '%llu'", path_.c_str(), fullpath.c_str(), new_size);
     } else {
       XBT_WARN("File %s doesn't exist", path_.c_str());
     }
   } else {
-    XBT_WARN("New full path %s is not on the same mount point: %s.", fullpath, mount_point_.c_str());
+    XBT_WARN("New full path %s is not on the same mount point: %s.", fullpath.c_str(), mount_point_.c_str());
   }
 }
 }
index 0478ea1..6b2f9cc 100644 (file)
@@ -28,7 +28,7 @@ public:
   sg_size_t tell() { return current_position_; }
   int seek(sg_offset_t offset, int origin);
   int unlink();
-  void move(const char* fullpath);
+  void move(std::string fullpath);
   Action* read(sg_size_t size);
   Action* write(sg_size_t size);
 
index b162a6e..1121989 100644 (file)
@@ -32,7 +32,7 @@ simgrid::xbt::signal<void(StorageAction*, Action::State, Action::State)> storage
 std::unordered_map<std::string, StorageImpl*>* StorageImpl::storages =
     new std::unordered_map<std::string, StorageImpl*>();
 
-StorageImpl* StorageImpl::byName(const char* name)
+StorageImpl* StorageImpl::byName(std::string name)
 {
   if (storages->find(name) == storages->end())
     return nullptr;
index da1f082..b74d624 100644 (file)
@@ -91,7 +91,7 @@ public:
 
   /** @brief Public interface */
   s4u::Storage piface_;
-  static StorageImpl* byName(const char* name);
+  static StorageImpl* byName(std::string name);
 
   /** @brief Check if the Storage is used (if an action currently uses its resources) */
   bool isUsed() override;
index 1a7dc48..159aa1a 100644 (file)
@@ -3,11 +3,9 @@
 /* This program is free software; you can redistribute it and/or modify it
  * under the terms of the license (GNU LGPL) which comes with this package. */
 
-#ifndef SURF_SURFXML_PARSE_H
-#define SURF_SURFXML_PARSE_H
+#ifndef SURF_SURFXML_PARSE_HPP
+#define SURF_SURFXML_PARSE_HPP
 
-#include <xbt/function_types.h>
-#include <xbt/misc.h>
 #include <xbt/signal.hpp>
 
 SG_BEGIN_DECL()
@@ -20,11 +18,11 @@ XBT_PUBLIC(void) surf_parse_open(const char *file);
 XBT_PUBLIC(void) surf_parse_close();
 XBT_PUBLIC(void) surf_parse_assert(bool cond, std::string msg);
 XBT_PUBLIC(void) XBT_ATTRIB_NORETURN surf_parse_error(std::string msg);
-XBT_PUBLIC(void) surf_parse_assert_netpoint(char* hostname, const char* pre, const char* post);
-XBT_PUBLIC(void) surf_parse_warn(const char *msg,...) XBT_ATTRIB_PRINTF(1,2);
+XBT_PUBLIC(void) surf_parse_assert_netpoint(std::string hostname, std::string pre, std::string post);
+XBT_PUBLIC(void) surf_parse_warn(std::string msg);
 
-XBT_PUBLIC(double) surf_parse_get_double(const char *string);
-XBT_PUBLIC(int) surf_parse_get_int(const char *string);
+XBT_PUBLIC(double) surf_parse_get_double(std::string s);
+XBT_PUBLIC(int) surf_parse_get_int(std::string s);
 XBT_PUBLIC(double) surf_parse_get_time(const char *string, const char *entity_kind, const char *name);
 XBT_PUBLIC(double) surf_parse_get_size(const char *string, const char *entity_kind, const char *name);
 XBT_PUBLIC(double) surf_parse_get_bandwidth(const char *string, const char *entity_kind, const char *name);
index c977169..aedd266 100644 (file)
@@ -191,7 +191,6 @@ public:
   int routing;
 };
 
-#define SG_PLATF_AS_INITIALIZER {nullptr,0}
 /* The default current property receiver. Setup in the corresponding opening callbacks. */
 extern std::map<std::string, std::string>* current_property_set;
 
@@ -205,21 +204,21 @@ XBT_PUBLIC(void) sg_platf_end(); // Finish the creation of the platform
 XBT_PUBLIC(simgrid::s4u::NetZone*) sg_platf_new_Zone_begin(ZoneCreationArgs* zone); // Begin description of new Zone
 XBT_PUBLIC(void) sg_platf_new_Zone_seal();                                          // That Zone is fully described
 
-XBT_PUBLIC(void) sg_platf_new_host   (sg_platf_host_cbarg_t   host);   // Add an host   to the currently described AS
-XBT_PUBLIC(void) sg_platf_new_hostlink(sg_platf_host_link_cbarg_t h); // Add an host_link to the currently described AS
-XBT_PUBLIC(simgrid::kernel::routing::NetPoint*)
-sg_platf_new_router(const char* name, const char* coords);             // Add a router  to the currently described AS
-XBT_PUBLIC(void) sg_platf_new_link(LinkCreationArgs* link);            // Add a link    to the currently described AS
-XBT_PUBLIC(void) sg_platf_new_peer(PeerCreationArgs* peer);            // Add a peer    to the currently described AS
-XBT_PUBLIC(void) sg_platf_new_cluster(sg_platf_cluster_cbarg_t clust); // Add a cluster to the currently described AS
-XBT_PUBLIC(void) sg_platf_new_cabinet(CabinetCreationArgs* cabinet);   // Add a cabinet to the currently described AS
+XBT_PUBLIC(void) sg_platf_new_host(sg_platf_host_cbarg_t host);        // Add a host      to the current Zone
+XBT_PUBLIC(void) sg_platf_new_hostlink(sg_platf_host_link_cbarg_t h);  // Add a host_link to the current Zone
+XBT_PUBLIC(void) sg_platf_new_link(LinkCreationArgs* link);            // Add a link      to the current Zone
+XBT_PUBLIC(void) sg_platf_new_peer(PeerCreationArgs* peer);            // Add a peer      to the current Zone
+XBT_PUBLIC(void) sg_platf_new_cluster(sg_platf_cluster_cbarg_t clust); // Add a cluster   to the current Zone
+XBT_PUBLIC(void) sg_platf_new_cabinet(CabinetCreationArgs* cabinet);   // Add a cabinet   to the current Zone
+XBT_PUBLIC(simgrid::kernel::routing::NetPoint*)                        // Add a router    to the current Zone
+sg_platf_new_router(const char* name, const char* coords);
 
 XBT_PUBLIC(void) sg_platf_new_route (sg_platf_route_cbarg_t route); // Add a route
 XBT_PUBLIC(void) sg_platf_new_bypassRoute (sg_platf_route_cbarg_t bypassroute); // Add a bypassRoute
 
 XBT_PUBLIC(void) sg_platf_new_trace(TraceCreationArgs* trace);
 
-XBT_PUBLIC(void) sg_platf_new_storage(StorageCreationArgs* storage); // Add a storage to the currently described AS
+XBT_PUBLIC(void) sg_platf_new_storage(StorageCreationArgs* storage); // Add a storage to the current Zone
 XBT_PUBLIC(void) sg_platf_new_storage_type(StorageTypeCreationArgs* storage_type);
 XBT_PUBLIC(void) sg_platf_new_mount(MountCreationArgs* mount);
 
index 314c276..bd7ffc5 100644 (file)
@@ -40,6 +40,7 @@ void surf_parse_assert(bool cond, std::string msg)
     xbt_die("Exiting now");
   }
 }
+
 void surf_parse_error(std::string msg)
 {
   int lineno = surf_parse_lineno;
@@ -49,15 +50,12 @@ void surf_parse_error(std::string msg)
   xbt_die("Exiting now");
 }
 
-void surf_parse_assert_netpoint(char* hostname, const char* pre, const char* post)
+void surf_parse_assert_netpoint(std::string hostname, std::string pre, std::string post)
 {
-  if (sg_netpoint_by_name_or_null(hostname) != nullptr) // found
+  if (sg_netpoint_by_name_or_null(hostname.c_str()) != nullptr) // found
     return;
 
-  std::string msg = std::string(pre);
-  msg += hostname;
-  msg += post;
-  msg += " Existing netpoints: \n";
+  std::string msg = pre + hostname + post + " Existing netpoints: \n";
 
   std::vector<simgrid::kernel::routing::NetPoint*> list;
   simgrid::s4u::Engine::getInstance()->getNetpointList(&list);
@@ -83,33 +81,33 @@ void surf_parse_assert_netpoint(char* hostname, const char* pre, const char* pos
   surf_parse_error(msg);
 }
 
-void surf_parse_warn(const char *fmt, ...) {
-  va_list va;
-  va_start(va,fmt);
-  char *msg = bvprintf(fmt,va);
-  va_end(va);
-    XBT_WARN("%s:%d: %s", surf_parsed_filename, surf_parse_lineno, msg);
-    free(msg);
+void surf_parse_warn(std::string msg)
+{
+  XBT_WARN("%s:%d: %s", surf_parsed_filename, surf_parse_lineno, msg.c_str());
 }
 
-double surf_parse_get_double(const char *string) {
-  double res;
-  int ret = sscanf(string, "%lg", &res);
-  if (ret != 1)
-    surf_parse_error(std::string(string) + " is not a double");
-  return res;
+double surf_parse_get_double(std::string s)
+{
+  try {
+    return std::stod(s);
+  } catch (std::invalid_argument& ia) {
+    surf_parse_error(s + " is not a double");
+    return -1;
+  }
 }
 
-int surf_parse_get_int(const char *string) {
-  int res;
-  int ret = sscanf(string, "%d", &res);
-  if (ret != 1)
-    surf_parse_error(std::string(string) + " is not an integer");
-  return res;
+int surf_parse_get_int(std::string s)
+{
+  try {
+    return std::stoi(s);
+  } catch (std::invalid_argument& ia) {
+    surf_parse_error(s + " is not a double");
+    return -1;
+  }
 }
 
 /* Turn something like "1-4,6,9-11" into the vector {1,2,3,4,6,9,10,11} */
-static std::vector<int>* explodesRadical(const char* radicals)
+static std::vector<int>* explodesRadical(std::string radicals)
 {
   std::vector<int>* exploded = new std::vector<int>();
 
@@ -119,15 +117,15 @@ static std::vector<int>* explodesRadical(const char* radicals)
   for (auto group : radical_elements) {
     std::vector<std::string> radical_ends;
     boost::split(radical_ends, group, boost::is_any_of("-"));
-    int start                = surf_parse_get_int((radical_ends.front()).c_str());
-    int end                  = 0;
+    int start = surf_parse_get_int(radical_ends.front());
+    int end   = 0;
 
     switch (radical_ends.size()) {
       case 1:
         end = start;
         break;
       case 2:
-        end = surf_parse_get_int((radical_ends.back()).c_str());
+        end = surf_parse_get_int(radical_ends.back());
         break;
       default:
         surf_parse_error(std::string("Malformed radical: ") + group);
@@ -706,28 +704,24 @@ void ETag_surfxml_link(){
   sg_platf_new_link(&link);
 }
 
-void STag_surfxml_link___ctn(){
-
+void STag_surfxml_link___ctn()
+{
   simgrid::surf::LinkImpl* link = nullptr;
-  char *link_name=nullptr;
   switch (A_surfxml_link___ctn_direction) {
   case AU_surfxml_link___ctn_direction:
   case A_surfxml_link___ctn_direction_NONE:
     link = simgrid::surf::LinkImpl::byName(A_surfxml_link___ctn_id);
     break;
   case A_surfxml_link___ctn_direction_UP:
-    link_name = bprintf("%s_UP", A_surfxml_link___ctn_id);
-    link      = simgrid::surf::LinkImpl::byName(link_name);
+    link = simgrid::surf::LinkImpl::byName(std::string(A_surfxml_link___ctn_id) + "_UP");
     break;
   case A_surfxml_link___ctn_direction_DOWN:
-    link_name = bprintf("%s_DOWN", A_surfxml_link___ctn_id);
-    link      = simgrid::surf::LinkImpl::byName(link_name);
+    link = simgrid::surf::LinkImpl::byName(std::string(A_surfxml_link___ctn_id) + "_DOWN");
     break;
   default:
-    surf_parse_error(std::string("Invalid direction for link ") + link_name);
+    surf_parse_error(std::string("Invalid direction for link ") + A_surfxml_link___ctn_id);
     break;
   }
-  xbt_free(link_name); // no-op if it's already nullptr
 
   const char* dirname = "";
   switch (A_surfxml_link___ctn_direction) {
@@ -976,7 +970,8 @@ void ETag_surfxml_zone()
 void STag_surfxml_config()
 {
   ZONE_TAG = 0;
-  xbt_assert(current_property_set == nullptr, "Someone forgot to reset the property set to nullptr in its closing tag (or XML malformed)");
+  xbt_assert(current_property_set == nullptr,
+             "Someone forgot to reset the property set to nullptr in its closing tag (or XML malformed)");
   XBT_DEBUG("START configuration name = %s",A_surfxml_config_id);
   if (_sg_cfg_init_status == 2) {
     surf_parse_error("All <config> tags must be given before any platform elements (such as <zone>, <host>, <cluster>, "
@@ -1007,6 +1002,7 @@ void STag_surfxml_process()
   AX_surfxml_actor_function = AX_surfxml_process_function;
   STag_surfxml_actor();
 }
+
 void STag_surfxml_actor()
 {
   ZONE_TAG  = 0;
@@ -1025,6 +1021,7 @@ void ETag_surfxml_process()
   AX_surfxml_actor_on___failure = (AT_surfxml_actor_on___failure)AX_surfxml_process_on___failure;
   ETag_surfxml_actor();
 }
+
 void ETag_surfxml_actor()
 {
   s_sg_platf_process_cbarg_t actor;
@@ -1071,8 +1068,7 @@ void STag_surfxml_model___prop(){
   if (not current_model_property_set)
     current_model_property_set = new std::map<std::string, std::string>();
 
-  current_model_property_set->insert(
-      {std::string(A_surfxml_model___prop_id), std::string(A_surfxml_model___prop_value)});
+  current_model_property_set->insert({A_surfxml_model___prop_id, A_surfxml_model___prop_value});
 }
 
 void ETag_surfxml_prop(){/* Nothing to do */}