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:41 UTC

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

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.