scripted-diff: Use the C++11 keyword nullptr to denote the pointer literal instead of the macro NULL #10483

pull practicalswift wants to merge 1 commits into bitcoin:master from practicalswift:nullptr changing 104 files +563 −563
  1. practicalswift commented at 8:03 am on May 31, 2017: contributor

    Since C++11 the macro NULL may be:

    • an integer literal with value zero, or
    • a prvalue of type std::nullptr_t

    By using the C++11 keyword nullptr we are guaranteed a prvalue of type std::nullptr_t.

    For a more thorough discussion, see “A name for the null pointer: nullptr” (Sutter & Stroustrup), http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2007/n2431.pdf

    With this patch applied there are no NULL macro usages left in the repo:

    0$ git grep NULL -- "*.cpp" "*.h" | egrep -v '(/univalue/|/secp256k1/|/leveldb/|_NULL|NULLDUMMY|torcontrol.*NULL|NULL cert)' | wc -l
    10
    

    The road towards nullptr (C++11) is split into two PRs:

    • NULLnullptr is handled in PR #10483 (scripted, this PR)
    • 0nullptr is handled in PR #10645 (manual)
  2. fanquake added the label Refactoring on May 31, 2017
  3. jonasschnelli commented at 8:37 am on May 31, 2017: contributor
    Concept ACK
  4. dcousens approved
  5. dcousens commented at 8:53 am on May 31, 2017: contributor
    utACK
  6. laanwj commented at 8:27 am on June 1, 2017: member
    Concept ACK. I think we can all agree that this needs to be done at some point, though we’ll have to discuss when to do this with the least impact. This change probably means every single PR needs to be rebased.
  7. practicalswift force-pushed on Jun 4, 2017
  8. practicalswift commented at 4:53 pm on June 4, 2017: contributor
    Rebased!
  9. sipa commented at 6:20 pm on June 4, 2017: member

    Can you rewrite this as a series of scripted diffs (possibly mixed with a few manual commits to fix things up)? See #10189 #10193 #10502 #10321 for examples.

    As for timing, possibly immediately after the feature freeze?

  10. practicalswift force-pushed on Jun 8, 2017
  11. practicalswift force-pushed on Jun 8, 2017
  12. practicalswift force-pushed on Jun 8, 2017
  13. practicalswift force-pushed on Jun 8, 2017
  14. practicalswift force-pushed on Jun 8, 2017
  15. practicalswift force-pushed on Jun 8, 2017
  16. practicalswift force-pushed on Jun 8, 2017
  17. practicalswift force-pushed on Jun 8, 2017
  18. practicalswift force-pushed on Jun 8, 2017
  19. practicalswift force-pushed on Jun 8, 2017
  20. practicalswift commented at 2:29 pm on June 8, 2017: contributor
    @sipa Great idea! Now re-implemented as a scripted-diff. Looks good? :-)
  21. practicalswift renamed this:
    Use the C++11 keyword nullptr to denote the pointer literal instead of the macro NULL
    scripted-diff: Use the C++11 keyword nullptr to denote the pointer literal instead of the macro NULL
    on Jun 8, 2017
  22. sipa commented at 8:12 pm on June 8, 2017: member
    @practicalswift You can use sed -i 's/\<NULL\>/nullptr/g' for the main operation. \< and \> denote begin and end of word.
  23. practicalswift force-pushed on Jun 9, 2017
  24. practicalswift commented at 3:26 pm on June 9, 2017: contributor
    @sipa Good point! Now using s/\<NULL\>/nullptr/g. Looks good? :-)
  25. practicalswift force-pushed on Jun 11, 2017
  26. practicalswift force-pushed on Jun 11, 2017
  27. practicalswift commented at 1:53 pm on June 11, 2017: contributor
    Merge conflicts resolved!
  28. practicalswift commented at 9:23 am on June 13, 2017: contributor

    What is the correct protocol to follow w.r.t. rebasing a large scripted-diff PR such as this one?

    Should I rebase periodically myself to keep it mergeable, or should I wait until I’m asked to rebase prior to the suggested time for merge (@sipa suggested: “possibly immediately after the feature freeze”).

  29. MarcoFalke commented at 10:20 am on June 13, 2017: member
    @practicalswift It is sufficient to rebase only once. Please refer to #9961#issue-212976673 for the preliminary date of feature freeze.
  30. practicalswift commented at 10:36 am on June 13, 2017: contributor
    @MarcoFalke Great! Thanks for clarifying!
  31. theuni commented at 8:54 pm on June 13, 2017: member
    Concept ACK. It’d be helpful to compare before/after binaries.
  32. practicalswift force-pushed on Jun 14, 2017
  33. practicalswift force-pushed on Jun 18, 2017
  34. jtimon commented at 1:24 am on June 22, 2017: contributor

    utACK But after revieweing the code, the script seems to be more complicated than it needs to be, wouldn’t the following do the same?

    0sed -i 's/NULL/nullptr/g' ./src/*.h ./src/*.cpp ./src/*/*.h ./src/*/*.cpp ./src/*/*/*.h ./src/*/*/*.cpp ;
    
  35. practicalswift commented at 2:17 am on June 22, 2017: contributor

    @jtimon Unfortunately that command is a bit too broad which leads to the following problems:

    • It would match dependencies such as src/leveldb/, src/secp256k1/, src/univalue/, etc.
    • It would match unrelated constants such as TX_NULL_DATA, SCRIPT_VERIFY_NULLDUMMY, SCRIPT_VERIFY_NULLFAIL, bitcoinconsensus_SCRIPT_FLAGS_VERIFY_NULLDUMMY, SCRIPT_ERR_SIG_NULLDUMMY, SCRIPT_ERR_SIG_NULLFAIL, etc.
  36. practicalswift force-pushed on Jun 22, 2017
  37. jtimon commented at 9:04 pm on June 23, 2017: contributor

    What about ?

    0sed -i 's/ NULL/ nullptr/g' ./src/*.h ./src/*.cpp ./src/*/*.h ./src/*/*.cpp ./src/*/*/*.h ./src/*/*/*.cpp ;
    1sed -i 's/ nullptr/ NULL/g' ./src/leveldb/*.*  ./src/secp256k1/.*.*;
    

    Anyway, no big deal, probably not worth it to change it. I looked at the changes and they do what I expect.

  38. practicalswift commented at 7:30 am on June 26, 2017: contributor
    @jtimon Unfortunately that one is too broad – it will replace NULLDUMMY with nullptrDUMMY, etc. 's/\<NULL\>/nullptr/g' is the narrowest replacement I can think of :-)
  39. jtimon commented at 1:59 am on June 27, 2017: contributor
    No worries, what you have seems to work. Needs rebase.
  40. practicalswift force-pushed on Jun 27, 2017
  41. practicalswift commented at 5:17 am on June 27, 2017: contributor
    Rebased! :-)
  42. practicalswift force-pushed on Jun 28, 2017
  43. practicalswift force-pushed on Jul 2, 2017
  44. practicalswift force-pushed on Jul 15, 2017
  45. practicalswift commented at 1:00 pm on July 15, 2017: contributor
    Rebased!
  46. TheBlueMatt commented at 7:44 pm on July 16, 2017: member
    utACK 2f2ac6fc76c966b6174d9df647648d0573d2ac41. I read through the diff but not thoroughly, the script looks good :).
  47. practicalswift force-pushed on Jul 17, 2017
  48. practicalswift commented at 8:00 am on July 17, 2017: contributor
    Rebased! :-)
  49. jtimon commented at 1:23 am on July 18, 2017: contributor
    Fast scroll-down re-review ACK. Didn’t checked the rebase.
  50. practicalswift force-pushed on Jul 24, 2017
  51. laanwj added this to the milestone 0.15.0 on Jul 28, 2017
  52. practicalswift force-pushed on Aug 1, 2017
  53. practicalswift commented at 5:05 pm on August 1, 2017: contributor
    Rebased! :-)
  54. promag commented at 3:17 pm on August 6, 2017: member

    utACK 2f2ac6f.

    Nit, while rebasing, reword to something short, like scripted-diff: Replace NULL macro with C++11 nullptr keyword.

  55. sipa commented at 10:08 pm on August 6, 2017: member
    Let’s try to merge this right before branching off 0.15.
  56. scripted-diff: Use the C++11 keyword nullptr to denote the pointer literal instead of the macro NULL
    -BEGIN VERIFY SCRIPT-
    sed -i 's/\<NULL\>/nullptr/g' src/*.cpp src/*.h src/*/*.cpp src/*/*.h src/qt/*/*.cpp src/qt/*/*.h src/wallet/*/*.cpp src/wallet/*/*.h src/support/allocators/*.h
    sed -i 's/Prefer nullptr, otherwise SAFECOOKIE./Prefer NULL, otherwise SAFECOOKIE./g' src/torcontrol.cpp
    sed -i 's/tor: Using nullptr authentication/tor: Using NULL authentication/g' src/torcontrol.cpp
    sed -i 's/METHODS=nullptr/METHODS=NULL/g' src/test/torcontrol_tests.cpp src/torcontrol.cpp
    sed -i 's/nullptr certificates/NULL certificates/g' src/qt/paymentserver.cpp
    sed -i 's/"nullptr"/"NULL"/g' src/torcontrol.cpp src/test/torcontrol_tests.cpp
    -END VERIFY SCRIPT-
    90d4d89230
  57. practicalswift force-pushed on Aug 7, 2017
  58. practicalswift commented at 5:38 am on August 7, 2017: contributor
    Rebased! @sipa That’s great! When is that expected to happen? I’ll keep this PR rebased :-)
  59. practicalswift commented at 5:42 am on August 7, 2017: contributor
    What about merging the related PR #10645 (“Use nullptr (C++11) instead of zero (0) as the null pointer constant “) at the same time? :-)
  60. MarcoFalke commented at 1:03 pm on August 8, 2017: member
    90d4d89 conflicts with #10882, which is tagged for 0.15.
  61. practicalswift commented at 1:42 pm on August 8, 2017: contributor
    @MarcoFalke Thanks for the notification! Should I wait until #10882 is merged and then rebase on master or what is the preferred way to handle it?
  62. laanwj merged this on Aug 14, 2017
  63. laanwj closed this on Aug 14, 2017

  64. laanwj referenced this in commit ce74799a3c on Aug 14, 2017
  65. practicalswift commented at 2:35 pm on August 14, 2017: contributor
    @laanwj Excellent! Thanks for merging! :-)
  66. MarcoFalke referenced this in commit c484ec6c9b on Aug 16, 2017
  67. laanwj referenced this in commit 9e00a625b4 on Aug 18, 2017
  68. PastaPastaPasta referenced this in commit de069f4fcb on Aug 6, 2019
  69. PastaPastaPasta referenced this in commit ee259f280e on Aug 6, 2019
  70. PastaPastaPasta referenced this in commit cd7daa2daa on Aug 6, 2019
  71. PastaPastaPasta referenced this in commit 33e1687721 on Aug 7, 2019
  72. PastaPastaPasta referenced this in commit e96d9a7ac4 on Aug 8, 2019
  73. PastaPastaPasta referenced this in commit 1a0d52814e on Aug 12, 2019
  74. PastaPastaPasta referenced this in commit aa160709d0 on Sep 19, 2019
  75. PastaPastaPasta referenced this in commit 3eda56fff5 on Sep 19, 2019
  76. PastaPastaPasta referenced this in commit 51801c02f9 on Sep 23, 2019
  77. PastaPastaPasta referenced this in commit 91ac93c63f on Sep 23, 2019
  78. PastaPastaPasta referenced this in commit b041cb30d7 on Sep 24, 2019
  79. PastaPastaPasta referenced this in commit c2171001d5 on Sep 24, 2019
  80. PastaPastaPasta referenced this in commit 5c6bd04c1c on Nov 19, 2019
  81. PastaPastaPasta referenced this in commit 77523f121f on Nov 19, 2019
  82. PastaPastaPasta referenced this in commit b19a6a64ed on Nov 21, 2019
  83. PastaPastaPasta referenced this in commit 1d3f9a70b8 on Nov 21, 2019
  84. PastaPastaPasta referenced this in commit be02c92f72 on Dec 9, 2019
  85. PastaPastaPasta referenced this in commit 47a0b82324 on Dec 9, 2019
  86. PastaPastaPasta referenced this in commit 38bb8a8909 on Jan 1, 2020
  87. PastaPastaPasta referenced this in commit 1b943d67ea on Jan 1, 2020
  88. PastaPastaPasta referenced this in commit 9d58c98753 on Jan 2, 2020
  89. PastaPastaPasta referenced this in commit a5ee45e8f7 on Jan 2, 2020
  90. PastaPastaPasta referenced this in commit ab52753cc2 on Jan 2, 2020
  91. PastaPastaPasta referenced this in commit 87a6d62f21 on Jan 2, 2020
  92. PastaPastaPasta referenced this in commit d737b59d45 on Jan 2, 2020
  93. PastaPastaPasta referenced this in commit 6984c98882 on Jan 3, 2020
  94. barrystyle referenced this in commit 6266cf059f on Jan 22, 2020
  95. str4d referenced this in commit e591f94fcf on Jul 31, 2020
  96. zkbot referenced this in commit 5ef5d8d268 on Jul 31, 2020
  97. zkbot referenced this in commit 7d94064616 on Sep 29, 2020
  98. ckti referenced this in commit d7d0d4db21 on Mar 28, 2021
  99. ckti referenced this in commit eb7e61ccae on Mar 28, 2021
  100. practicalswift deleted the branch on Apr 10, 2021
  101. gades referenced this in commit e1ff51567c on Jun 24, 2021
  102. gades referenced this in commit 651b72418a on Jun 26, 2021
  103. gades referenced this in commit 4a3bc05874 on Jan 29, 2022
  104. gades referenced this in commit 4dd3ea416b on Feb 22, 2022
  105. DrahtBot locked this on Aug 18, 2022

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-07-05 22:12 UTC

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