kudu-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From danburk...@apache.org
Subject [1/4] kudu git commit: Fix various use-after-move errors
Date Fri, 09 Jun 2017 20:28:48 GMT
Repository: kudu
Updated Branches:
  refs/heads/master 6dade2aa0 -> 8d2ca982f


Fix various use-after-move errors

This fixes all of the cases where clang-tidy detects
'misc-use-after-move'. This is necessary before enabling protobuf move
constructors to avoid test failures.

Change-Id: I2895a3c334ee1f1e6c9d82d587973adf66ce3738
Reviewed-on: http://gerrit.cloudera.org:8080/7130
Reviewed-by: Dan Burkert <danburkert@apache.org>
Tested-by: Kudu Jenkins


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

Branch: refs/heads/master
Commit: f1e75b728e351d73b5439a8a46eec59977588dc1
Parents: 6dade2a
Author: Todd Lipcon <todd@cloudera.com>
Authored: Thu Jun 8 18:59:38 2017 -0700
Committer: Todd Lipcon <todd@apache.org>
Committed: Fri Jun 9 20:27:10 2017 +0000

----------------------------------------------------------------------
 build-support/lint.sh                                    |  2 +-
 src/kudu/client/client.cc                                |  6 ++++--
 src/kudu/client/scan_token-test.cc                       |  2 +-
 src/kudu/integration-tests/external_mini_cluster-test.cc |  2 +-
 src/kudu/master/catalog_manager.cc                       |  7 ++++---
 src/kudu/rpc/client_negotiation.cc                       |  2 --
 src/kudu/tablet/lock_manager-test.cc                     |  2 +-
 src/kudu/tablet/tablet_bootstrap-test.cc                 |  2 +-
 src/kudu/util/status-test.cc                             | 10 +++++-----
 9 files changed, 18 insertions(+), 17 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/kudu/blob/f1e75b72/build-support/lint.sh
----------------------------------------------------------------------
diff --git a/build-support/lint.sh b/build-support/lint.sh
index 61279bc..6cc2f74 100755
--- a/build-support/lint.sh
+++ b/build-support/lint.sh
@@ -51,7 +51,7 @@ cd $ROOT
 
 $ROOT/thirdparty/installed/common/bin/cpplint.py \
   --verbose=4 \
-  --filter=-whitespace/comments,-readability/todo,-readability/inheritance,-build/header_guard,-build/include_order,-legal/copyright,-build/c++11
\
+  --filter=-whitespace/comments,-readability/todo,-readability/inheritance,-build/header_guard,-build/include_order,-legal/copyright,-build/c++11,-readability/nolint
\
   $FILES 2>&1 | grep -v 'Done processing' | tee $TMP
 
 NUM_ERRORS=$(grep "Total errors found" $TMP | awk '{print $4}')

http://git-wip-us.apache.org/repos/asf/kudu/blob/f1e75b72/src/kudu/client/client.cc
----------------------------------------------------------------------
diff --git a/src/kudu/client/client.cc b/src/kudu/client/client.cc
index b1bf502..3006f2f 100644
--- a/src/kudu/client/client.cc
+++ b/src/kudu/client/client.cc
@@ -989,15 +989,17 @@ KuduTableAlterer* KuduTableAlterer::RenameTo(const string& new_name)
{
 KuduColumnSpec* KuduTableAlterer::AddColumn(const string& name) {
   Data::Step s = { AlterTableRequestPB::ADD_COLUMN,
                    new KuduColumnSpec(name), nullptr, nullptr };
+  auto* spec = s.spec;
   data_->steps_.emplace_back(std::move(s));
-  return s.spec;
+  return spec;
 }
 
 KuduColumnSpec* KuduTableAlterer::AlterColumn(const string& name) {
   Data::Step s = { AlterTableRequestPB::ALTER_COLUMN,
                    new KuduColumnSpec(name), nullptr, nullptr };
+  auto* spec = s.spec;
   data_->steps_.emplace_back(std::move(s));
-  return s.spec;
+  return spec;
 }
 
 KuduTableAlterer* KuduTableAlterer::DropColumn(const string& name) {

http://git-wip-us.apache.org/repos/asf/kudu/blob/f1e75b72/src/kudu/client/scan_token-test.cc
----------------------------------------------------------------------
diff --git a/src/kudu/client/scan_token-test.cc b/src/kudu/client/scan_token-test.cc
index 521b752..58b62ef 100644
--- a/src/kudu/client/scan_token-test.cc
+++ b/src/kudu/client/scan_token-test.cc
@@ -191,7 +191,7 @@ TEST_F(ScanTokenTest, TestScanTokens) {
     ASSERT_OK(builder.Build(&tokens));
 
     ASSERT_EQ(1, tokens.size());
-    ASSERT_EQ(1, CountRows(std::move(tokens)));
+    ASSERT_EQ(1, CountRows(tokens));
     NO_FATALS(VerifyTabletInfo(tokens));
   }
 

http://git-wip-us.apache.org/repos/asf/kudu/blob/f1e75b72/src/kudu/integration-tests/external_mini_cluster-test.cc
----------------------------------------------------------------------
diff --git a/src/kudu/integration-tests/external_mini_cluster-test.cc b/src/kudu/integration-tests/external_mini_cluster-test.cc
index fb8eaed..79b2a7f 100644
--- a/src/kudu/integration-tests/external_mini_cluster-test.cc
+++ b/src/kudu/integration-tests/external_mini_cluster-test.cc
@@ -112,7 +112,7 @@ TEST_P(ExternalMiniClusterTest, TestBasicOperation) {
   opts.num_masters = opts.master_rpc_ports.size();
   opts.num_tablet_servers = 3;
 
-  ExternalMiniCluster cluster(std::move(opts));
+  ExternalMiniCluster cluster(opts);
   ASSERT_OK(cluster.Start());
 
   // Verify each of the masters.

http://git-wip-us.apache.org/repos/asf/kudu/blob/f1e75b72/src/kudu/master/catalog_manager.cc
----------------------------------------------------------------------
diff --git a/src/kudu/master/catalog_manager.cc b/src/kudu/master/catalog_manager.cc
index df7935e..8e19553 100644
--- a/src/kudu/master/catalog_manager.cc
+++ b/src/kudu/master/catalog_manager.cc
@@ -351,12 +351,13 @@ class TskEntryLoader : public TskEntryVisitor {
     CHECK(tsk.has_expire_unix_epoch_seconds());
     CHECK(tsk.has_rsa_key_der());
 
-    // Expired entries are useful as well: they are needed for correct tracking
-    // of TSK sequence numbers.
-    entries_.emplace_back(std::move(tsk));
     if (tsk.expire_unix_epoch_seconds() <= entry_expiration_seconds_) {
       expired_entry_ids_.insert(entry_id);
     }
+
+    // Expired entries are useful as well: they are needed for correct tracking
+    // of TSK sequence numbers.
+    entries_.emplace_back(std::move(tsk));
     return Status::OK();
   }
 

http://git-wip-us.apache.org/repos/asf/kudu/blob/f1e75b72/src/kudu/rpc/client_negotiation.cc
----------------------------------------------------------------------
diff --git a/src/kudu/rpc/client_negotiation.cc b/src/kudu/rpc/client_negotiation.cc
index 8ce5190..2b6b083 100644
--- a/src/kudu/rpc/client_negotiation.cc
+++ b/src/kudu/rpc/client_negotiation.cc
@@ -481,8 +481,6 @@ Status ClientNegotiation::HandleTlsHandshake(const NegotiatePB& response)
{
   RETURN_NOT_OK(s);
 
   // TLS handshake is finished.
-  DCHECK(token.empty());
-
   if (ContainsKey(server_features_, TLS_AUTHENTICATION_ONLY) &&
       ContainsKey(client_features_, TLS_AUTHENTICATION_ONLY)) {
     TRACE("Negotiated auth-only $0 with cipher suite $1",

http://git-wip-us.apache.org/repos/asf/kudu/blob/f1e75b72/src/kudu/tablet/lock_manager-test.cc
----------------------------------------------------------------------
diff --git a/src/kudu/tablet/lock_manager-test.cc b/src/kudu/tablet/lock_manager-test.cc
index eccb67b..f599e2b 100644
--- a/src/kudu/tablet/lock_manager-test.cc
+++ b/src/kudu/tablet/lock_manager-test.cc
@@ -101,7 +101,7 @@ TEST_F(LockManagerTest, TestMoveLock) {
   // Move it to a new instance.
   ScopedRowLock moved_lock(std::move(row_lock));
   ASSERT_TRUE(moved_lock.acquired());
-  ASSERT_FALSE(row_lock.acquired());
+  ASSERT_FALSE(row_lock.acquired()); // NOLINT(misc-use-after-move)
 }
 
 class LmTestResource {

http://git-wip-us.apache.org/repos/asf/kudu/blob/f1e75b72/src/kudu/tablet/tablet_bootstrap-test.cc
----------------------------------------------------------------------
diff --git a/src/kudu/tablet/tablet_bootstrap-test.cc b/src/kudu/tablet/tablet_bootstrap-test.cc
index 0a0d5e9..4a3f735 100644
--- a/src/kudu/tablet/tablet_bootstrap-test.cc
+++ b/src/kudu/tablet/tablet_bootstrap-test.cc
@@ -589,7 +589,7 @@ TEST_F(BootstrapTest, TestConsensusOnlyOperationOutOfOrderTimestamp) {
   AppendCommit(std::move(mutate_commit));
 
   // ...and WRITE_OP...
-  mutate_commit.reset(new consensus::CommitMsg);
+  mutate_commit = gscoped_ptr<consensus::CommitMsg>(new consensus::CommitMsg);
   mutate_commit->set_op_type(consensus::WRITE_OP);
   *mutate_commit->mutable_commited_op_id() = write_replicate->get()->id();
   TxResultPB* result = mutate_commit->mutable_result();

http://git-wip-us.apache.org/repos/asf/kudu/blob/f1e75b72/src/kudu/util/status-test.cc
----------------------------------------------------------------------
diff --git a/src/kudu/util/status-test.cc b/src/kudu/util/status-test.cc
index ca33b89..d5aa130 100644
--- a/src/kudu/util/status-test.cc
+++ b/src/kudu/util/status-test.cc
@@ -50,7 +50,7 @@ TEST(StatusTest, TestMoveConstructor) {
   {
     Status src = Status::OK();
     Status dst = std::move(src);
-    ASSERT_OK(src);
+    ASSERT_OK(src); // NOLINT(misc-use-after-move)
     ASSERT_OK(dst);
   }
 
@@ -59,7 +59,7 @@ TEST(StatusTest, TestMoveConstructor) {
   {
     Status src = Status::NotFound("foo");
     Status dst = std::move(src);
-    ASSERT_OK(src);
+    ASSERT_OK(src); // NOLINT(misc-use-after-move)
     ASSERT_EQ("Not found: foo", dst.ToString());
   }
 }
@@ -71,7 +71,7 @@ TEST(StatusTest, TestMoveAssignment) {
     Status src = Status::OK();
     Status dst = Status::NotFound("orig dst");
     dst = std::move(src);
-    ASSERT_OK(src);
+    ASSERT_OK(src); // NOLINT(misc-use-after-move)
     ASSERT_OK(dst);
   }
 
@@ -80,7 +80,7 @@ TEST(StatusTest, TestMoveAssignment) {
     Status src = Status::NotFound("orig src");
     Status dst = Status::NotFound("orig dst");
     dst = std::move(src);
-    ASSERT_OK(src);
+    ASSERT_OK(src); // NOLINT(misc-use-after-move)
     ASSERT_EQ("Not found: orig src", dst.ToString());
   }
 
@@ -89,7 +89,7 @@ TEST(StatusTest, TestMoveAssignment) {
     Status src = Status::NotFound("orig src");
     Status dst = Status::OK();
     dst = std::move(src);
-    ASSERT_OK(src);
+    ASSERT_OK(src); // NOLINT(misc-use-after-move)
     ASSERT_EQ("Not found: orig src", dst.ToString());
   }
 }


Mime
View raw message