Skip to content

Conversation

@dongcarl
Copy link
Contributor

Port numbers are 16-bit unsigned integers.

Port numbers are 16-bit unsigned integers.
@promag
Copy link
Contributor

promag commented Mar 12, 2019

Could also update call sites?

@maflcko
Copy link
Member

maflcko commented Mar 12, 2019

Unless you switch the constructors to use member initizlizer lists with the "{}-syntax" that checks for overflows, I don't see how this adds any value.

Also, #8394 (comment)

@laanwj
Copy link
Member

laanwj commented Mar 13, 2019

sorry, NACK, I don't see the point, this doesn't improve the code in any user-visible way

Copy link
Contributor

@ryanofsky ryanofsky left a comment

Choose a reason for hiding this comment

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

utACK 7c6b079. Code change itself looks good and is more clear and correct. Will happily defer to Marco/Wladimir on project management & prioritization, though, if this shouldn't be merged on those grounds.

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.

utACK 7c6b079 (agree with @ryanofsky)

@dongcarl
Copy link
Contributor Author

@MarcoFalke You mean use member initializer lists for CChainParams?

@dongcarl
Copy link
Contributor Author

dongcarl commented Mar 14, 2019

w/re the parsing comment #8394 (comment), would @laanwj and @MarcoFalke be more inclined to merge if this PR added relevant ArgsManager changes? This would be usable for both -port and -rpcport I believe.

@dongcarl
Copy link
Contributor Author

dongcarl commented Mar 14, 2019

Just for some context, this was motivated by my looking at GetListenPort(), which I believe casts signed ints to unsigned shorts. I think pairing this change with an ArgsManager change with good parsing would make it worthwhile.

Also related: #14856 (comment)

@maflcko
Copy link
Member

maflcko commented Mar 14, 2019

I believe it casts int64_t to unsigned short, but that should be fine as long as we check that the value is in range before the cast. No need to change the return type here.

@luke-jr
Copy link
Member

luke-jr commented Apr 17, 2019

This is just one of many cases where a 16-bit int type could cause problems, so I'm okay with fixing it for future portability. But I agree that if we do, we should fix the call sites too:

  • GetListenPort (in net.cpp)
  • CConnman::ConnectNode's default_port (in net.cpp)
  • Lookup's portDefault, port (in netbase.cpp)
    • SplitHostPort's portOut (in util/strencodings.cpp)
  • LookupNumeric's portDefault (in net.cpp)

@dongcarl
Copy link
Contributor Author

dongcarl commented May 15, 2019

I'll pick this back up someday. Feel free to grab it from me.

@fanquake
Copy link
Member

fanquake commented Mar 2, 2021

Removing up for grabs, as this is currently included in #21328.

@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.

8 participants