From eafb09a380bd2b1d807fdadc2606d534cd99fdbc Mon Sep 17 00:00:00 2001 From: Sagar Vemuri Date: Tue, 12 Feb 2019 13:55:40 -0800 Subject: [PATCH] Fix issues found by Clang Analyzer (#4976) Summary: Fix issues found by Clang Analyzer. Pull Request resolved: https://github.com/facebook/rocksdb/pull/4976 Differential Revision: D14054211 Pulled By: sagar0 fbshipit-source-id: ec2053bae43af3b2ff3425306824c677e3ba70c2 --- util/transaction_test_util.cc | 18 ++++++++++-------- 1 file changed, 10 insertions(+), 8 deletions(-) diff --git a/util/transaction_test_util.cc b/util/transaction_test_util.cc index 240295a81..6c1ad1553 100644 --- a/util/transaction_test_util.cc +++ b/util/transaction_test_util.cc @@ -185,12 +185,14 @@ bool RandomTransactionInserter::DoInsert(DB* db, Transaction* txn, } bytes_inserted_ += key.size() + sum.size(); } - ROCKS_LOG_DEBUG(db->GetDBOptions().info_log, - "Insert (%s) %s snap: %" PRIu64 " key:%s value: %" PRIu64 - "+%" PRIu64 "=%" PRIu64, - txn->GetName().c_str(), s.ToString().c_str(), - txn->GetSnapshot()->GetSequenceNumber(), full_key.c_str(), - int_value, incr, int_value + incr); + if (txn != nullptr) { + ROCKS_LOG_DEBUG(db->GetDBOptions().info_log, + "Insert (%s) %s snap: %" PRIu64 " key:%s value: %" PRIu64 + "+%" PRIu64 "=%" PRIu64, + txn->GetName().c_str(), s.ToString().c_str(), + txn->GetSnapshot()->GetSequenceNumber(), full_key.c_str(), + int_value, incr, int_value + incr); + } } if (s.ok()) { @@ -252,10 +254,10 @@ bool RandomTransactionInserter::DoInsert(DB* db, Transaction* txn, } } } else { - ROCKS_LOG_DEBUG(db->GetDBOptions().info_log, "Error %s for txn %s", - s.ToString().c_str(), txn->GetName().c_str()); if (txn != nullptr) { assert(txn->Rollback().ok()); + ROCKS_LOG_DEBUG(db->GetDBOptions().info_log, "Error %s for txn %s", + s.ToString().c_str(), txn->GetName().c_str()); } }