Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
fix test (hate dict) and please sonar
authorFrederic Suter <frederic.suter@cc.in2p3.fr>
Mon, 19 Jun 2017 11:12:19 +0000 (13:12 +0200)
committerFrederic Suter <frederic.suter@cc.in2p3.fr>
Mon, 19 Jun 2017 11:12:19 +0000 (13:12 +0200)
examples/msg/io-storage/io-storage.c
include/simgrid/s4u/File.hpp
src/msg/msg_io.cpp
src/s4u/s4u_file.cpp
src/s4u/s4u_storage.cpp
src/surf/StorageImpl.cpp
src/surf/StorageImpl.hpp

index e4075c1..4d5b34f 100644 (file)
@@ -104,7 +104,7 @@ static int host(int argc, char *argv[]){
   xbt_dict_foreach(contents, curs, mountname, content){
     XBT_INFO("Print the content of mount point: %s",mountname);
     xbt_dict_foreach(content,curs2,path,size){
-      XBT_INFO("%s size: %llu bytes", path, (sg_size_t)size);
+      XBT_INFO("%s size: %llu bytes", path, *(sg_size_t*)size);
     }
     xbt_dict_free(&content);
   }
index 27dbf56..75050dd 100644 (file)
@@ -76,10 +76,10 @@ public:
   int desc_id = 0;
 
 private:
-  sg_host_t host_   = nullptr;
   smx_file_t pimpl_ = nullptr;
   const char* path_ = nullptr;
   void* userdata_   = nullptr;
+  sg_host_t host_   = nullptr;
 };
 }
 } // namespace simgrid::s4u
index 7aa6b09..bfb2f3d 100644 (file)
@@ -295,7 +295,7 @@ msg_error_t MSG_file_rcopy (msg_file_t file, msg_host_t host, const char* fullpa
     }
   }
 
-  if (longest_prefix_length > 0) {
+  if (storage_dest != nullptr) {
     /* Mount point found, retrieve the host the storage is attached to */
     dst_host = storage_dest->host();
   }else{
@@ -472,10 +472,12 @@ void *MSG_storage_get_data(msg_storage_t storage)
 xbt_dict_t MSG_storage_get_content(msg_storage_t storage)
 {
   std::map<std::string, sg_size_t>* content = storage->content();
-  xbt_dict_t content_dict = xbt_dict_new_homogeneous(nullptr);
+  xbt_dict_t content_dict = xbt_dict_new_homogeneous(&free);
 
   for (auto entry : *content) {
-    xbt_dict_set(content_dict, entry.first.c_str(), (void*)entry.second, nullptr);
+    sg_size_t* psize = new sg_size_t;
+    *psize           = entry.second;
+    xbt_dict_set(content_dict, entry.first.c_str(), psize, nullptr);
   }
   return content_dict;
 }
index ec8cd7c..3296ba1 100644 (file)
@@ -17,7 +17,7 @@ namespace s4u {
 
 File::File(const char* 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(const char* fullpath, sg_host_t host, void* userdata) : path_(fullpath), userdata_(userdata), host_(host)
 {
   // this cannot fail because we get a xbt_die if the mountpoint does not exist
   Storage* st                  = nullptr;
@@ -42,7 +42,6 @@ File::File(const char* fullpath, sg_host_t host, void* userdata) : path_(fullpat
     xbt_die("Can't find mount point for '%s' on '%s'", fullpath, host->cname());
 
   pimpl_       = simcall_file_open(mount_point.c_str(), path.c_str(), st);
-  host_        = host;
   storage_type = st->type();
   storageId    = st->name();
 }
index b1112a2..d10a19d 100644 (file)
@@ -12,7 +12,6 @@
 namespace simgrid {
 namespace s4u {
 
-//  attached_to_ = Host::by_name_or_null(pimpl->attach_);
 std::map<std::string, Storage*>* allStorages()
 {
   std::unordered_map<std::string, surf::StorageImpl*>* map = surf::StorageImpl::storagesMap();
@@ -38,7 +37,7 @@ const char* Storage::name()
 
 const char* Storage::type()
 {
-  return pimpl_->typeId_;
+  return pimpl_->typeId_.c_str();
 }
 
 Host* Storage::host()
index a6b1317..95c0ffe 100644 (file)
@@ -64,11 +64,11 @@ StorageImpl::StorageImpl(Model* model, const char* name, lmm_system_t maxminSyst
     , piface_(this)
     , size_(size)
     , usedSize_(0)
-    , typeId_(xbt_strdup(type_id))
+    , typeId_(type_id)
+    , attach_(attach)
     , writeActions_(std::vector<StorageAction*>())
 {
   content_ = parseContent(content_name);
-  attach_  = attach;
   turnOn();
   XBT_DEBUG("Create resource with Bread '%f' Bwrite '%f' and Size '%llu'", bread, bwrite, size);
   constraintRead_  = lmm_constraint_new(maxminSystem, this, bread);
@@ -81,8 +81,6 @@ StorageImpl::~StorageImpl()
   storageDestructedCallbacks(this);
   if (content_ != nullptr)
     delete content_;
-
-  free(typeId_);
 }
 
 std::map<std::string, sg_size_t>* StorageImpl::parseContent(const char* filename)
index ac7a602..fbb7449 100644 (file)
@@ -105,7 +105,7 @@ public:
   std::map<std::string, sg_size_t>* content_;
   sg_size_t size_;
   sg_size_t usedSize_;
-  char* typeId_;
+  std::string typeId_;
   std::string attach_; // Name of the host to which this storage is attached.
                        // Only used until the platform is fully parsed only.
                        // Then the interface stores the Host directly.