Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix coverity issues in include/rocksdb #3100

Closed
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
13 changes: 11 additions & 2 deletions include/rocksdb/metadata.h
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ struct SstFileMetaData;

// The metadata that describes a column family.
struct ColumnFamilyMetaData {
ColumnFamilyMetaData() : size(0), name("") {}
ColumnFamilyMetaData() : size(0), file_count(0), name("") {}
ColumnFamilyMetaData(const std::string& _name, uint64_t _size,
const std::vector<LevelMetaData>&& _levels) :
size(_size), name(_name), levels(_levels) {}
Expand Down Expand Up @@ -54,7 +54,16 @@ struct LevelMetaData {

// The metadata that describes a SST file.
struct SstFileMetaData {
SstFileMetaData() {}
SstFileMetaData()
: size(0),
name(""),
db_path(""),
smallest_seqno(0),
largest_seqno(0),
smallestkey(""),
largestkey(""),
num_reads_sampled(0),
being_compacted(false) {}
SstFileMetaData(const std::string& _file_name, const std::string& _path,
uint64_t _size, SequenceNumber _smallest_seqno,
SequenceNumber _largest_seqno,
Expand Down
10 changes: 9 additions & 1 deletion include/rocksdb/sst_file_writer.h
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,15 @@ class Comparator;
// ExternalSstFileInfo include information about sst files created
// using SstFileWriter.
struct ExternalSstFileInfo {
ExternalSstFileInfo() {}
ExternalSstFileInfo()
: file_path(""),
smallest_key(""),
largest_key(""),
sequence_number(0),
file_size(0),
num_entries(0),
version(0) {}

ExternalSstFileInfo(const std::string& _file_path,
const std::string& _smallest_key,
const std::string& _largest_key,
Expand Down
2 changes: 1 addition & 1 deletion include/rocksdb/utilities/transaction.h
Original file line number Diff line number Diff line change
Expand Up @@ -470,7 +470,7 @@ class Transaction {

protected:
explicit Transaction(const TransactionDB* db) {}
Transaction() {}
Transaction() : log_number_(0), txn_state_(STARTED) {}
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@ajkr @sagar0 Should I add another enum member TransactionState::FAILED to initialize txn_state_ to FAILED in default Transaction constructor. Though in RegisterTransaction we are checking transaction state is in TransactionState::STARTED.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@maysamyabandeh -- How would you like to initialize the txn_state_ here?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

STARTED is fine. This is always initialized to STARTED in the PessimisticTransaction constructor:

 56 void PessimisticTransaction::Initialize(const TransactionOptions& txn_options) {
 57   txn_id_ = GenTxnID();
 58
 59   txn_state_ = STARTED;


// the log in which the prepared section for this txn resides
// (for two phase commit)
Expand Down