From 5384f0af6e1bbe6dd7e3ce347ecb290298c2d443 Mon Sep 17 00:00:00 2001 From: jsteemann Date: Wed, 24 Nov 2021 11:18:07 -0800 Subject: [PATCH] Fix compile warnings (#9199) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Summary: * added missing override specifiers for overriden methods this fixes compiler warnings emitted by g++ and clang++ when compile option `-Wsuggest-override` is turned on. * fix compile warning with -Wmaybe-uninitialized g++-11 warns about a _potentially_ uninitialized variable when using `-Wmaybe_uninitialized`: ``` env/env.cc: In member function ‘virtual rocksdb::Status rocksdb::Env::GetHostNameString(std::string*)’: env/env.cc:738:66: error: ‘hostname_buf’ may be used uninitialized [-Werror=maybe-uninitialized] 738 | Status s = GetHostName(hostname_buf.data(), hostname_buf.size()); | ^ In file included from /usr/include/c++/11/tuple:39, from /usr/include/c++/11/functional:54, from ./include/rocksdb/env.h:22, from env/env.cc:10: /usr/include/c++/11/array:176:7: note: by argument 1 of type ‘const std::array*’ to ‘constexpr std::array<_Tp, _Nm>::size_type std::array<_Tp, _Nm>::size() const [with _Tp = char; long unsigned int _Nm = 256]’ declared here 176 | size() const noexcept { return _Nm; } | ^~~~ env/env.cc:737:37: note: ‘hostname_buf’ declared here 737 | std::array hostname_buf; ``` Pull Request resolved: https://github.com/facebook/rocksdb/pull/9199 Reviewed By: jay-zhuang Differential Revision: D32630703 Pulled By: pdillinger fbshipit-source-id: 9ea3010b1105a582548e3c3c0db4475b201e4a10 --- env/env.cc | 2 +- include/rocksdb/compaction_filter.h | 2 +- include/rocksdb/comparator.h | 2 +- include/rocksdb/file_checksum.h | 2 +- include/rocksdb/memtablerep.h | 2 +- include/rocksdb/merge_operator.h | 2 +- include/rocksdb/secondary_cache.h | 2 +- include/rocksdb/slice_transform.h | 2 +- include/rocksdb/sst_partitioner.h | 2 +- include/rocksdb/system_clock.h | 2 +- include/rocksdb/table_properties.h | 2 +- include/rocksdb/wal_filter.h | 2 +- 12 files changed, 12 insertions(+), 12 deletions(-) diff --git a/env/env.cc b/env/env.cc index 0bf8e5edc..ac50874f3 100644 --- a/env/env.cc +++ b/env/env.cc @@ -734,7 +734,7 @@ Status Env::GetChildrenFileAttributes(const std::string& dir, } Status Env::GetHostNameString(std::string* result) { - std::array hostname_buf; + std::array hostname_buf{}; Status s = GetHostName(hostname_buf.data(), hostname_buf.size()); if (s.ok()) { hostname_buf[hostname_buf.size() - 1] = '\0'; diff --git a/include/rocksdb/compaction_filter.h b/include/rocksdb/compaction_filter.h index 3c334f4bf..bdf872fd5 100644 --- a/include/rocksdb/compaction_filter.h +++ b/include/rocksdb/compaction_filter.h @@ -248,7 +248,7 @@ class CompactionFilterFactory : public Customizable { const CompactionFilter::Context& context) = 0; // Returns a name that identifies this `CompactionFilter` factory. - virtual const char* Name() const = 0; + virtual const char* Name() const override = 0; }; } // namespace ROCKSDB_NAMESPACE diff --git a/include/rocksdb/comparator.h b/include/rocksdb/comparator.h index 6c73a026f..c8c720b2f 100644 --- a/include/rocksdb/comparator.h +++ b/include/rocksdb/comparator.h @@ -75,7 +75,7 @@ class Comparator : public Customizable { // // Names starting with "rocksdb." are reserved and should not be used // by any clients of this package. - virtual const char* Name() const = 0; + virtual const char* Name() const override = 0; // Advanced functions: these are used to reduce the space requirements // for internal data structures like index blocks. diff --git a/include/rocksdb/file_checksum.h b/include/rocksdb/file_checksum.h index 4881dcf38..e993690b4 100644 --- a/include/rocksdb/file_checksum.h +++ b/include/rocksdb/file_checksum.h @@ -85,7 +85,7 @@ class FileChecksumGenFactory : public Customizable { const FileChecksumGenContext& context) = 0; // Return the name of this FileChecksumGenFactory. - virtual const char* Name() const = 0; + virtual const char* Name() const override = 0; }; // FileChecksumList stores the checksum information of a list of files (e.g., diff --git a/include/rocksdb/memtablerep.h b/include/rocksdb/memtablerep.h index 952d5d41f..64ebaf966 100644 --- a/include/rocksdb/memtablerep.h +++ b/include/rocksdb/memtablerep.h @@ -311,7 +311,7 @@ class MemTableRepFactory : public Customizable { return CreateMemTableRep(key_cmp, allocator, slice_transform, logger); } - virtual const char* Name() const = 0; + virtual const char* Name() const override = 0; // Return true if the current MemTableRep supports concurrent inserts // Default: false diff --git a/include/rocksdb/merge_operator.h b/include/rocksdb/merge_operator.h index bd6e336a5..e1e88bbdf 100644 --- a/include/rocksdb/merge_operator.h +++ b/include/rocksdb/merge_operator.h @@ -205,7 +205,7 @@ class MergeOperator : public Customizable { // TODO: the name is currently not stored persistently and thus // no checking is enforced. Client is responsible for providing // consistent MergeOperator between DB opens. - virtual const char* Name() const = 0; + virtual const char* Name() const override = 0; // Determines whether the PartialMerge can be called with just a single // merge operand. diff --git a/include/rocksdb/secondary_cache.h b/include/rocksdb/secondary_cache.h index 2bfe863df..989c7d9b0 100644 --- a/include/rocksdb/secondary_cache.h +++ b/include/rocksdb/secondary_cache.h @@ -79,7 +79,7 @@ class SecondaryCache : public Customizable { // Wait for a collection of handles to become ready virtual void WaitAll(std::vector handles) = 0; - virtual std::string GetPrintableOptions() const = 0; + virtual std::string GetPrintableOptions() const override = 0; }; } // namespace ROCKSDB_NAMESPACE diff --git a/include/rocksdb/slice_transform.h b/include/rocksdb/slice_transform.h index 742060969..7369e2887 100644 --- a/include/rocksdb/slice_transform.h +++ b/include/rocksdb/slice_transform.h @@ -38,7 +38,7 @@ class SliceTransform : public Customizable { virtual ~SliceTransform(){}; // Return the name of this transformation. - virtual const char* Name() const = 0; + virtual const char* Name() const override = 0; static const char* Type() { return "SliceTransform"; } // Creates and configures a new SliceTransform from the input options and id. diff --git a/include/rocksdb/sst_partitioner.h b/include/rocksdb/sst_partitioner.h index dd719b43e..9765f61ec 100644 --- a/include/rocksdb/sst_partitioner.h +++ b/include/rocksdb/sst_partitioner.h @@ -93,7 +93,7 @@ class SstPartitionerFactory : public Customizable { const SstPartitioner::Context& context) const = 0; // Returns a name that identifies this partitioner factory. - virtual const char* Name() const = 0; + virtual const char* Name() const override = 0; }; /* diff --git a/include/rocksdb/system_clock.h b/include/rocksdb/system_clock.h index 456847a19..05d3a5ed8 100644 --- a/include/rocksdb/system_clock.h +++ b/include/rocksdb/system_clock.h @@ -34,7 +34,7 @@ class SystemClock : public Customizable { const std::string& value, std::shared_ptr* result); // The name of this system clock - virtual const char* Name() const = 0; + virtual const char* Name() const override = 0; // The name/nickname for the Default SystemClock. This name can be used // to determine if the clock is the default one. diff --git a/include/rocksdb/table_properties.h b/include/rocksdb/table_properties.h index b9ddc2a84..27eb612bf 100644 --- a/include/rocksdb/table_properties.h +++ b/include/rocksdb/table_properties.h @@ -162,7 +162,7 @@ class TablePropertiesCollectorFactory : public Customizable { TablePropertiesCollectorFactory::Context context) = 0; // The name of the properties collector can be used for debugging purpose. - virtual const char* Name() const = 0; + virtual const char* Name() const override = 0; // Can be overridden by sub-classes to return the Name, followed by // configuration info that will // be logged to the info log when the diff --git a/include/rocksdb/wal_filter.h b/include/rocksdb/wal_filter.h index 80ed2dfc5..3e66c39e4 100644 --- a/include/rocksdb/wal_filter.h +++ b/include/rocksdb/wal_filter.h @@ -105,7 +105,7 @@ class WalFilter : public Customizable { // Returns a name that identifies this WAL filter. // The name will be printed to LOG file on start up for diagnosis. - virtual const char* Name() const = 0; + virtual const char* Name() const override = 0; }; } // namespace ROCKSDB_NAMESPACE