diff --git a/Makefile b/Makefile index 0eaddfb85..5f2895356 100644 --- a/Makefile +++ b/Makefile @@ -421,6 +421,11 @@ default: all WARNING_FLAGS = -W -Wextra -Wall -Wsign-compare -Wshadow \ -Wunused-parameter +ifdef USE_CLANG + # Used by some teams in Facebook + WARNING_FLAGS += -Wshift-sign-overflow +endif + ifeq ($(PLATFORM), OS_OPENBSD) WARNING_FLAGS += -Wno-unused-lambda-capture endif diff --git a/db/write_batch_test.cc b/db/write_batch_test.cc index 84f9a45ec..007fb66db 100644 --- a/db/write_batch_test.cc +++ b/db/write_batch_test.cc @@ -419,7 +419,7 @@ TEST_F(WriteBatchTest, PrepareCommit) { TEST_F(WriteBatchTest, DISABLED_ManyUpdates) { // Insert key and value of 3GB and push total batch size to 12GB. static const size_t kKeyValueSize = 4u; - static const uint32_t kNumUpdates = uint32_t(3 << 30); + static const uint32_t kNumUpdates = uint32_t{3} << 30; std::string raw(kKeyValueSize, 'A'); WriteBatch batch(kNumUpdates * (4 + kKeyValueSize * 2) + 1024u); char c = 'A'; diff --git a/include/rocksdb/utilities/backupable_db.h b/include/rocksdb/utilities/backupable_db.h index e9277e07a..36f29edbb 100644 --- a/include/rocksdb/utilities/backupable_db.h +++ b/include/rocksdb/utilities/backupable_db.h @@ -129,7 +129,7 @@ struct BackupableDBOptions { // table file names when the table files are stored in the shared_checksum // directory (i.e., both share_table_files and share_files_with_checksum // are true). - enum ShareFilesNaming : int { + enum ShareFilesNaming : uint32_t { // Backup SST filenames are __.sst // where is an unsigned decimal integer. This is the // original/legacy naming scheme for share_files_with_checksum, @@ -140,7 +140,7 @@ struct BackupableDBOptions { // so generally requires reading the whole file even if the file // is already backed up. // ** ONLY RECOMMENDED FOR PRESERVING OLD BEHAVIOR ** - kLegacyCrc32cAndFileSize = 1, + kLegacyCrc32cAndFileSize = 1U, // Backup SST filenames are _s.sst. This // pair of values should be very strongly unique for a given SST file @@ -152,9 +152,9 @@ struct BackupableDBOptions { // will be used instead, matching the names assigned by RocksDB versions // not supporting the newer naming scheme. // * See also flags below. - kUseDbSessionId = 2, + kUseDbSessionId = 2U, - kMaskNoNamingFlags = 0xffff, + kMaskNoNamingFlags = 0xffffU, // If not already part of the naming scheme, insert // _ @@ -165,7 +165,7 @@ struct BackupableDBOptions { // // We do not consider SST file sizes to have sufficient entropy to // contribute significantly to naming uniqueness. - kFlagIncludeFileSize = 1 << 31, + kFlagIncludeFileSize = 1U << 31, // When encountering an SST file from a Facebook-internal early // release of 6.12, use the default naming scheme in effect for @@ -175,7 +175,7 @@ struct BackupableDBOptions { // and ignores kFlagIncludeFileSize setting. // NOTE: This flag is intended to be temporary and should be removed // in a later release. - kFlagMatchInterimNaming = 1 << 30, + kFlagMatchInterimNaming = 1U << 30, kMaskNamingFlags = ~kMaskNoNamingFlags, }; @@ -234,8 +234,8 @@ struct BackupableDBOptions { inline BackupableDBOptions::ShareFilesNaming operator&( BackupableDBOptions::ShareFilesNaming lhs, BackupableDBOptions::ShareFilesNaming rhs) { - int l = static_cast(lhs); - int r = static_cast(rhs); + uint32_t l = static_cast(lhs); + uint32_t r = static_cast(rhs); assert(r == BackupableDBOptions::kMaskNoNamingFlags || (r & BackupableDBOptions::kMaskNoNamingFlags) == 0); return static_cast(l & r); @@ -244,8 +244,8 @@ inline BackupableDBOptions::ShareFilesNaming operator&( inline BackupableDBOptions::ShareFilesNaming operator|( BackupableDBOptions::ShareFilesNaming lhs, BackupableDBOptions::ShareFilesNaming rhs) { - int l = static_cast(lhs); - int r = static_cast(rhs); + uint32_t l = static_cast(lhs); + uint32_t r = static_cast(rhs); assert((r & BackupableDBOptions::kMaskNoNamingFlags) == 0); return static_cast(l | r); }