You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@mesos.apache.org by mp...@apache.org on 2017/11/21 06:17:38 UTC

[1/4] mesos git commit: MesosTidy [misc-use-after-move]: Added `NOLINT` to false-positives.

Repository: mesos
Updated Branches:
  refs/heads/master 0af8dc401 -> 7d5ee197e


MesosTidy [misc-use-after-move]: Added `NOLINT` to false-positives.

```
3rdparty/libprocess/src/../include/process/future.hpp:1187:5: warning:
'callback' used after it was moved [misc-use-after-move]
    callback();
    ^
3rdparty/libprocess/src/../include/process/future.hpp:1181:32: note:
move occurred here
      data->onDiscardCallbacks.emplace_back(std::move(callback));
                               ^
```

Review: https://reviews.apache.org/r/63932


Project: http://git-wip-us.apache.org/repos/asf/mesos/repo
Commit: http://git-wip-us.apache.org/repos/asf/mesos/commit/56c9ff46
Tree: http://git-wip-us.apache.org/repos/asf/mesos/tree/56c9ff46
Diff: http://git-wip-us.apache.org/repos/asf/mesos/diff/56c9ff46

Branch: refs/heads/master
Commit: 56c9ff460604bf7db20941e997a0f07cc7bde0a8
Parents: 6026b80
Author: Michael Park <mp...@apache.org>
Authored: Wed Nov 8 02:23:26 2017 -0800
Committer: Michael Park <mp...@apache.org>
Committed: Mon Nov 20 22:16:36 2017 -0800

----------------------------------------------------------------------
 3rdparty/libprocess/include/process/future.hpp | 10 +++++-----
 3rdparty/libprocess/src/http.cpp               |  2 +-
 2 files changed, 6 insertions(+), 6 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/mesos/blob/56c9ff46/3rdparty/libprocess/include/process/future.hpp
----------------------------------------------------------------------
diff --git a/3rdparty/libprocess/include/process/future.hpp b/3rdparty/libprocess/include/process/future.hpp
index 155499e..97bc0c8 100644
--- a/3rdparty/libprocess/include/process/future.hpp
+++ b/3rdparty/libprocess/include/process/future.hpp
@@ -1329,7 +1329,7 @@ const Future<T>& Future<T>::onAbandoned(AbandonedCallback&& callback) const
 
   // TODO(*): Invoke callback in another execution context.
   if (run) {
-    callback();
+    callback(); // NOLINT(misc-use-after-move)
   }
 
   return *this;
@@ -1351,7 +1351,7 @@ const Future<T>& Future<T>::onDiscard(DiscardCallback&& callback) const
 
   // TODO(*): Invoke callback in another execution context.
   if (run) {
-    callback();
+    callback(); // NOLINT(misc-use-after-move)
   }
 
   return *this;
@@ -1373,7 +1373,7 @@ const Future<T>& Future<T>::onReady(ReadyCallback&& callback) const
 
   // TODO(*): Invoke callback in another execution context.
   if (run) {
-    callback(data->result.get());
+    callback(data->result.get()); // NOLINT(misc-use-after-move)
   }
 
   return *this;
@@ -1395,7 +1395,7 @@ const Future<T>& Future<T>::onFailed(FailedCallback&& callback) const
 
   // TODO(*): Invoke callback in another execution context.
   if (run) {
-    callback(data->result.error());
+    callback(data->result.error()); // NOLINT(misc-use-after-move)
   }
 
   return *this;
@@ -1439,7 +1439,7 @@ const Future<T>& Future<T>::onAny(AnyCallback&& callback) const
 
   // TODO(*): Invoke callback in another execution context.
   if (run) {
-    callback(*this);
+    callback(*this); // NOLINT(misc-use-after-move)
   }
 
   return *this;

http://git-wip-us.apache.org/repos/asf/mesos/blob/56c9ff46/3rdparty/libprocess/src/http.cpp
----------------------------------------------------------------------
diff --git a/3rdparty/libprocess/src/http.cpp b/3rdparty/libprocess/src/http.cpp
index 123c5c3..0cecb28 100644
--- a/3rdparty/libprocess/src/http.cpp
+++ b/3rdparty/libprocess/src/http.cpp
@@ -533,7 +533,7 @@ bool Pipe::Writer::write(string s)
   // NOTE: We set the promise outside the critical section to avoid
   // triggering callbacks that try to reacquire the lock.
   if (read.get() != nullptr) {
-    read->set(std::move(s));
+    read->set(std::move(s)); // NOLINT(misc-use-after-move)
   }
 
   return written;


[2/4] mesos git commit: MesosTidy [misc-use-after-move]: Fixed `HashMapTest` test.

Posted by mp...@apache.org.
MesosTidy [misc-use-after-move]: Fixed `HashMapTest` test.

```
3rdparty/stout/tests/hashmap_tests.cpp:68:17: warning: 'map1' used after
it was moved [misc-use-after-move]
  EXPECT_EQ(2u, map1.size());
                ^
3rdparty/stout/tests/hashmap_tests.cpp:66:21: note: move occurred here
  hashmap<int, int> map2(std::move(map1));
                    ^
```

Review: https://reviews.apache.org/r/63931


Project: http://git-wip-us.apache.org/repos/asf/mesos/repo
Commit: http://git-wip-us.apache.org/repos/asf/mesos/commit/6026b805
Tree: http://git-wip-us.apache.org/repos/asf/mesos/tree/6026b805
Diff: http://git-wip-us.apache.org/repos/asf/mesos/diff/6026b805

Branch: refs/heads/master
Commit: 6026b8054117c5a71064c2c4700c8bbb3361ee1c
Parents: eb25c1a
Author: Michael Park <mp...@apache.org>
Authored: Wed Nov 8 02:23:07 2017 -0800
Committer: Michael Park <mp...@apache.org>
Committed: Mon Nov 20 22:16:36 2017 -0800

----------------------------------------------------------------------
 3rdparty/stout/tests/hashmap_tests.cpp | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/mesos/blob/6026b805/3rdparty/stout/tests/hashmap_tests.cpp
----------------------------------------------------------------------
diff --git a/3rdparty/stout/tests/hashmap_tests.cpp b/3rdparty/stout/tests/hashmap_tests.cpp
index 321f404..38a33dc 100644
--- a/3rdparty/stout/tests/hashmap_tests.cpp
+++ b/3rdparty/stout/tests/hashmap_tests.cpp
@@ -65,11 +65,11 @@ TEST(HashMapTest, FromRValueStdMap)
 
   hashmap<int, int> map2(std::move(map1));
 
-  EXPECT_EQ(2u, map1.size());
+  EXPECT_EQ(2u, map2.size());
 
-  EXPECT_EQ(2, map1[1]);
+  EXPECT_EQ(2, map2[1]);
 
-  EXPECT_EQ(3, map1[2]);
+  EXPECT_EQ(3, map2[2]);
 }
 
 


[4/4] mesos git commit: MesosTidy [misc-use-after-move]: Arguments moved into chained calls.

Posted by mp...@apache.org.
MesosTidy [misc-use-after-move]: Arguments moved into chained calls.

```
3rdparty/libprocess/src/process.cpp:2298:33:
warning: 'message' used after it was moved [misc-use-after-move]
      poll_socket.get().connect(message.to.address)
                                ^
3rdparty/libprocess/src/process.cpp:2299:16: note: move occurred here
        .onAny(lambda::bind(
               ^
3rdparty/libprocess/src/process.cpp:2298:33: note: the use and move are
unsequenced, i.e. there is no guarantee about the order in which they
are evaluated
      poll_socket.get().connect(message.to.address)
                                ^
```

Given an expression like `x.f(a).g(b)`, in C++11/4, there's no guarantee
that `f(a)` is fully evaluated before `b` is evaluated.

Either of the following are valid evaluation order:
  - `a`, `f(a)`, `b`, `g(b)` or
  - `a`, `b`, `f(a)`, `g(b)`

More so if there `a` and `b` actually contain subexpressions.

In C++17, we could rely on this order since it is guaranteed to be:
  - `a`, `f(a)`, `b`, `g(b)`

http://eel.is/c++draft/expr.compound#expr.call-5

Review: https://reviews.apache.org/r/63933


Project: http://git-wip-us.apache.org/repos/asf/mesos/repo
Commit: http://git-wip-us.apache.org/repos/asf/mesos/commit/7d5ee197
Tree: http://git-wip-us.apache.org/repos/asf/mesos/tree/7d5ee197
Diff: http://git-wip-us.apache.org/repos/asf/mesos/diff/7d5ee197

Branch: refs/heads/master
Commit: 7d5ee197e060d3fba8afc980703cda2253456c78
Parents: 56c9ff4
Author: Michael Park <mp...@apache.org>
Authored: Fri Nov 17 15:28:54 2017 -0800
Committer: Michael Park <mp...@apache.org>
Committed: Mon Nov 20 22:16:37 2017 -0800

----------------------------------------------------------------------
 3rdparty/libprocess/src/process.cpp | 16 +++++++++-------
 1 file changed, 9 insertions(+), 7 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/mesos/blob/7d5ee197/3rdparty/libprocess/src/process.cpp
----------------------------------------------------------------------
diff --git a/3rdparty/libprocess/src/process.cpp b/3rdparty/libprocess/src/process.cpp
index 17138fd..64bcce2 100644
--- a/3rdparty/libprocess/src/process.cpp
+++ b/3rdparty/libprocess/src/process.cpp
@@ -1864,13 +1864,15 @@ void SocketManager::send_connect(
       }
 
       CHECK_SOME(poll_socket);
-      poll_socket.get().connect(message.to.address)
-        .onAny(lambda::bind(
-            // TODO(benh): with C++14 we can use lambda instead of
-            // `std::bind` and capture `message` with a `std::move`.
-            [this, poll_socket](Message& message, const Future<Nothing>& f) {
-              send_connect(f, poll_socket.get(), std::move(message));
-            }, std::move(message), lambda::_1));
+      Future<Nothing> connect = poll_socket.get().connect(message.to.address);
+      connect.onAny(lambda::bind(
+          // TODO(benh): with C++14 we can use lambda instead of
+          // `std::bind` and capture `message` with a `std::move`.
+          [this, poll_socket](Message& message, const Future<Nothing>& f) {
+            send_connect(f, poll_socket.get(), std::move(message));
+          },
+          std::move(message),
+          lambda::_1));
 
       // We don't need to 'shutdown()' the socket as it was never
       // connected.


[3/4] mesos git commit: MesosTidy: Turned on [misc-use-after-move].

Posted by mp...@apache.org.
MesosTidy: Turned on [misc-use-after-move].

Review: https://reviews.apache.org/r/63930


Project: http://git-wip-us.apache.org/repos/asf/mesos/repo
Commit: http://git-wip-us.apache.org/repos/asf/mesos/commit/eb25c1a2
Tree: http://git-wip-us.apache.org/repos/asf/mesos/tree/eb25c1a2
Diff: http://git-wip-us.apache.org/repos/asf/mesos/diff/eb25c1a2

Branch: refs/heads/master
Commit: eb25c1a2f596b834fe01d2d328ca9f6de7173565
Parents: 0af8dc4
Author: Michael Park <mp...@apache.org>
Authored: Wed Nov 8 02:22:19 2017 -0800
Committer: Michael Park <mp...@apache.org>
Committed: Mon Nov 20 22:16:36 2017 -0800

----------------------------------------------------------------------
 support/clang-tidy | 2 ++
 1 file changed, 2 insertions(+)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/mesos/blob/eb25c1a2/support/clang-tidy
----------------------------------------------------------------------
diff --git a/support/clang-tidy b/support/clang-tidy
index 47a2cad..d68ddab 100644
--- a/support/clang-tidy
+++ b/support/clang-tidy
@@ -25,6 +25,8 @@ google-*,\
 mesos-*,\
 -mesos-this-capture,\
 \
+misc-use-after-move,\
+\
 readability-redundant-string-cstr\
 "
 FormatStyle: file