kudu-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From t...@apache.org
Subject [1/3] kudu git commit: Fix some clang-tidy errors for std::move
Date Fri, 03 Feb 2017 02:06:11 GMT
Repository: kudu
Updated Branches:
  refs/heads/master 85fd90996 -> cb06dd12a


Fix some clang-tidy errors for std::move

Clang-tidy reported a few errors in a recent code review
of moved code[1]. Rather than fix them in the commit that just moved the
code, I fixed them separately. This also fixes a few other similar cases
I spotted where shared_ptr<Messenger> should be std::moved, and other
cases where MonoTime/MonoDelta should not be std::moved.

[1] https://gerrit.cloudera.org/#/c/5864/1/src/kudu/client/master_rpc.cc

Change-Id: I61a51478685a50c50c84319bd32d506fe372c3c4
Reviewed-on: http://gerrit.cloudera.org:8080/5867
Reviewed-by: Adar Dembo <adar@cloudera.com>
Reviewed-by: Alexey Serbin <aserbin@cloudera.com>
Tested-by: Todd Lipcon <todd@apache.org>


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

Branch: refs/heads/master
Commit: 6aba5eff8e5a541fcd4b57460d5d33938327aecc
Parents: 85fd909
Author: Todd Lipcon <todd@apache.org>
Authored: Wed Feb 1 18:46:36 2017 -0800
Committer: Todd Lipcon <todd@apache.org>
Committed: Fri Feb 3 01:06:59 2017 +0000

----------------------------------------------------------------------
 src/kudu/client/batcher.cc            |  6 +++---
 src/kudu/client/client-internal.cc    |  1 -
 src/kudu/client/master_rpc.cc         | 22 +++++++++++-----------
 src/kudu/client/meta_cache.cc         |  6 +++---
 src/kudu/client/meta_cache.h          |  2 +-
 src/kudu/rpc/exactly_once_rpc-test.cc |  9 +++++----
 src/kudu/rpc/proxy.cc                 |  6 +++---
 src/kudu/rpc/proxy.h                  |  2 +-
 src/kudu/rpc/reactor.cc               | 10 +++++-----
 src/kudu/rpc/reactor.h                |  2 +-
 src/kudu/rpc/retriable_rpc.h          | 12 ++++++------
 src/kudu/rpc/rpc-bench.cc             |  2 +-
 src/kudu/rpc/rpc.h                    |  6 +++---
 src/kudu/tools/ksck.cc                |  2 +-
 src/kudu/tools/ksck_remote.h          |  4 ++--
 15 files changed, 46 insertions(+), 46 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/kudu/blob/6aba5eff/src/kudu/client/batcher.cc
----------------------------------------------------------------------
diff --git a/src/kudu/client/batcher.cc b/src/kudu/client/batcher.cc
index 53a57d5..a3d9b7a 100644
--- a/src/kudu/client/batcher.cc
+++ b/src/kudu/client/batcher.cc
@@ -199,7 +199,7 @@ class WriteRpc : public RetriableRpc<RemoteTabletServer, WriteRequestPB,
WriteRe
            const scoped_refptr<RequestTracker>& request_tracker,
            vector<InFlightOp*> ops,
            const MonoTime& deadline,
-           const shared_ptr<Messenger>& messenger,
+           shared_ptr<Messenger> messenger,
            const string& tablet_id,
            uint64_t propagated_timestamp);
   virtual ~WriteRpc();
@@ -237,10 +237,10 @@ WriteRpc::WriteRpc(const scoped_refptr<Batcher>& batcher,
                    const scoped_refptr<RequestTracker>& request_tracker,
                    vector<InFlightOp*> ops,
                    const MonoTime& deadline,
-                   const shared_ptr<Messenger>& messenger,
+                   shared_ptr<Messenger> messenger,
                    const string& tablet_id,
                    uint64_t propagated_timestamp)
-    : RetriableRpc(replica_picker, request_tracker, deadline, messenger),
+    : RetriableRpc(replica_picker, request_tracker, deadline, std::move(messenger)),
       batcher_(batcher),
       ops_(std::move(ops)),
       tablet_id_(tablet_id) {

http://git-wip-us.apache.org/repos/asf/kudu/blob/6aba5eff/src/kudu/client/client-internal.cc
----------------------------------------------------------------------
diff --git a/src/kudu/client/client-internal.cc b/src/kudu/client/client-internal.cc
index f53f540..176d3d7 100644
--- a/src/kudu/client/client-internal.cc
+++ b/src/kudu/client/client-internal.cc
@@ -84,7 +84,6 @@ using strings::Substitute;
 namespace client {
 
 using internal::GetLeaderMasterRpc;
-using internal::GetTableSchemaRpc;
 using internal::RemoteTablet;
 using internal::RemoteTabletServer;
 

http://git-wip-us.apache.org/repos/asf/kudu/blob/6aba5eff/src/kudu/client/master_rpc.cc
----------------------------------------------------------------------
diff --git a/src/kudu/client/master_rpc.cc b/src/kudu/client/master_rpc.cc
index 5878c58..4e032ec 100644
--- a/src/kudu/client/master_rpc.cc
+++ b/src/kudu/client/master_rpc.cc
@@ -62,9 +62,10 @@ class GetMasterRegistrationRpc : public rpc::Rpc {
   // pointer for the lifetime of this object.
   //
   // Invokes 'user_cb' upon failure or success of the RPC call.
-  GetMasterRegistrationRpc(StatusCallback user_cb, Sockaddr addr,
+  GetMasterRegistrationRpc(StatusCallback user_cb,
+                           const Sockaddr& addr,
                            const MonoTime& deadline,
-                           const std::shared_ptr<rpc::Messenger>& messenger,
+                           std::shared_ptr<rpc::Messenger> messenger,
                            ServerEntryPB* out);
 
   ~GetMasterRegistrationRpc();
@@ -86,11 +87,11 @@ class GetMasterRegistrationRpc : public rpc::Rpc {
 
 
 GetMasterRegistrationRpc::GetMasterRegistrationRpc(
-    StatusCallback user_cb, Sockaddr addr, const MonoTime& deadline,
-    const shared_ptr<Messenger>& messenger, ServerEntryPB* out)
-    : Rpc(deadline, messenger),
+    StatusCallback user_cb, const Sockaddr& addr, const MonoTime& deadline,
+    shared_ptr<Messenger> messenger, ServerEntryPB* out)
+    : Rpc(deadline, std::move(messenger)),
       user_cb_(std::move(user_cb)),
-      addr_(std::move(addr)),
+      addr_(addr),
       out_(DCHECK_NOTNULL(out)) {}
 
 GetMasterRegistrationRpc::~GetMasterRegistrationRpc() {
@@ -150,10 +151,10 @@ GetLeaderMasterRpc::GetLeaderMasterRpc(LeaderCallback user_cb,
                                        MonoTime deadline,
                                        MonoDelta rpc_timeout,
                                        shared_ptr<Messenger> messenger)
-    : Rpc(std::move(deadline), std::move(messenger)),
+    : Rpc(deadline, std::move(messenger)),
       user_cb_(std::move(user_cb)),
       addrs_(std::move(addrs)),
-      rpc_timeout_(std::move(rpc_timeout)),
+      rpc_timeout_(rpc_timeout),
       pending_responses_(0),
       completed_(false) {
   DCHECK(deadline.Initialized());
@@ -230,7 +231,7 @@ void GetLeaderMasterRpc::SendRpcCb(const Status& status) {
 void GetLeaderMasterRpc::GetMasterRegistrationRpcCbForNode(const Sockaddr& node_addr,
                                                            const ServerEntryPB& resp,
                                                            const Status& status) {
-  // TODO: handle the situation where one Master is partitioned from
+  // TODO(todd): handle the situation where one Master is partitioned from
   // the rest of the Master consensus configuration, all are reachable by the client,
   // and the partitioned node "thinks" it's the leader.
   //
@@ -268,9 +269,8 @@ void GetLeaderMasterRpc::GetMasterRegistrationRpcCbForNode(const Sockaddr&
node_
         // a delayed re-try, which don't need to do unless we've
         // been unable to find a leader so far.
         return;
-      } else {
-        completed_ = true;
       }
+      completed_ = true;
     }
   }
   // Called if the leader has been determined, or if we've received

http://git-wip-us.apache.org/repos/asf/kudu/blob/6aba5eff/src/kudu/client/meta_cache.cc
----------------------------------------------------------------------
diff --git a/src/kudu/client/meta_cache.cc b/src/kudu/client/meta_cache.cc
index 1cee1fd..eb40f68 100644
--- a/src/kudu/client/meta_cache.cc
+++ b/src/kudu/client/meta_cache.cc
@@ -516,7 +516,7 @@ class LookupRpc : public Rpc {
             string partition_key,
             scoped_refptr<RemoteTablet>* remote_tablet,
             const MonoTime& deadline,
-            const shared_ptr<Messenger>& messenger,
+            shared_ptr<Messenger> messenger,
             bool is_exact_lookup);
   virtual ~LookupRpc();
   virtual void SendRpc() OVERRIDE;
@@ -583,9 +583,9 @@ LookupRpc::LookupRpc(const scoped_refptr<MetaCache>& meta_cache,
                      string partition_key,
                      scoped_refptr<RemoteTablet>* remote_tablet,
                      const MonoTime& deadline,
-                     const shared_ptr<Messenger>& messenger,
+                     shared_ptr<Messenger> messenger,
                      bool is_exact_lookup)
-    : Rpc(deadline, messenger),
+    : Rpc(deadline, std::move(messenger)),
       meta_cache_(meta_cache),
       user_cb_(std::move(user_cb)),
       table_(table),

http://git-wip-us.apache.org/repos/asf/kudu/blob/6aba5eff/src/kudu/client/meta_cache.h
----------------------------------------------------------------------
diff --git a/src/kudu/client/meta_cache.h b/src/kudu/client/meta_cache.h
index 8bb69ce..b013076 100644
--- a/src/kudu/client/meta_cache.h
+++ b/src/kudu/client/meta_cache.h
@@ -267,7 +267,7 @@ class MetaCacheEntry {
   MetaCacheEntry(MonoTime expiration_time,
                  std::string lower_bound_partition_key,
                  std::string upper_bound_partition_key)
-      : expiration_time_(std::move(expiration_time)),
+      : expiration_time_(expiration_time),
         lower_bound_partition_key_(std::move(lower_bound_partition_key)),
         upper_bound_partition_key_(std::move(upper_bound_partition_key)) {
   }

http://git-wip-us.apache.org/repos/asf/kudu/blob/6aba5eff/src/kudu/rpc/exactly_once_rpc-test.cc
----------------------------------------------------------------------
diff --git a/src/kudu/rpc/exactly_once_rpc-test.cc b/src/kudu/rpc/exactly_once_rpc-test.cc
index 28537e0..1fb945d 100644
--- a/src/kudu/rpc/exactly_once_rpc-test.cc
+++ b/src/kudu/rpc/exactly_once_rpc-test.cc
@@ -72,11 +72,12 @@ class CalculatorServiceRpc : public RetriableRpc<CalculatorServiceProxy,
   CalculatorServiceRpc(const scoped_refptr<TestServerPicker>& server_picker,
                        const scoped_refptr<RequestTracker>& request_tracker,
                        const MonoTime& deadline,
-                       const shared_ptr<Messenger>& messenger,
+                       shared_ptr<Messenger> messenger,
                        int value,
                        CountDownLatch* latch,
                        int server_sleep = 0)
-      : RetriableRpc(server_picker, request_tracker, deadline, messenger), latch_(latch)
{
+      : RetriableRpc(server_picker, request_tracker, deadline, std::move(messenger)),
+        latch_(latch) {
     req_.set_value_to_add(value);
     req_.set_randomly_fail(true);
     req_.set_sleep_for_ms(server_sleep);
@@ -168,7 +169,7 @@ class ExactlyOnceRpcTest : public RpcTestBase {
   struct RetriableRpcExactlyOnceAdder {
     RetriableRpcExactlyOnceAdder(const scoped_refptr<TestServerPicker>& server_picker,
                      const scoped_refptr<RequestTracker>& request_tracker,
-                     const shared_ptr<Messenger>& messenger,
+                     shared_ptr<Messenger> messenger,
                      int value,
                      int server_sleep = 0) : latch_(1) {
       MonoTime now = MonoTime::Now();
@@ -176,7 +177,7 @@ class ExactlyOnceRpcTest : public RpcTestBase {
       rpc_ = new CalculatorServiceRpc(server_picker,
                                       request_tracker,
                                       now,
-                                      messenger,
+                                      std::move(messenger),
                                       value,
                                       &latch_);
     }

http://git-wip-us.apache.org/repos/asf/kudu/blob/6aba5eff/src/kudu/rpc/proxy.cc
----------------------------------------------------------------------
diff --git a/src/kudu/rpc/proxy.cc b/src/kudu/rpc/proxy.cc
index c8e5017..206aac3 100644
--- a/src/kudu/rpc/proxy.cc
+++ b/src/kudu/rpc/proxy.cc
@@ -47,12 +47,12 @@ using std::shared_ptr;
 namespace kudu {
 namespace rpc {
 
-Proxy::Proxy(const std::shared_ptr<Messenger>& messenger,
+Proxy::Proxy(std::shared_ptr<Messenger> messenger,
              const Sockaddr& remote, string service_name)
     : service_name_(std::move(service_name)),
-      messenger_(messenger),
+      messenger_(std::move(messenger)),
       is_started_(false) {
-  CHECK(messenger != nullptr);
+  CHECK(messenger_ != nullptr);
   DCHECK(!service_name_.empty()) << "Proxy service name must not be blank";
 
   // By default, we set the real user to the currently logged-in user.

http://git-wip-us.apache.org/repos/asf/kudu/blob/6aba5eff/src/kudu/rpc/proxy.h
----------------------------------------------------------------------
diff --git a/src/kudu/rpc/proxy.h b/src/kudu/rpc/proxy.h
index b1bc350..ddbbe60 100644
--- a/src/kudu/rpc/proxy.h
+++ b/src/kudu/rpc/proxy.h
@@ -55,7 +55,7 @@ class Messenger;
 // After initialization, multiple threads may make calls using the same proxy object.
 class Proxy {
  public:
-  Proxy(const std::shared_ptr<Messenger>& messenger, const Sockaddr& remote,
+  Proxy(std::shared_ptr<Messenger> messenger, const Sockaddr& remote,
         std::string service_name);
   ~Proxy();
 

http://git-wip-us.apache.org/repos/asf/kudu/blob/6aba5eff/src/kudu/rpc/reactor.cc
----------------------------------------------------------------------
diff --git a/src/kudu/rpc/reactor.cc b/src/kudu/rpc/reactor.cc
index 4a78f8c..da185b0 100644
--- a/src/kudu/rpc/reactor.cc
+++ b/src/kudu/rpc/reactor.cc
@@ -490,12 +490,12 @@ void DelayedTask::TimerHandler(ev::timer& watcher, int revents)
{
   }
 }
 
-Reactor::Reactor(const shared_ptr<Messenger>& messenger,
+Reactor::Reactor(shared_ptr<Messenger> messenger,
                  int index, const MessengerBuilder& bld)
-  : messenger_(messenger),
-    name_(StringPrintf("%s_R%03d", messenger->name().c_str(), index)),
-    closing_(false),
-    thread_(this, bld) {
+    : messenger_(std::move(messenger)),
+      name_(StringPrintf("%s_R%03d", messenger_->name().c_str(), index)),
+      closing_(false),
+      thread_(this, bld) {
 }
 
 Status Reactor::Init() {

http://git-wip-us.apache.org/repos/asf/kudu/blob/6aba5eff/src/kudu/rpc/reactor.h
----------------------------------------------------------------------
diff --git a/src/kudu/rpc/reactor.h b/src/kudu/rpc/reactor.h
index f9f5662..a31392b 100644
--- a/src/kudu/rpc/reactor.h
+++ b/src/kudu/rpc/reactor.h
@@ -269,7 +269,7 @@ class ReactorThread {
 // A Reactor manages a ReactorThread
 class Reactor {
  public:
-  Reactor(const std::shared_ptr<Messenger>& messenger,
+  Reactor(std::shared_ptr<Messenger> messenger,
           int index,
           const MessengerBuilder &bld);
   Status Init();

http://git-wip-us.apache.org/repos/asf/kudu/blob/6aba5eff/src/kudu/rpc/retriable_rpc.h
----------------------------------------------------------------------
diff --git a/src/kudu/rpc/retriable_rpc.h b/src/kudu/rpc/retriable_rpc.h
index a81d160..3817bb9 100644
--- a/src/kudu/rpc/retriable_rpc.h
+++ b/src/kudu/rpc/retriable_rpc.h
@@ -52,12 +52,12 @@ class RetriableRpc : public Rpc {
   RetriableRpc(const scoped_refptr<ServerPicker<Server>>& server_picker,
                const scoped_refptr<RequestTracker>& request_tracker,
                const MonoTime& deadline,
-               const std::shared_ptr<Messenger>& messenger)
-   : Rpc(deadline, messenger),
-     server_picker_(server_picker),
-     request_tracker_(request_tracker),
-     sequence_number_(RequestTracker::NO_SEQ_NO),
-     num_attempts_(0) {}
+               std::shared_ptr<Messenger> messenger)
+      : Rpc(deadline, std::move(messenger)),
+        server_picker_(server_picker),
+        request_tracker_(request_tracker),
+        sequence_number_(RequestTracker::NO_SEQ_NO),
+        num_attempts_(0) {}
 
   virtual ~RetriableRpc() {
     DCHECK_EQ(sequence_number_, RequestTracker::NO_SEQ_NO);

http://git-wip-us.apache.org/repos/asf/kudu/blob/6aba5eff/src/kudu/rpc/rpc-bench.cc
----------------------------------------------------------------------
diff --git a/src/kudu/rpc/rpc-bench.cc b/src/kudu/rpc/rpc-bench.cc
index c4a051a..809697a 100644
--- a/src/kudu/rpc/rpc-bench.cc
+++ b/src/kudu/rpc/rpc-bench.cc
@@ -174,7 +174,7 @@ class ClientAsyncWorkload {
  public:
   ClientAsyncWorkload(RpcBench *bench, shared_ptr<Messenger> messenger)
     : bench_(bench),
-      messenger_(messenger),
+      messenger_(std::move(messenger)),
       request_count_(0) {
     controller_.set_timeout(MonoDelta::FromSeconds(10));
     proxy_.reset(new CalculatorServiceProxy(messenger_, bench_->server_addr_));

http://git-wip-us.apache.org/repos/asf/kudu/blob/6aba5eff/src/kudu/rpc/rpc.h
----------------------------------------------------------------------
diff --git a/src/kudu/rpc/rpc.h b/src/kudu/rpc/rpc.h
index 6dd95fe..077c8f3 100644
--- a/src/kudu/rpc/rpc.h
+++ b/src/kudu/rpc/rpc.h
@@ -99,7 +99,7 @@ class RpcRetrier {
  public:
   RpcRetrier(MonoTime deadline, std::shared_ptr<rpc::Messenger> messenger)
       : attempt_num_(1),
-        deadline_(std::move(deadline)),
+        deadline_(deadline),
         messenger_(std::move(messenger)) {
     if (deadline_.Initialized()) {
       controller_.set_deadline(deadline_);
@@ -168,8 +168,8 @@ class RpcRetrier {
 class Rpc {
  public:
   Rpc(const MonoTime& deadline,
-      const std::shared_ptr<rpc::Messenger>& messenger)
-  : retrier_(deadline, messenger) {
+      std::shared_ptr<rpc::Messenger> messenger)
+      : retrier_(deadline, std::move(messenger)) {
   }
 
   virtual ~Rpc() {}

http://git-wip-us.apache.org/repos/asf/kudu/blob/6aba5eff/src/kudu/tools/ksck.cc
----------------------------------------------------------------------
diff --git a/src/kudu/tools/ksck.cc b/src/kudu/tools/ksck.cc
index 21cc6ba..67beac1 100644
--- a/src/kudu/tools/ksck.cc
+++ b/src/kudu/tools/ksck.cc
@@ -105,7 +105,7 @@ ChecksumOptions::ChecksumOptions()
 
 ChecksumOptions::ChecksumOptions(MonoDelta timeout, int scan_concurrency,
                                  bool use_snapshot, uint64_t snapshot_timestamp)
-    : timeout(std::move(timeout)),
+    : timeout(timeout),
       scan_concurrency(scan_concurrency),
       use_snapshot(use_snapshot),
       snapshot_timestamp(snapshot_timestamp) {}

http://git-wip-us.apache.org/repos/asf/kudu/blob/6aba5eff/src/kudu/tools/ksck_remote.h
----------------------------------------------------------------------
diff --git a/src/kudu/tools/ksck_remote.h b/src/kudu/tools/ksck_remote.h
index ee049d6..698a678 100644
--- a/src/kudu/tools/ksck_remote.h
+++ b/src/kudu/tools/ksck_remote.h
@@ -91,9 +91,9 @@ class RemoteKsckMaster : public KsckMaster {
  private:
 
   RemoteKsckMaster(const std::vector<std::string>& master_addresses,
-                   const std::shared_ptr<rpc::Messenger>& messenger)
+                   std::shared_ptr<rpc::Messenger> messenger)
       : master_addresses_(master_addresses),
-        messenger_(messenger) {
+        messenger_(std::move(messenger)) {
   }
 
   const std::vector<std::string> master_addresses_;


Mime
View raw message