Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
[sonar] Use std::move with rvalue references.
authorArnaud Giersch <arnaud.giersch@univ-fcomte.fr>
Wed, 8 Jan 2020 16:13:40 +0000 (17:13 +0100)
committerArnaud Giersch <arnaud.giersch@univ-fcomte.fr>
Wed, 8 Jan 2020 16:53:44 +0000 (17:53 +0100)
include/simgrid/simix/blocking_simcall.hpp
include/xbt/functional.hpp
include/xbt/string.hpp
src/mc/inspect/mc_unw.hpp
src/mc/mc_global.cpp
src/mc/remote/RemoteClient.cpp

index e43affe..973ead8 100644 (file)
@@ -57,7 +57,7 @@ template <class F> auto kernel_sync(F code) -> decltype(code().get())
         try {
           auto future = code();
           future.then_([&result, self](std::shared_ptr<simgrid::kernel::FutureState<T>>&& value) {
-            simgrid::xbt::set_promise(result, simgrid::kernel::Future<T>(value));
+            simgrid::xbt::set_promise(result, simgrid::kernel::Future<T>(std::move(value)));
             simgrid::simix::unblock(self);
           });
         } catch (...) {
@@ -94,7 +94,7 @@ public:
             // When the kernel future is ready...
             this->future_.then_([&result, self](std::shared_ptr<simgrid::kernel::FutureState<T>>&& value) {
               // ... wake up the process with the result of the kernel future.
-              simgrid::xbt::set_promise(result, simgrid::kernel::Future<T>(value));
+              simgrid::xbt::set_promise(result, simgrid::kernel::Future<T>(std::move(value)));
               simgrid::simix::unblock(self);
             });
           } catch (...) {
@@ -125,7 +125,7 @@ public:
             // When the kernel future is ready...
             this->future_.then_([this, self](std::shared_ptr<simgrid::kernel::FutureState<T>>&& value) {
               // ...store it the simix kernel and wake up.
-              this->future_ = std::move(simgrid::kernel::Future<T>(value));
+              this->future_ = simgrid::kernel::Future<T>(std::move(value));
               simgrid::simix::unblock(self);
             });
           } catch (...) {
index f5bf973..b7e361e 100644 (file)
@@ -168,8 +168,7 @@ public:
       that.vtable_->move(buffer_, that.buffer_);
     else
       std::memcpy(static_cast<void*>(&buffer_), static_cast<void*>(&that.buffer_), sizeof(buffer_));
-
-    vtable_ = that.vtable_;
+    vtable_      = std::move(that.vtable_);
     that.vtable_ = nullptr;
   }
   Task& operator=(Task const& that) = delete;
@@ -180,7 +179,7 @@ public:
       that.vtable_->move(buffer_, that.buffer_);
     else
       std::memcpy(static_cast<void*>(&buffer_), static_cast<void*>(&that.buffer_), sizeof(buffer_));
-    vtable_ = that.vtable_;
+    vtable_      = std::move(that.vtable_);
     that.vtable_ = nullptr;
     return *this;
   }
index 0169240..a8f2020 100644 (file)
@@ -91,8 +91,7 @@ public:
   string(string const& s) : string(s.c_str(), s.size()) {}
   string(string&& s)
   {
-    str.len    = s.str.len;
-    str.data   = s.str.data;
+    str        = std::move(s.str);
     s.str.len  = 0;
     s.str.data = &NUL;
   }
index 8c40bd2..206c92d 100644 (file)
@@ -68,8 +68,7 @@ public:
   static unw_addr_space_t createUnwindAddressSpace();
 };
 
-void dumpStack(FILE* file, unw_cursor_t&& cursor);
-void dumpStack(FILE* file, pid_t pid);
+void dumpStack(FILE* file, unw_cursor_t cursor);
 } // namespace mc
 } // namespace simgrid
 
index 0ca25e3..b6d1c09 100644 (file)
@@ -106,7 +106,7 @@ void MC_automaton_load(const char *file)
 namespace simgrid {
 namespace mc {
 
-void dumpStack(FILE* file, unw_cursor_t&& cursor)
+void dumpStack(FILE* file, unw_cursor_t cursor)
 {
   int nframe = 0;
   char buffer[100];
index c48a4bf..e727460 100644 (file)
@@ -622,7 +622,7 @@ void RemoteClient::dump_stack()
     return;
   }
 
-  simgrid::mc::dumpStack(stderr, std::move(cursor));
+  simgrid::mc::dumpStack(stderr, cursor);
 
   _UPT_destroy(context);
   unw_destroy_addr_space(as);