Skip to content

Conversation

maflcko
Copy link
Member

@maflcko maflcko commented Oct 1, 2021

All of the ParsePrechecks are already done by ToIntegral, so remove them from ParseIntegral.

Also:

Also:
* Remove redundant {} from return statement
* Add missing failing c-string test case and "-" and "+" strings
* Add missing failing test cases for non-int32_t integral types
@practicalswift
Copy link
Contributor

Concept ACK

@practicalswift
Copy link
Contributor

@MarcoFalke Nice cleanup! I think we can get rid of the entire ParsePrechecks function now since the only remaining caller ParseDouble is unused (last use of ParseDouble removed in 78c312c).

@practicalswift
Copy link
Contributor

practicalswift commented Oct 3, 2021

Note to reviewers: The string fuzzing harness (FUZZ=string src/test/fuzz/fuzz) can be used to try to test that ParseInt32 (and the other functions in that family) stays identical to the old behaviour (LegacyParseInt32) also after the removal of ParsePrechecks.

@maflcko maflcko changed the title refactor: Remove unused ParsePrechecks from ParseIntegral refactor: Remove unused ParsePrechecks and ParseDouble Oct 4, 2021
@maflcko
Copy link
Member Author

maflcko commented Oct 4, 2021

@practicalswift Good find. Removed as well.

Copy link
Contributor

@practicalswift practicalswift left a comment

Choose a reason for hiding this comment

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

cr ACK fa9d72a

@maflcko maflcko closed this Oct 4, 2021
@maflcko maflcko reopened this Oct 4, 2021
template <typename T>
static void RunToIntegralTests()
{
BOOST_CHECK(!ToIntegral<T>(STRING_WITH_EMBEDDED_NULL_CHAR));
Copy link
Member

Choose a reason for hiding this comment

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

I like this test line.

@laanwj
Copy link
Member

laanwj commented Oct 4, 2021

Code review ACK fa9d72a, good find on ParseDouble not being used at all, and testing for behavior of embedded NULL characters is always a good thing.

@maflcko maflcko merged commit 42fedb4 into bitcoin:master Oct 4, 2021
sidhujag pushed a commit to syscoin/syscoin that referenced this pull request Oct 4, 2021
…Double

fa9d72a Remove unused ParseDouble and ParsePrechecks (MarcoFalke)
fa3cd28 refactor: Remove unused ParsePrechecks from ParseIntegral (MarcoFalke)

Pull request description:

  All of the `ParsePrechecks` are already done by `ToIntegral`, so remove them from `ParseIntegral`.

  Also:
  * Remove redundant `{}`. See bitcoin#20457 (comment)
  * Add missing failing c-string test case
  * Add missing failing test cases for non-int32_t integral types

ACKs for top commit:
  laanwj:
    Code review ACK fa9d72a, good find on ParseDouble not being used at all, and testing for behavior of embedded NULL characters is always a good thing.
  practicalswift:
    cr ACK fa9d72a

Tree-SHA512: 3d654dcaebbf312dd57e54241f9aa6d35b1d1d213c37e4c6b8b9a69bcbe8267a397474a8b86b57740fbdd8e3d03b4cdb6a189a9eb8e05cd38035dab195410aa7
@maflcko maflcko deleted the 2110-refactorParseInt branch October 4, 2021 16:13
@bitcoin bitcoin locked and limited conversation to collaborators Oct 30, 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.

4 participants