From b5818f87f03a189098a240ceb38d9bca2efa5d93 Mon Sep 17 00:00:00 2001 From: Yanqin Jin Date: Wed, 1 Apr 2020 09:59:06 -0700 Subject: [PATCH] Fix clang analyze error (#6622) Summary: As title. https://github.com/facebook/rocksdb/issues/6612 caused clang analyze to fail with the error: ``` db/compaction/compaction_picker_fifo.cc:105:39: warning: Called C++ object pointer is null cf_name.c_str(), f->fd.GetNumber(), creation_time); ^~~~~~~~~~~~~~~~~ ./logging/logging.h:59:36: note: expanded from macro 'ROCKS_LOG_BUFFER' ##__VA_ARGS__) ^~~~~~~~~~~ 1 warning generated. ``` Test Plan (devserver): USE_CLANG=1 make analyze Pull Request resolved: https://github.com/facebook/rocksdb/pull/6622 Reviewed By: ltamasi Differential Revision: D20787407 Pulled By: riversand963 fbshipit-source-id: a5de4910cc1aa0d3481a73ec114578925bfd63f7 --- db/compaction/compaction_picker_fifo.cc | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/db/compaction/compaction_picker_fifo.cc b/db/compaction/compaction_picker_fifo.cc index 8272b7a7e..efe9c10cc 100644 --- a/db/compaction/compaction_picker_fifo.cc +++ b/db/compaction/compaction_picker_fifo.cc @@ -71,6 +71,7 @@ Compaction* FIFOCompactionPicker::PickTTLCompaction( if (current_time > mutable_cf_options.ttl) { for (auto ritr = level_files.rbegin(); ritr != level_files.rend(); ++ritr) { FileMetaData* f = *ritr; + assert(f); if (f->fd.table_reader && f->fd.table_reader->GetTableProperties()) { uint64_t creation_time = f->fd.table_reader->GetTableProperties()->creation_time; @@ -96,7 +97,8 @@ Compaction* FIFOCompactionPicker::PickTTLCompaction( for (const auto& f : inputs[0].files) { uint64_t creation_time = 0; - if (f && f->fd.table_reader && f->fd.table_reader->GetTableProperties()) { + assert(f); + if (f->fd.table_reader && f->fd.table_reader->GetTableProperties()) { creation_time = f->fd.table_reader->GetTableProperties()->creation_time; } ROCKS_LOG_BUFFER(log_buffer,