From e8480d4d9d1e1afa1ccca38f077724368bead0c8 Mon Sep 17 00:00:00 2001 From: Zhongyi Xie Date: Tue, 2 Apr 2019 21:13:01 -0700 Subject: [PATCH] add assert to silence clang analyzer and fix variable shadowing (#5140) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Summary: This PR address two open issues: 1. clang analyzer is paranoid about db_ being nullptr after DB::Open calls in the test. See https://github.com/facebook/rocksdb/pull/5043#discussion_r271394579 Add an assert to keep clang happy 2. PR https://github.com/facebook/rocksdb/pull/5049 introduced a variable shadowing: ``` db/db_iterator_test.cc: In constructor ‘rocksdb::DBIteratorWithReadCallbackTest_ReadCallback_Test::TestBody()::TestReadCallback::TestReadCallback(rocksdb::SequenceNumber)’: db/db_iterator_test.cc:2484:9: error: declaration of ‘max_visible_seq’ shadows a member of 'this' [-Werror=shadow] : ReadCallback(max_visible_seq) {} ^ ``` Pull Request resolved: https://github.com/facebook/rocksdb/pull/5140 Differential Revision: D14735497 Pulled By: miasantreble fbshipit-source-id: 3219ea75cf4ae04f64d889323f6779e84be98144 --- db/db_iterator_test.cc | 4 ++-- db/deletefile_test.cc | 4 +++- 2 files changed, 5 insertions(+), 3 deletions(-) diff --git a/db/db_iterator_test.cc b/db/db_iterator_test.cc index 8eee3c0ce..210b0d733 100644 --- a/db/db_iterator_test.cc +++ b/db/db_iterator_test.cc @@ -2480,8 +2480,8 @@ class DBIteratorWithReadCallbackTest : public DBIteratorTest {}; TEST_F(DBIteratorWithReadCallbackTest, ReadCallback) { class TestReadCallback : public ReadCallback { public: - explicit TestReadCallback(SequenceNumber max_visible_seq) - : ReadCallback(max_visible_seq) {} + explicit TestReadCallback(SequenceNumber _max_visible_seq) + : ReadCallback(_max_visible_seq) {} bool IsVisibleFullCheck(SequenceNumber seq) override { return seq <= max_visible_seq_; diff --git a/db/deletefile_test.cc b/db/deletefile_test.cc index 0905c90cc..3ae464c58 100644 --- a/db/deletefile_test.cc +++ b/db/deletefile_test.cc @@ -71,7 +71,9 @@ class DeleteFileTest : public testing::Test { } db_ = nullptr; options_.create_if_missing = create; - return DB::Open(options_, dbname_, &db_); + Status s = DB::Open(options_, dbname_, &db_); + assert(db_); + return s; } void CloseDB() {