Skip to content

Conversation

hebasto
Copy link
Owner

@hebasto hebasto commented Feb 9, 2024

This PR split from #84

It introduces a new warn_leveldb_interface, which overrides -Wconditional-uninitialized and -Wsuggest-override if any.

For MSVC builds, dropped warning suppressions that are provided at the global level.

For example, on the staging branch:

$ env CC=clang CXX=clang++ CXXFLAGS="-Wconditional-uninitialized -Wsuggest-override" cmake -B build
$ cmake --build build --target leveldb > /dev/null 
/home/hebasto/git/bitcoin/src/leveldb/db/c.cc:474:17: warning: 'Name' overrides a member function but is not marked 'override' [-Wsuggest-override]
    const char* Name() const { return rep_->Name(); }
                ^
/home/hebasto/git/bitcoin/src/leveldb/db/c.cc:110:15: note: overridden virtual function is here
  const char* Name() const override { return (*name_)(state_); }
              ^
/home/hebasto/git/bitcoin/src/leveldb/db/c.cc:475:10: warning: 'CreateFilter' overrides a member function but is not marked 'override' [-Wsuggest-override]
    void CreateFilter(const Slice* keys, int n, std::string* dst) const {
         ^
/home/hebasto/git/bitcoin/src/leveldb/db/c.cc:112:8: note: overridden virtual function is here
  void CreateFilter(const Slice* keys, int n, std::string* dst) const override {
       ^
/home/hebasto/git/bitcoin/src/leveldb/db/c.cc:478:10: warning: 'KeyMayMatch' overrides a member function but is not marked 'override' [-Wsuggest-override]
    bool KeyMayMatch(const Slice& key, const Slice& filter) const {
         ^
/home/hebasto/git/bitcoin/src/leveldb/db/c.cc:125:8: note: overridden virtual function is here
  bool KeyMayMatch(const Slice& key, const Slice& filter) const override {
       ^
3 warnings generated.
/home/hebasto/git/bitcoin/src/leveldb/db/version_set.cc:1016:55: warning: variable 'manifest_size' may be uninitialized when used here [-Wconditional-uninitialized]
  descriptor_log_ = new log::Writer(descriptor_file_, manifest_size);
                                                      ^~~~~~~~~~~~~
/home/hebasto/git/bitcoin/src/leveldb/db/version_set.cc:997:25: note: initialize the variable 'manifest_size' to silence this warning
  uint64_t manifest_size;
                        ^
                         = 0
1 warning generated.

@hebasto
Copy link
Owner Author

hebasto commented Feb 9, 2024

@hebasto hebasto added the enhancement New feature or request label Feb 10, 2024
@theuni
Copy link

theuni commented Feb 12, 2024

Concept ACK. I think "nowarn_leveldb_interface" would make this more intuitive though.

This change introduces a new `warn_leveldb_interface`, which overrides
`-Wconditional-uninitialized` and `-Wsuggest-override` if any.

For MSVC builds, dropped warning suppressions that are provided at the
global level.
@hebasto
Copy link
Owner Author

hebasto commented Feb 12, 2024

I think "nowarn_leveldb_interface" would make this more intuitive though.

Thanks! Renamed.

Copy link

@vasild vasild left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ACK 33dee19

/wd4244
/wd4267
$<$<CONFIG:Release>:/wd4722>
target_compile_options(nowarn_leveldb_interface INTERFACE
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why are these no longer private?

Copy link
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Only INTERFACE_* properties might be populated for interface libraries.

The nowarn_leveldb_interface library itself is linked in the PRIVATE scope though.

Copy link
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Otherwise, CMake raises an error:

CMake Error at cmake/leveldb.cmake:86 (target_compile_options):
  target_compile_options may only set INTERFACE properties on INTERFACE
  targets
Call Stack (most recent call first):
  CMakeLists.txt:260 (include)

Copy link

@theuni theuni left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ACK 33dee19

@hebasto hebasto merged commit 2082e3d into cmake-staging Feb 15, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants