Skip to content

Conversation

hebasto
Copy link
Member

@hebasto hebasto commented Nov 29, 2018

Refactoring:

  • all cases of using (uint32_t) -1 in COutPoint class are replaced with const;
  • also all remaining instances of (UNSIGNED)-1 transformed to std::numeric_limits<UNSIGNED>::max() (by @practicalswift).

@practicalswift
Copy link
Contributor

practicalswift commented Nov 29, 2018

Concept ACK modulo review comment

@hebasto hebasto force-pushed the 20181129-const-null-outpoint branch from 95e2c1a to 6a53717 Compare November 29, 2018 09:53
@hebasto
Copy link
Member Author

hebasto commented Nov 29, 2018

@practicalswift Thank you for your review. Your comment has been addressed.

@practicalswift
Copy link
Contributor

utACK 6a537172cb96efbbaa6cdd8d31d4938dab4b648d

@Empact
Copy link
Contributor

Empact commented Nov 30, 2018

nit: Maybe call it NULL_INDEX, as n is short for index, and the value is already scoped to COutPoint.

@hebasto hebasto force-pushed the 20181129-const-null-outpoint branch from 6a53717 to 6b82fc5 Compare November 30, 2018 10:54
@hebasto
Copy link
Member Author

hebasto commented Nov 30, 2018

@Empact Thank you for your review. Your comment has been addressed.

@promag
Copy link
Contributor

promag commented Dec 3, 2018

utACK 6b82fc5.

@practicalswift
Copy link
Contributor

utACK 6b82fc5

@maflcko
Copy link
Member

maflcko commented Dec 3, 2018

utACK 6b82fc5

@Empact
Copy link
Contributor

Empact commented Dec 4, 2018

utACK 6b82fc5

@practicalswift
Copy link
Contributor

practicalswift commented Dec 4, 2018

@hebasto Consider cherry-picking in 35c6ba8 which transforms all remaining instances of (UNSIGNED)-1 to std::numeric_limits<UNSIGNED>::max().

@hebasto
Copy link
Member Author

hebasto commented Dec 4, 2018

@practicalswift

Consider cherry-picking in 35c6ba8 which transforms all remaining instances of (UNSIGNED)-1 to std::numeric_limits<UNSIGNED>::max().

I don't how to point my local git to 35c6ba8c64de02069bc82dbcc790193f05332f78 commit (cannot see related PR). Would you mind showing me how to do this?

Btw, what's your nick on IRC (to get in touch)?

@practicalswift
Copy link
Contributor

practicalswift commented Dec 4, 2018

@hebasto The easiest way to do it is probably:

curl https://github.com/bitcoin/bitcoin/commit/35c6ba8c64de02069bc82dbcc790193f05332f78.patch \
    | git am

@hebasto
Copy link
Member Author

hebasto commented Dec 4, 2018

@practicalswift

Consider cherry-picking in 35c6ba8 which transforms all remaining instances of (UNSIGNED)-1 to std::numeric_limits<UNSIGNED>::max().

Done.

@practicalswift
Copy link
Contributor

utACK cf4b032

@Empact
Copy link
Contributor

Empact commented Dec 4, 2018

I would drop the latter commit. The PR stands alone and has 4 acks as-was. Introducing the latter commit broadens the scope unnecessarily.

E.g. the latter commit is not comprehensive, and has no mechanism to ensure ongoing enforcement (compiler warning).

@practicalswift
Copy link
Contributor

@Empact The latter commit is meant to be comprehensive: did you find any counterexample?

@Empact
Copy link
Contributor

Empact commented Dec 5, 2018

Ironically I found an example that was not addressed by the second commit but had already been by the first, so no I don’t know of one.

@promag
Copy link
Contributor

promag commented Dec 5, 2018

utACK cf4b032, no harm in being more comprehensive.

@@ -21,7 +21,9 @@ class COutPoint
uint256 hash;
uint32_t n;

COutPoint(): n((uint32_t) -1) { }
static constexpr uint32_t NULL_INDEX = std::numeric_limits<uint32_t>::max();
Copy link
Contributor

Choose a reason for hiding this comment

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

Should add #include <limits> to this file

@@ -200,7 +200,7 @@ BOOST_AUTO_TEST_CASE(varints)
}

for (uint64_t i = 0; i < 100000000000ULL; i += 999999937) {
uint64_t j = -1;
uint64_t j = std::numeric_limits<uint64_t>::max();
Copy link
Contributor

Choose a reason for hiding this comment

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

Should add #include <limits> to this file

@@ -105,7 +105,7 @@ void static RandomTransaction(CMutableTransaction &tx, bool fSingle) {
txin.prevout.hash = InsecureRand256();
txin.prevout.n = InsecureRandBits(2);
RandomScript(txin.scriptSig);
txin.nSequence = (InsecureRandBool()) ? InsecureRand32() : (unsigned int)-1;
txin.nSequence = (InsecureRandBool()) ? InsecureRand32() : std::numeric_limits<uint32_t>::max();
Copy link
Contributor

Choose a reason for hiding this comment

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

Should add #include <limits> to this file

@Empact
Copy link
Contributor

Empact commented Dec 6, 2018

Fair enough! Though on second look I noticed some missing includes, as noted.

@laanwj
Copy link
Member

laanwj commented Dec 6, 2018

utACK cf4b032

@laanwj laanwj merged commit cf4b032 into bitcoin:master Dec 6, 2018
laanwj added a commit that referenced this pull request Dec 6, 2018
cf4b032 Use std::numeric_limits<UNSIGNED>::max()) instead of (UNSIGNED)-1 (practicalswift)
6b82fc5 Use const in COutPoint class (Hennadii Stepanov)

Pull request description:

  Refactoring:
  - all cases of using `(uint32_t) -1` in `COutPoint` class are replaced with const;
  - also all remaining instances of `(UNSIGNED)-1` transformed to `std::numeric_limits<UNSIGNED>::max()` (by @practicalswift).

Tree-SHA512: fc7fe9838b6e5136d8b97ea3d6f64c4aaa1215f4369832df432cab017396620bb6e30520a64180ceab6de222562ac11eab243a78dfa5a658ba018835a34caa19
@hebasto hebasto deleted the 20181129-const-null-outpoint branch December 6, 2018 14:48
deadalnix pushed a commit to Bitcoin-ABC/bitcoin-abc that referenced this pull request Mar 12, 2020
Summary:
```
Refactoring:

    all cases of using (uint32_t) -1 in COutPoint class are replaced
with const;
    also all remaining instances of (UNSIGNED)-1 transformed to
std::numeric_limits<UNSIGNED>::max() (by @practicalswift).

```

Backport of core [[bitcoin/bitcoin#14838 | PR14838]].

Test Plan:
  ninja check

Reviewers: #bitcoin_abc, deadalnix

Reviewed By: #bitcoin_abc, deadalnix

Differential Revision: https://reviews.bitcoinabc.org/D5464
ftrader pushed a commit to bitcoin-cash-node/bitcoin-cash-node that referenced this pull request May 19, 2020
Summary:
```
Refactoring:

    all cases of using (uint32_t) -1 in COutPoint class are replaced
with const;
    also all remaining instances of (UNSIGNED)-1 transformed to
std::numeric_limits<UNSIGNED>::max() (by @practicalswift).

```

Backport of core [[bitcoin/bitcoin#14838 | PR14838]].

Test Plan:
  ninja check

Reviewers: #bitcoin_abc, deadalnix

Reviewed By: #bitcoin_abc, deadalnix

Differential Revision: https://reviews.bitcoinabc.org/D5464
PastaPastaPasta pushed a commit to PastaPastaPasta/dash that referenced this pull request Jun 27, 2021
cf4b032 Use std::numeric_limits<UNSIGNED>::max()) instead of (UNSIGNED)-1 (practicalswift)
6b82fc5 Use const in COutPoint class (Hennadii Stepanov)

Pull request description:

  Refactoring:
  - all cases of using `(uint32_t) -1` in `COutPoint` class are replaced with const;
  - also all remaining instances of `(UNSIGNED)-1` transformed to `std::numeric_limits<UNSIGNED>::max()` (by @practicalswift).

Tree-SHA512: fc7fe9838b6e5136d8b97ea3d6f64c4aaa1215f4369832df432cab017396620bb6e30520a64180ceab6de222562ac11eab243a78dfa5a658ba018835a34caa19
PastaPastaPasta pushed a commit to PastaPastaPasta/dash that referenced this pull request Jun 28, 2021
cf4b032 Use std::numeric_limits<UNSIGNED>::max()) instead of (UNSIGNED)-1 (practicalswift)
6b82fc5 Use const in COutPoint class (Hennadii Stepanov)

Pull request description:

  Refactoring:
  - all cases of using `(uint32_t) -1` in `COutPoint` class are replaced with const;
  - also all remaining instances of `(UNSIGNED)-1` transformed to `std::numeric_limits<UNSIGNED>::max()` (by @practicalswift).

Tree-SHA512: fc7fe9838b6e5136d8b97ea3d6f64c4aaa1215f4369832df432cab017396620bb6e30520a64180ceab6de222562ac11eab243a78dfa5a658ba018835a34caa19
PastaPastaPasta pushed a commit to PastaPastaPasta/dash that referenced this pull request Jun 29, 2021
cf4b032 Use std::numeric_limits<UNSIGNED>::max()) instead of (UNSIGNED)-1 (practicalswift)
6b82fc5 Use const in COutPoint class (Hennadii Stepanov)

Pull request description:

  Refactoring:
  - all cases of using `(uint32_t) -1` in `COutPoint` class are replaced with const;
  - also all remaining instances of `(UNSIGNED)-1` transformed to `std::numeric_limits<UNSIGNED>::max()` (by @practicalswift).

Tree-SHA512: fc7fe9838b6e5136d8b97ea3d6f64c4aaa1215f4369832df432cab017396620bb6e30520a64180ceab6de222562ac11eab243a78dfa5a658ba018835a34caa19
PastaPastaPasta pushed a commit to PastaPastaPasta/dash that referenced this pull request Jul 1, 2021
cf4b032 Use std::numeric_limits<UNSIGNED>::max()) instead of (UNSIGNED)-1 (practicalswift)
6b82fc5 Use const in COutPoint class (Hennadii Stepanov)

Pull request description:

  Refactoring:
  - all cases of using `(uint32_t) -1` in `COutPoint` class are replaced with const;
  - also all remaining instances of `(UNSIGNED)-1` transformed to `std::numeric_limits<UNSIGNED>::max()` (by @practicalswift).

Tree-SHA512: fc7fe9838b6e5136d8b97ea3d6f64c4aaa1215f4369832df432cab017396620bb6e30520a64180ceab6de222562ac11eab243a78dfa5a658ba018835a34caa19
PastaPastaPasta pushed a commit to PastaPastaPasta/dash that referenced this pull request Jul 1, 2021
cf4b032 Use std::numeric_limits<UNSIGNED>::max()) instead of (UNSIGNED)-1 (practicalswift)
6b82fc5 Use const in COutPoint class (Hennadii Stepanov)

Pull request description:

  Refactoring:
  - all cases of using `(uint32_t) -1` in `COutPoint` class are replaced with const;
  - also all remaining instances of `(UNSIGNED)-1` transformed to `std::numeric_limits<UNSIGNED>::max()` (by @practicalswift).

Tree-SHA512: fc7fe9838b6e5136d8b97ea3d6f64c4aaa1215f4369832df432cab017396620bb6e30520a64180ceab6de222562ac11eab243a78dfa5a658ba018835a34caa19
PastaPastaPasta pushed a commit to PastaPastaPasta/dash that referenced this pull request Jul 1, 2021
cf4b032 Use std::numeric_limits<UNSIGNED>::max()) instead of (UNSIGNED)-1 (practicalswift)
6b82fc5 Use const in COutPoint class (Hennadii Stepanov)

Pull request description:

  Refactoring:
  - all cases of using `(uint32_t) -1` in `COutPoint` class are replaced with const;
  - also all remaining instances of `(UNSIGNED)-1` transformed to `std::numeric_limits<UNSIGNED>::max()` (by @practicalswift).

Tree-SHA512: fc7fe9838b6e5136d8b97ea3d6f64c4aaa1215f4369832df432cab017396620bb6e30520a64180ceab6de222562ac11eab243a78dfa5a658ba018835a34caa19
UdjinM6 pushed a commit to UdjinM6/dash that referenced this pull request Jul 5, 2021
cf4b032 Use std::numeric_limits<UNSIGNED>::max()) instead of (UNSIGNED)-1 (practicalswift)
6b82fc5 Use const in COutPoint class (Hennadii Stepanov)

Pull request description:

  Refactoring:
  - all cases of using `(uint32_t) -1` in `COutPoint` class are replaced with const;
  - also all remaining instances of `(UNSIGNED)-1` transformed to `std::numeric_limits<UNSIGNED>::max()` (by @practicalswift).

Tree-SHA512: fc7fe9838b6e5136d8b97ea3d6f64c4aaa1215f4369832df432cab017396620bb6e30520a64180ceab6de222562ac11eab243a78dfa5a658ba018835a34caa19
PastaPastaPasta pushed a commit to PastaPastaPasta/dash that referenced this pull request Jul 8, 2021
cf4b032 Use std::numeric_limits<UNSIGNED>::max()) instead of (UNSIGNED)-1 (practicalswift)
6b82fc5 Use const in COutPoint class (Hennadii Stepanov)

Pull request description:

  Refactoring:
  - all cases of using `(uint32_t) -1` in `COutPoint` class are replaced with const;
  - also all remaining instances of `(UNSIGNED)-1` transformed to `std::numeric_limits<UNSIGNED>::max()` (by @practicalswift).

Tree-SHA512: fc7fe9838b6e5136d8b97ea3d6f64c4aaa1215f4369832df432cab017396620bb6e30520a64180ceab6de222562ac11eab243a78dfa5a658ba018835a34caa19
gades pushed a commit to cosanta/cosanta-core that referenced this pull request Apr 23, 2022
cf4b032 Use std::numeric_limits<UNSIGNED>::max()) instead of (UNSIGNED)-1 (practicalswift)
6b82fc5 Use const in COutPoint class (Hennadii Stepanov)

Pull request description:

  Refactoring:
  - all cases of using `(uint32_t) -1` in `COutPoint` class are replaced with const;
  - also all remaining instances of `(UNSIGNED)-1` transformed to `std::numeric_limits<UNSIGNED>::max()` (by @practicalswift).

Tree-SHA512: fc7fe9838b6e5136d8b97ea3d6f64c4aaa1215f4369832df432cab017396620bb6e30520a64180ceab6de222562ac11eab243a78dfa5a658ba018835a34caa19
@bitcoin bitcoin locked as resolved and limited conversation to collaborators Aug 16, 2022
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

7 participants