Fix two bugs in talbe format
Summary: Previous code had two bugs: * didn't initialize the table_magic_number_ explicitly -- as a result a random junk number is stored for table_magic_number_, making HasInitializedMagicNumber() always return true. * if condition is inconrrect in set_table_magic_number(), and the return value is not checked. I replace if-else by a stronger requirement enforced by assert(). Test Plan: Previous sst_dump failed to work. After the fix, things back to normal. Reviewers: yhchiang CC: haobo, sdong, igor, dhruba, leveldb Differential Revision: https://reviews.facebook.net/D17055
This commit is contained in:
parent
e493f2f54e
commit
69f6cf431d
@ -112,14 +112,10 @@ class Footer {
|
||||
static const uint64_t kInvalidTableMagicNumber = 0;
|
||||
|
||||
private:
|
||||
// Set the table_magic_number only when it was not previously
|
||||
// initialized. Return true on success.
|
||||
bool set_table_magic_number(uint64_t magic_number) {
|
||||
if (HasInitializedTableMagicNumber()) {
|
||||
// REQUIRES: magic number wasn't initialized.
|
||||
void set_table_magic_number(uint64_t magic_number) {
|
||||
assert(!HasInitializedTableMagicNumber());
|
||||
table_magic_number_ = magic_number;
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
// return true if @table_magic_number_ is set to a value different
|
||||
@ -130,7 +126,7 @@ class Footer {
|
||||
|
||||
BlockHandle metaindex_handle_;
|
||||
BlockHandle index_handle_;
|
||||
uint64_t table_magic_number_;
|
||||
uint64_t table_magic_number_ = 0;
|
||||
};
|
||||
|
||||
// Read the footer from file
|
||||
|
Loading…
Reference in New Issue
Block a user