Qt: Replace remaining 0 with nullptr #15114

pull Empact wants to merge 2 commits into bitcoin:master from Empact:qt-zero-as-null-pointer-constant changing 61 files +123 −125
  1. Empact commented at 10:34 am on January 6, 2019: member

    This corrects all violations of -Wzero-as-null-pointer-constant identified in the Qt codebase.

    These changes are extracted from #15112 as suggested by @MarcoFalke to ease review. This is in service of enabling -Wzero-as-null-pointer-constant, which should eliminate this as a concern going forward.

    Note there are 2 non-Qt changes: src/test/allocator_tests.cpp and src/wallet/db.cpp.

  2. Empact force-pushed on Jan 6, 2019
  3. MarcoFalke added the label GUI on Jan 6, 2019
  4. MarcoFalke added the label Refactoring on Jan 6, 2019
  5. in src/wallet/db.cpp:341 in 60a2a0b242 outdated
    337@@ -338,7 +338,7 @@ bool BerkeleyBatch::VerifyEnvironment(const fs::path& file_path, std::string& er
    338     BerkeleyEnvironment* env = GetWalletEnv(file_path, walletFile);
    339     fs::path walletDir = env->Directory();
    340 
    341-    LogPrintf("Using BerkeleyDB version %s\n", DbEnv::version(0, 0, 0));
    342+    LogPrintf("Using BerkeleyDB version %s\n", DbEnv::version(nullptr, nullptr, nullptr));
    


  6. hebasto commented at 10:49 am on January 6, 2019: member
    Concept ACK.
  7. in src/qt/addresstablemodel.cpp:303 in 60a2a0b242 outdated
    299@@ -300,8 +300,8 @@ QVariant AddressTableModel::headerData(int section, Qt::Orientation orientation,
    300 
    301 Qt::ItemFlags AddressTableModel::flags(const QModelIndex &index) const
    302 {
    303-    if(!index.isValid())
    304-        return 0;
    305+    if (!index.isValid()) return Qt::NoItemFlags;
    


    Empact commented at 11:12 am on January 6, 2019:
  8. in src/qt/utilitydialog.h:48 in 60a2a0b242 outdated
    44@@ -45,7 +45,7 @@ class ShutdownWindow : public QWidget
    45     Q_OBJECT
    46 
    47 public:
    48-    explicit ShutdownWindow(QWidget *parent=0, Qt::WindowFlags f=0);
    49+    explicit ShutdownWindow(QWidget *parent=nullptr, Qt::WindowFlags f=Qt::Widget);
    


    Empact commented at 11:17 am on January 6, 2019:
  9. luke-jr commented at 11:34 am on January 6, 2019: member
    Rationale? Changing code style stuff for no reason isn’t useful…
  10. practicalswift commented at 3:56 pm on January 6, 2019: contributor
    Concept ACK
  11. practicalswift commented at 4:00 pm on January 6, 2019: contributor

    @luke-jr The change @Empact is suggesting is not a code style change.

    Reasons to use nullptr include:

    • nullptr has a well-specified (very restrictive) type, and thus works in more scenarios where type deduction might do the wrong thing on NULL or 0.
    • Improves readability.
    • Minimises surprises: nullptr cannot be confused with an int.

    Enabling -Wzero-as-null-pointer-constant will help developers follow our developer guide which is a good thing. This in turn means that human reviewers will not have to point out the benefits of nullptr ever again :-)

  12. practicalswift commented at 4:05 pm on January 6, 2019: contributor
    utACK 60a2a0b24275757dee767deafadd86d24889bdf8
  13. hebasto commented at 5:22 pm on January 6, 2019: member
    utACK 60a2a0b24275757dee767deafadd86d24889bdf8. nit: could clang-format-diff.py be applied?
  14. promag commented at 5:50 pm on January 6, 2019: member

    Concept ACK, agree it improves code.

    I don’t think this should be merged without something to prevent more zero-as-null-pointer.

  15. practicalswift commented at 5:56 pm on January 6, 2019: contributor
    @promag That is taken care of in #15112, right? :-)
  16. laanwj commented at 2:33 pm on January 7, 2019: member

    I don’t think this should be merged without something to prevent more zero-as-null-pointer.

    I agree, as discussed many times, we don’t want PR after PR fixing ‘straggler’ occurrences. It’s not that important that it warrants some kind of crusade.

    But if #15112 enables failing the build on this I’m okay with that and they should probably be merged together.

  17. DrahtBot commented at 10:49 pm on January 9, 2019: member

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

    Conflicts

    Reviewers, this pull request conflicts with the following ones:

    • #15157 (rpc: Bumpfee units change, satoshis to BTC by benthecarman)
    • #15153 (gui: Add Open Wallet menu by promag)
    • #15101 (gui: Add WalletController by promag)
    • #15040 (qt: Add workaround for QProgressDialog bug on macOS by hebasto)
    • #13880 (gui: Try shutdown also on failure by MarcoFalke)
    • #12096 ([rpc] [wallet] Allow specifying the output index when using bumpfee by kallewoof)

    If you consider this pull request important, please also help to review the conflicting pull requests. Ideally, start with the one that should be merged first.

  18. DrahtBot added the label Needs rebase on Jan 12, 2019
  19. Don't use zero as null pointer constant (-Wzero-as-null-pointer-constant)
    Qt-only changes.
    9096276e0b
  20. Replace remaining 0 with nullptr in Qt code
    Also used type-appropriate enum values such as Qt::NoItemFlags in
    some cases.
    
    All cases identified via -Wzero-as-null-pointer-constant
    3a0e76fc12
  21. Empact force-pushed on Jan 13, 2019
  22. Empact commented at 5:11 pm on January 13, 2019: member
    Rebased for #13216
  23. DrahtBot removed the label Needs rebase on Jan 13, 2019
  24. practicalswift commented at 8:37 am on January 14, 2019: contributor
    utACK 3a0e76fc12b91b2846d756981e15f09b767a9c37
  25. laanwj commented at 2:21 pm on January 14, 2019: member
    utACK 3a0e76fc12b91b2846d756981e15f09b767a9c37
  26. benthecarman referenced this in commit 76335298f4 on Jan 14, 2019
  27. laanwj merged this on Jan 14, 2019
  28. laanwj closed this on Jan 14, 2019

  29. deadalnix referenced this in commit d70c6bbf14 on Feb 27, 2020
  30. ftrader referenced this in commit 23d63d62fd on Apr 16, 2020
  31. Munkybooty referenced this in commit 9c8420a241 on Aug 21, 2021
  32. Munkybooty referenced this in commit d4669e1898 on Aug 23, 2021
  33. Munkybooty referenced this in commit 8f57bae102 on Aug 24, 2021
  34. Munkybooty referenced this in commit 41291f2c18 on Aug 24, 2021
  35. Munkybooty referenced this in commit eed7c1f4d4 on Aug 24, 2021
  36. UdjinM6 referenced this in commit 485cf5ac70 on Aug 24, 2021
  37. Munkybooty referenced this in commit f239861eba on Aug 24, 2021
  38. DrahtBot locked this on Dec 16, 2021

github-metadata-mirror

This is a metadata mirror of the GitHub repository bitcoin/bitcoin. This site is not affiliated with GitHub. Content is generated from a GitHub metadata backup.
generated: 2024-11-17 09:12 UTC

This site is hosted by @0xB10C
More mirrored repositories can be found on mirror.b10c.me