Fix compile warnings (#9199)

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<char, 256>*’ 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<char, kMaxHostNameLen> 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
main
jsteemann 3 years ago committed by Facebook GitHub Bot
parent ea3aa60dcc
commit 5384f0af6e
  1. 2
      env/env.cc
  2. 2
      include/rocksdb/compaction_filter.h
  3. 2
      include/rocksdb/comparator.h
  4. 2
      include/rocksdb/file_checksum.h
  5. 2
      include/rocksdb/memtablerep.h
  6. 2
      include/rocksdb/merge_operator.h
  7. 2
      include/rocksdb/secondary_cache.h
  8. 2
      include/rocksdb/slice_transform.h
  9. 2
      include/rocksdb/sst_partitioner.h
  10. 2
      include/rocksdb/system_clock.h
  11. 2
      include/rocksdb/table_properties.h
  12. 2
      include/rocksdb/wal_filter.h

2
env/env.cc vendored

@ -734,7 +734,7 @@ Status Env::GetChildrenFileAttributes(const std::string& dir,
} }
Status Env::GetHostNameString(std::string* result) { Status Env::GetHostNameString(std::string* result) {
std::array<char, kMaxHostNameLen> hostname_buf; std::array<char, kMaxHostNameLen> hostname_buf{};
Status s = GetHostName(hostname_buf.data(), hostname_buf.size()); Status s = GetHostName(hostname_buf.data(), hostname_buf.size());
if (s.ok()) { if (s.ok()) {
hostname_buf[hostname_buf.size() - 1] = '\0'; hostname_buf[hostname_buf.size() - 1] = '\0';

@ -248,7 +248,7 @@ class CompactionFilterFactory : public Customizable {
const CompactionFilter::Context& context) = 0; const CompactionFilter::Context& context) = 0;
// Returns a name that identifies this `CompactionFilter` factory. // Returns a name that identifies this `CompactionFilter` factory.
virtual const char* Name() const = 0; virtual const char* Name() const override = 0;
}; };
} // namespace ROCKSDB_NAMESPACE } // namespace ROCKSDB_NAMESPACE

@ -75,7 +75,7 @@ class Comparator : public Customizable {
// //
// Names starting with "rocksdb." are reserved and should not be used // Names starting with "rocksdb." are reserved and should not be used
// by any clients of this package. // 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 // Advanced functions: these are used to reduce the space requirements
// for internal data structures like index blocks. // for internal data structures like index blocks.

@ -85,7 +85,7 @@ class FileChecksumGenFactory : public Customizable {
const FileChecksumGenContext& context) = 0; const FileChecksumGenContext& context) = 0;
// Return the name of this FileChecksumGenFactory. // 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., // FileChecksumList stores the checksum information of a list of files (e.g.,

@ -311,7 +311,7 @@ class MemTableRepFactory : public Customizable {
return CreateMemTableRep(key_cmp, allocator, slice_transform, logger); 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 // Return true if the current MemTableRep supports concurrent inserts
// Default: false // Default: false

@ -205,7 +205,7 @@ class MergeOperator : public Customizable {
// TODO: the name is currently not stored persistently and thus // TODO: the name is currently not stored persistently and thus
// no checking is enforced. Client is responsible for providing // no checking is enforced. Client is responsible for providing
// consistent MergeOperator between DB opens. // 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 // Determines whether the PartialMerge can be called with just a single
// merge operand. // merge operand.

@ -79,7 +79,7 @@ class SecondaryCache : public Customizable {
// Wait for a collection of handles to become ready // Wait for a collection of handles to become ready
virtual void WaitAll(std::vector<SecondaryCacheResultHandle*> handles) = 0; virtual void WaitAll(std::vector<SecondaryCacheResultHandle*> handles) = 0;
virtual std::string GetPrintableOptions() const = 0; virtual std::string GetPrintableOptions() const override = 0;
}; };
} // namespace ROCKSDB_NAMESPACE } // namespace ROCKSDB_NAMESPACE

@ -38,7 +38,7 @@ class SliceTransform : public Customizable {
virtual ~SliceTransform(){}; virtual ~SliceTransform(){};
// Return the name of this transformation. // 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"; } static const char* Type() { return "SliceTransform"; }
// Creates and configures a new SliceTransform from the input options and id. // Creates and configures a new SliceTransform from the input options and id.

@ -93,7 +93,7 @@ class SstPartitionerFactory : public Customizable {
const SstPartitioner::Context& context) const = 0; const SstPartitioner::Context& context) const = 0;
// Returns a name that identifies this partitioner factory. // Returns a name that identifies this partitioner factory.
virtual const char* Name() const = 0; virtual const char* Name() const override = 0;
}; };
/* /*

@ -34,7 +34,7 @@ class SystemClock : public Customizable {
const std::string& value, const std::string& value,
std::shared_ptr<SystemClock>* result); std::shared_ptr<SystemClock>* result);
// The name of this system clock // 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 // The name/nickname for the Default SystemClock. This name can be used
// to determine if the clock is the default one. // to determine if the clock is the default one.

@ -162,7 +162,7 @@ class TablePropertiesCollectorFactory : public Customizable {
TablePropertiesCollectorFactory::Context context) = 0; TablePropertiesCollectorFactory::Context context) = 0;
// The name of the properties collector can be used for debugging purpose. // 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 // Can be overridden by sub-classes to return the Name, followed by
// configuration info that will // be logged to the info log when the // configuration info that will // be logged to the info log when the

@ -105,7 +105,7 @@ class WalFilter : public Customizable {
// Returns a name that identifies this WAL filter. // Returns a name that identifies this WAL filter.
// The name will be printed to LOG file on start up for diagnosis. // 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 } // namespace ROCKSDB_NAMESPACE

Loading…
Cancel
Save