Skip to content

wallet: don't include bdb files from our headers - #28039

Merged
achow101 merged 7 commits into
bitcoin:masterfrom
theuni:bdb-no-include-from-headers
Jul 7, 2023
Merged

achow101 merged 7 commits into
bitcoin:masterfrom
theuni:bdb-no-include-from-headers

Conversation

@theuni

@theuni theuni commented Jul 6, 2023

Copy link
Copy Markdown
Member

Only #include upstream bdb headers from our cpp files.

It's generally good practice to avoid including 3rd party deps in headers as otherwise they tend to sneak into new compilation units. IMO this makes for a nice cleanup.

There's a good bit of code movement here, but each commit is small and should be obviously correct.

Note: in the future, the buildsystem can add the bdb include path for bdb.cpp and salvage.cpp only, rather than all wallet sources.

@DrahtBot

DrahtBot commented Jul 6, 2023 •

Copy link
Copy Markdown
Contributor

The following sections might be updated with supplementary metadata relevant to reviewers and maintainers.

Reviews

See the guideline for information on the review process.

Type Reviewers
ACK hebasto, achow101

If your review is incorrectly listed, please react with 👎 to this comment and the bot will ignore it on the next update.

@theuni
theuni force-pushed the bdb-no-include-from-headers branch from fe5b4b6 to 2d09d0f Compare July 6, 2023 20:17
@achow101

achow101 commented Jul 6, 2023

Copy link
Copy Markdown
Member

ACK 2d09d0f50408f9c522b9efa4f386072502c7b3d1

Changes are primarily moves and appear otherwise obviously correct.

@maflcko maflcko left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

lgtm

Comment thread src/wallet/bdb.cpp Resolved
fanquake added a commit that referenced this pull request Jul 7, 2023
…ders

bea9fc2 wallet: sqlite: force sqlite3.h to be included by the cpp files (Cory Fields)

Pull request description:

  Only `#include` upstream sqlite headers from our cpp files.

  Like #28039 but simpler :)

ACKs for top commit:
  achow101:
    ACK bea9fc2
  TheCharlatan:
    Nice, ACK bea9fc2
  kristapsk:
    utACK bea9fc2
  hebasto:
    ACK bea9fc2, I have reviewed the code and it looks OK.

Tree-SHA512: cb83ac51eed7e0740f1c75ee87c7849fa7e535bc4836c499290041eb995ccfd82533e3babfe83a164257b62b180f206112d6a1bae7ea290ad0ec7f55d62432da

@hebasto hebasto left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Approach ACK 2d09d0f50408f9c522b9efa4f386072502c7b3d1.

Suggesting to adjust our IWYU mapping file:

--- a/contrib/devtools/iwyu/bitcoin.core.imp
+++ b/contrib/devtools/iwyu/bitcoin.core.imp
@@ -4,4 +4,7 @@
   { include: [ "<bits/termios-struct.h>", private, "<termios.h>", public ] },
   { include: [ "<bits/termios-tcflow.h>", private, "<termios.h>", public ] },
   { include: [ "<bits/chrono.h>", private, "<chrono>", public ] },
+
+  # Berkeley DB
+  { include: [ "<db.h>", private, "<db_cxx.h>", public ] },
 ]

or #include <db.h> explicitly along with #include <db_cxx.h>.

theuni added 5 commits July 7, 2023 14:14
No functional change, just simplifies the code move in the next commit.
Dbt requires including bdb headers.
Else some compilers/stdlibs may not be able to construct
std::unique_ptr<Db> without Db defined.
This way the dependency can't sneak into other files without being noticed.

Forward-declare bdb classes as necessary.
@theuni
theuni force-pushed the bdb-no-include-from-headers branch from 2d09d0f to 8b5397c Compare July 7, 2023 14:16

@hebasto hebasto left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

ACK 8b5397c

@DrahtBot
DrahtBot requested a review from achow101 July 7, 2023 14:19
@theuni

theuni commented Jul 7, 2023

Copy link
Copy Markdown
Member Author

@hebasto I'm ~0 on doing either/none of those changes. Happy to make a change if you or @achow101 or @MarcoFalke have a strong preference, otherwise I'll leave it as-is.

@achow101

achow101 commented Jul 7, 2023 •

Copy link
Copy Markdown
Member

reACK 8b5397c

No preference to make those changes.

@DrahtBot
DrahtBot removed the request for review from achow101 July 7, 2023 17:19
@achow101
achow101 merged commit 79e8247 into bitcoin:master Jul 7, 2023
@bitcoin bitcoin locked and limited conversation to collaborators Dec 5, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants