From a163cc2d5a89a572050640916a2512c0b9a44ee0 Mon Sep 17 00:00:00 2001 From: Islam AbdelRahman Date: Mon, 16 Nov 2015 12:56:21 -0800 Subject: [PATCH] Lint everything Summary: ``` arc2 lint --everything ``` run the linter on the whole code repo to fix exisitng lint issues Test Plan: make check -j64 Reviewers: sdong, rven, anthony, kradhakrishnan, yhchiang Reviewed By: yhchiang Subscribers: dhruba, leveldb Differential Revision: https://reviews.facebook.net/D50769 --- db/db_bench.cc | 6 +++--- db/listener_test.cc | 1 - doc/log_format.txt | 2 +- include/rocksdb/options.h | 4 ++-- include/rocksdb/table.h | 16 ++++++++-------- .../rocksdb/ColumnFamilyOptionsInterface.java | 2 +- .../java/org/rocksdb/DBOptionsInterface.java | 2 +- port/port.h | 1 - port/port_posix.h | 8 ++------ port/win/env_win.cc | 5 ++--- port/win/port_win.cc | 2 +- port/win/win_logger.cc | 15 +++++++++------ table/plain_table_factory.cc | 8 ++++---- table/plain_table_factory.h | 2 +- .../gtest-1.7.0/fused-src/gtest/gtest-all.cc | 2 +- util/env.cc | 4 ++-- util/options_helper.cc | 8 ++++---- util/options_test.cc | 9 +++++---- .../string_append/stringappend.cc | 3 --- .../merge_operators/string_append/stringappend.h | 4 ++-- .../string_append/stringappend2.cc | 1 - utilities/redis/redis_list_iterator.h | 7 +++---- 22 files changed, 52 insertions(+), 60 deletions(-) diff --git a/db/db_bench.cc b/db/db_bench.cc index fe54650b4..b30b07245 100644 --- a/db/db_bench.cc +++ b/db/db_bench.cc @@ -376,8 +376,8 @@ DEFINE_int32(compaction_readahead_size, 0, "Compaction readahead size"); DEFINE_int32(random_access_max_buffer_size, 1024 * 1024, "Maximum windows randomaccess buffer size"); -DEFINE_int32(writable_file_max_buffer_size, 1024 * 1024, - "Maximum write buffer for Writeable File"); +DEFINE_int32(writable_file_max_buffer_size, 1024 * 1024, + "Maximum write buffer for Writable File"); DEFINE_int32(skip_table_builder_flush, false, "Skip flushing block in " "table builder "); @@ -2448,7 +2448,7 @@ class Benchmark { block_based_options.block_size = FLAGS_block_size; block_based_options.block_restart_interval = FLAGS_block_restart_interval; block_based_options.filter_policy = filter_policy_; - block_based_options.skip_table_builder_flush = + block_based_options.skip_table_builder_flush = FLAGS_skip_table_builder_flush; block_based_options.format_version = 2; options.table_factory.reset( diff --git a/db/listener_test.cc b/db/listener_test.cc index 08fe096dc..ae911e7d1 100644 --- a/db/listener_test.cc +++ b/db/listener_test.cc @@ -533,4 +533,3 @@ int main(int argc, char** argv) { ::testing::InitGoogleTest(&argc, argv); return RUN_ALL_TESTS(); } - diff --git a/doc/log_format.txt b/doc/log_format.txt index 3a0414b65..5222d8113 100644 --- a/doc/log_format.txt +++ b/doc/log_format.txt @@ -11,7 +11,7 @@ Each block consists of a sequence of records: A record never starts within the last six bytes of a block (since it won't fit). Any leftover bytes here form the trailer, which must -consist entirely of zero bytes and must be skipped by readers. +consist entirely of zero bytes and must be skipped by readers. Aside: if exactly seven bytes are left in the current block, and a new non-zero length record is added, the writer must emit a FIRST record diff --git a/include/rocksdb/options.h b/include/rocksdb/options.h index f834a94ac..58121be58 100644 --- a/include/rocksdb/options.h +++ b/include/rocksdb/options.h @@ -1090,8 +1090,8 @@ struct DBOptions { size_t random_access_max_buffer_size; // This is the maximum buffer size that is used by WritableFileWriter. - // On Windows, we need to maintain an aligned buffer for writes. - // We allow the buffer to grow until it's size hits the limit. + // On Windows, we need to maintain an aligned buffer for writes. + // We allow the buffer to grow until it's size hits the limit. // // Default: 1024 * 1024 (1 MB) size_t writable_file_max_buffer_size; diff --git a/include/rocksdb/table.h b/include/rocksdb/table.h index 060c400e6..bbf293714 100644 --- a/include/rocksdb/table.h +++ b/include/rocksdb/table.h @@ -129,19 +129,19 @@ struct BlockBasedTableOptions { bool whole_key_filtering = true; // If true, block will not be explictly flushed to disk during building - // a SstTable. Instead, buffer in WritableFileWriter will take - // care of the flushing when it is full. + // a SstTable. Instead, buffer in WritableFileWriter will take + // care of the flushing when it is full. // - // On Windows, this option helps a lot when unbuffered I/O - // (allow_os_buffer = false) is used, since it avoids small - // unbuffered disk write. + // On Windows, this option helps a lot when unbuffered I/O + // (allow_os_buffer = false) is used, since it avoids small + // unbuffered disk write. // - // User may also adjust writable_file_max_buffer_size to optimize disk I/O - // size. + // User may also adjust writable_file_max_buffer_size to optimize disk I/O + // size. // // Default: false bool skip_table_builder_flush = false; - + // We currently have three versions: // 0 -- This version is currently written out by all RocksDB's versions by // default. Can be read by really old RocksDB's. Doesn't support changing diff --git a/java/src/main/java/org/rocksdb/ColumnFamilyOptionsInterface.java b/java/src/main/java/org/rocksdb/ColumnFamilyOptionsInterface.java index 1c7a5a110..dad75a242 100644 --- a/java/src/main/java/org/rocksdb/ColumnFamilyOptionsInterface.java +++ b/java/src/main/java/org/rocksdb/ColumnFamilyOptionsInterface.java @@ -231,7 +231,7 @@ public interface ColumnFamilyOptionsInterface { /** - * Same as fixed length prefix extractor, except that when slice is + * Same as fixed length prefix extractor, except that when slice is * shorter than the fixed length, it will use the full key. * * @param n use the first n bytes of a key as its prefix. diff --git a/java/src/main/java/org/rocksdb/DBOptionsInterface.java b/java/src/main/java/org/rocksdb/DBOptionsInterface.java index f710105a6..0c230e436 100644 --- a/java/src/main/java/org/rocksdb/DBOptionsInterface.java +++ b/java/src/main/java/org/rocksdb/DBOptionsInterface.java @@ -565,7 +565,7 @@ public interface DBOptionsInterface { * are older than WAL_ttl_seconds will be deleted. *
  • If both are not 0, WAL files will be checked every 10 min and both * checks will be performed with ttl being first.
  • - * + * * * @param sizeLimitMB size limit in mega-bytes. * @return the instance of the current Object. diff --git a/port/port.h b/port/port.h index e949cd286..670006e82 100644 --- a/port/port.h +++ b/port/port.h @@ -19,4 +19,3 @@ #elif defined(OS_WIN) #include "port/win/port_win.h" #endif - diff --git a/port/port_posix.h b/port/port_posix.h index efb72ee10..2debd62ea 100644 --- a/port/port_posix.h +++ b/port/port_posix.h @@ -32,14 +32,11 @@ #else #define PLATFORM_IS_LITTLE_ENDIAN false #endif -#elif defined(OS_FREEBSD) +#elif defined(OS_FREEBSD) || defined(OS_OPENBSD) || defined(OS_NETBSD) || \ + defined(OS_DRAGONFLYBSD) || defined(OS_ANDROID) #include #include #define PLATFORM_IS_LITTLE_ENDIAN (_BYTE_ORDER == _LITTLE_ENDIAN) -#elif defined(OS_OPENBSD) || defined(OS_NETBSD) ||\ - defined(OS_DRAGONFLYBSD) || defined(OS_ANDROID) - #include - #include #else #include #endif @@ -159,4 +156,3 @@ extern int GetMaxOpenFiles(); } // namespace port } // namespace rocksdb - diff --git a/port/win/env_win.cc b/port/win/env_win.cc index 9f81d9db2..90b04b552 100644 --- a/port/win/env_win.cc +++ b/port/win/env_win.cc @@ -610,7 +610,7 @@ class WinSequentialFile : public SequentialFile { HANDLE file_; // There is no equivalent of advising away buffered pages as in posix. - // To implement this flag we would need to do unbuffered reads which + // To implement this flag we would need to do unbuffered reads which // will need to be aligned (not sure there is a guarantee that the buffer // passed in is aligned). // Hence we currently ignore this flag. It is used only in a few cases @@ -970,8 +970,7 @@ class WinWritableFile : public WritableFile { virtual Status PositionedAppend(const Slice& data, uint64_t offset) override { Status s; - SSIZE_T ret = pwrite(hFile_, data.data(), - data.size(), offset); + SSIZE_T ret = pwrite(hFile_, data.data(), data.size(), offset); // Error break if (ret < 0) { diff --git a/port/win/port_win.cc b/port/win/port_win.cc index 42eff09a1..35f53d675 100644 --- a/port/win/port_win.cc +++ b/port/win/port_win.cc @@ -67,7 +67,7 @@ bool CondVar::TimedWait(uint64_t abs_time_us) { using namespace std::chrono; // MSVC++ library implements wait_until in terms of wait_for so - // we need to convert absoulte wait into relative wait. + // we need to convert absolute wait into relative wait. microseconds usAbsTime(abs_time_us); microseconds usNow( diff --git a/port/win/win_logger.cc b/port/win/win_logger.cc index e91930dff..20ef759e4 100644 --- a/port/win/win_logger.cc +++ b/port/win/win_logger.cc @@ -10,6 +10,8 @@ // Logger implementation that can be shared by all environments // where enough posix functionality is available. +#include "port/win/win_logger.h" + #include #include #include @@ -21,7 +23,6 @@ #include -#include "port/win/win_logger.h" #include "port/sys_time.h" #include "util/iostats_context_imp.h" @@ -53,8 +54,9 @@ void WinLogger::close() { CloseHandle(file_); } void WinLogger::Flush() { if (flush_pending_) { flush_pending_ = false; - // With Windows API writes go to OS buffers directly so no fflush needed unlike - // with C runtime API. We don't flush all the way to disk for perf reasons. + // With Windows API writes go to OS buffers directly so no fflush needed + // unlike with C runtime API. We don't flush all the way to disk + // for perf reasons. } last_flush_micros_ = env_->NowMicros(); @@ -124,7 +126,7 @@ void WinLogger::Logv(const char* format, va_list ap) { assert(p <= limit); const size_t write_size = p - base; - DWORD bytesWritten = 0; + DWORD bytesWritten = 0; BOOL ret = WriteFile(file_, base, write_size, &bytesWritten, NULL); if (ret == FALSE) { std::string errSz = GetWindowsErrSz(GetLastError()); @@ -141,8 +143,9 @@ void WinLogger::Logv(const char* format, va_list ap) { static_cast(now_tv.tv_sec) * 1000000 + now_tv.tv_usec; if (now_micros - last_flush_micros_ >= flush_every_seconds_ * 1000000) { flush_pending_ = false; - // With Windows API writes go to OS buffers directly so no fflush needed unlike - // with C runtime API. We don't flush all the way to disk for perf reasons. + // With Windows API writes go to OS buffers directly so no fflush needed + // unlike with C runtime API. We don't flush all the way to disk + // for perf reasons. last_flush_micros_ = now_micros; } break; diff --git a/table/plain_table_factory.cc b/table/plain_table_factory.cc index f5f3a7692..1ab3d3470 100644 --- a/table/plain_table_factory.cc +++ b/table/plain_table_factory.cc @@ -21,8 +21,8 @@ Status PlainTableFactory::NewTableReader( return PlainTableReader::Open( table_reader_options.ioptions, table_reader_options.env_options, table_reader_options.internal_comparator, std::move(file), file_size, - table, table_options_.bloom_bits_per_key, table_options_.hash_table_ratio, - table_options_.index_sparseness, table_options_.huge_page_tlb_size, + table, table_options_.bloom_bits_per_key, table_options_.hash_table_ratio, + table_options_.index_sparseness, table_options_.huge_page_tlb_size, table_options_.full_scan_mode); } @@ -36,8 +36,8 @@ TableBuilder* PlainTableFactory::NewTableBuilder( return new PlainTableBuilder( table_builder_options.ioptions, table_builder_options.int_tbl_prop_collector_factories, column_family_id, - file, table_options_.user_key_len, table_options_.encoding_type, - table_options_.index_sparseness, table_options_.bloom_bits_per_key, 6, + file, table_options_.user_key_len, table_options_.encoding_type, + table_options_.index_sparseness, table_options_.bloom_bits_per_key, 6, table_options_.huge_page_tlb_size, table_options_.hash_table_ratio, table_options_.store_index_in_file); } diff --git a/table/plain_table_factory.h b/table/plain_table_factory.h index 301b07a06..158af825a 100644 --- a/table/plain_table_factory.h +++ b/table/plain_table_factory.h @@ -151,7 +151,7 @@ class PlainTableFactory : public TableFactory { unique_ptr&& file, uint64_t file_size, unique_ptr* table) const override; - + TableBuilder* NewTableBuilder( const TableBuilderOptions& table_builder_options, uint32_t column_family_id, WritableFileWriter* file) const override; diff --git a/third-party/gtest-1.7.0/fused-src/gtest/gtest-all.cc b/third-party/gtest-1.7.0/fused-src/gtest/gtest-all.cc index 92c3a439b..bdb83d553 100644 --- a/third-party/gtest-1.7.0/fused-src/gtest/gtest-all.cc +++ b/third-party/gtest-1.7.0/fused-src/gtest/gtest-all.cc @@ -2592,7 +2592,7 @@ class Hunk { // Print a unified diff header for one hunk. // The format is // "@@ -, +, @@" - // where the left/right parts are ommitted if unnecessary. + // where the left/right parts are omitted if unnecessary. void PrintHeader(std::ostream* ss) const { *ss << "@@ "; if (removes_) { diff --git a/util/env.cc b/util/env.cc index 5042251a8..968d300b8 100644 --- a/util/env.cc +++ b/util/env.cc @@ -296,8 +296,8 @@ void AssignEnvOptions(EnvOptions* env_options, const DBOptions& options) { env_options->random_access_max_buffer_size = options.random_access_max_buffer_size; env_options->rate_limiter = options.rate_limiter.get(); - env_options->writable_file_max_buffer_size = - options.writable_file_max_buffer_size; + env_options->writable_file_max_buffer_size = + options.writable_file_max_buffer_size; env_options->allow_fallocate = options.allow_fallocate; } diff --git a/util/options_helper.cc b/util/options_helper.cc index 3c545e115..2957bd5d5 100644 --- a/util/options_helper.cc +++ b/util/options_helper.cc @@ -1153,7 +1153,7 @@ std::string ParsePlainTableOptions(const std::string& name, const std::string& org_value, PlainTableOptions* new_option, bool input_strings_escaped = false) { - const std::string& value = + const std::string& value = input_strings_escaped ? UnescapeOptionString(org_value) : org_value; const auto iter = plain_table_type_info.find(name); if (iter == plain_table_type_info.end()) { @@ -1239,7 +1239,7 @@ Status GetPlainTableOptionsFromString( if (!s.ok()) { return s; } - return GetPlainTableOptionsFromMap(table_options, opts_map, + return GetPlainTableOptionsFromMap(table_options, opts_map, new_table_options); } @@ -1384,8 +1384,8 @@ Status GetTableFactoryFromMap( return Status::OK(); } else if (factory_name == PlainTableFactory().Name()) { PlainTableOptions pt_opt; - s = GetPlainTableOptionsFromMap(PlainTableOptions(), opt_map, - &pt_opt, true); + s = GetPlainTableOptionsFromMap(PlainTableOptions(), opt_map, &pt_opt, + true); if (!s.ok()) { return s; } diff --git a/util/options_test.cc b/util/options_test.cc index d1d4ecd21..49d4851e2 100644 --- a/util/options_test.cc +++ b/util/options_test.cc @@ -535,10 +535,11 @@ TEST_F(OptionsTest, GetPlainTableOptionsFromString) { &new_opt)); // unrecognized EncodingType - ASSERT_NOK(GetPlainTableOptionsFromString(table_opt, - "user_key_len=66;bloom_bits_per_key=20;hash_table_ratio=0.5;" - "encoding_type=kPrefixXX", - &new_opt)); + ASSERT_NOK(GetPlainTableOptionsFromString( + table_opt, + "user_key_len=66;bloom_bits_per_key=20;hash_table_ratio=0.5;" + "encoding_type=kPrefixXX", + &new_opt)); } #endif // !ROCKSDB_LITE diff --git a/utilities/merge_operators/string_append/stringappend.cc b/utilities/merge_operators/string_append/stringappend.cc index 38cd22eb4..ff19348f0 100644 --- a/utilities/merge_operators/string_append/stringappend.cc +++ b/utilities/merge_operators/string_append/stringappend.cc @@ -55,6 +55,3 @@ std::shared_ptr MergeOperators::CreateStringAppendOperator() { } } // namespace rocksdb - - - diff --git a/utilities/merge_operators/string_append/stringappend.h b/utilities/merge_operators/string_append/stringappend.h index ca5b97ec9..621d15153 100644 --- a/utilities/merge_operators/string_append/stringappend.h +++ b/utilities/merge_operators/string_append/stringappend.h @@ -12,7 +12,8 @@ namespace rocksdb { class StringAppendOperator : public AssociativeMergeOperator { public: - StringAppendOperator(char delim_char); /// Constructor: specify delimiter + // Constructor: specify delimiter + explicit StringAppendOperator(char delim_char); virtual bool Merge(const Slice& key, const Slice* existing_value, @@ -28,4 +29,3 @@ class StringAppendOperator : public AssociativeMergeOperator { }; } // namespace rocksdb - diff --git a/utilities/merge_operators/string_append/stringappend2.cc b/utilities/merge_operators/string_append/stringappend2.cc index 1dd8262d0..cceb8d547 100644 --- a/utilities/merge_operators/string_append/stringappend2.cc +++ b/utilities/merge_operators/string_append/stringappend2.cc @@ -110,4 +110,3 @@ MergeOperators::CreateStringAppendTESTOperator() { } } // namespace rocksdb - diff --git a/utilities/redis/redis_list_iterator.h b/utilities/redis/redis_list_iterator.h index 6d0b1a6af..73907ddf8 100644 --- a/utilities/redis/redis_list_iterator.h +++ b/utilities/redis/redis_list_iterator.h @@ -37,8 +37,8 @@ * @author Deon Nicholas (dnicholas@fb.com) */ -#ifndef ROCKSDB_LITE #pragma once +#ifndef ROCKSDB_LITE #include @@ -65,7 +65,7 @@ class RedisListIterator { /// e) result_ will always contain data_[0..cur_byte_) and a header /// f) Whenever corrupt data is encountered or an invalid operation is /// attempted, a RedisListException will immediately be thrown. - RedisListIterator(const std::string& list_data) + explicit RedisListIterator(const std::string& list_data) : data_(list_data.data()), num_bytes_(static_cast(list_data.size())), cur_byte_(0), @@ -73,7 +73,6 @@ class RedisListIterator { cur_elem_length_(0), length_(0), result_() { - // Initialize the result_ (reserve enough space for header) InitializeResult(); @@ -269,7 +268,7 @@ class RedisListIterator { data_+cur_byte_+ sizeof(uint32_t) + cur_elem_length_); } - /// Will ThrowError() if neccessary. + /// Will ThrowError() if necessary. /// Checks for common/ubiquitous errors that can arise after most operations. /// This method should be called before any reading operation. /// If this function succeeds, then we are guaranteed to be in a valid state.