Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

src: remove validation of unreachable code #32818

Closed

Conversation

juanarbol
Copy link
Member

Based on nodejs/help#2600 (comment)
the condition (amount < 0) won't be possible.

Checklist
  • make -j4 test (UNIX), or vcbuild test (Windows) passes
  • commit message follows commit guidelines

Based on nodejs/help#2600 (comment)
the condition (amount < 0) won't be possible.
@nodejs-github-bot nodejs-github-bot added c++ Issues and PRs that require attention from people who are familiar with C++. os Issues and PRs related to the os subsystem. labels Apr 13, 2020
@nodejs-github-bot
Copy link
Collaborator

nodejs-github-bot commented Apr 13, 2020

@addaleax addaleax added the author ready PRs that have at least one approval, no pending requests for changes, and a CI started. label Apr 13, 2020
@juanarbol
Copy link
Member Author

I think this needs a quick update, it should be unsigned int amount, instead of double amount, if I am right, I can write that little "fix"

@addaleax
Copy link
Member

@juanarbol The current code is correct – we want the returned value to be a JS number, which corresponds to double in C++. The assignment to double amount = ... does the conversion implicitly, which is fine for us (although you could add static_cast<double>(...) to make it more explicit).

If we did use unsigned int amount, the amount value would be truncated to the size of an unsigned int, which is typically 32 bits; but the value returned from libuv won’t usually fit into that range, so we’d actually get a wrong result in that case.

@juanarbol
Copy link
Member Author

I think it is ok now, thank you @addaleax !!!

@nodejs-github-bot
Copy link
Collaborator

nodejs-github-bot commented Apr 19, 2020

juanarbol added a commit that referenced this pull request Apr 19, 2020
Based on nodejs/help#2600 (comment)
the condition (amount < 0) won't be possible.

PR-URL: #32818
Reviewed-By: Anna Henningsen <[email protected]>
Reviewed-By: Yongsheng Zhang <[email protected]>
Reviewed-By: Zeyu Yang <[email protected]>
Reviewed-By: Shelley Vohr <[email protected]>
Reviewed-By: Ben Noordhuis <[email protected]>
Reviewed-By: Colin Ihrig <[email protected]>
Reviewed-By: James M Snell <[email protected]>
Reviewed-By: Gus Caplan <[email protected]>
@juanarbol
Copy link
Member Author

Landed in 250060a

@juanarbol juanarbol closed this Apr 19, 2020
BethGriggs pushed a commit that referenced this pull request Apr 27, 2020
Based on nodejs/help#2600 (comment)
the condition (amount < 0) won't be possible.

PR-URL: #32818
Reviewed-By: Anna Henningsen <[email protected]>
Reviewed-By: Yongsheng Zhang <[email protected]>
Reviewed-By: Zeyu Yang <[email protected]>
Reviewed-By: Shelley Vohr <[email protected]>
Reviewed-By: Ben Noordhuis <[email protected]>
Reviewed-By: Colin Ihrig <[email protected]>
Reviewed-By: James M Snell <[email protected]>
Reviewed-By: Gus Caplan <[email protected]>
@BethGriggs BethGriggs mentioned this pull request Apr 27, 2020
BridgeAR pushed a commit that referenced this pull request Apr 28, 2020
Based on nodejs/help#2600 (comment)
the condition (amount < 0) won't be possible.

PR-URL: #32818
Reviewed-By: Anna Henningsen <[email protected]>
Reviewed-By: Yongsheng Zhang <[email protected]>
Reviewed-By: Zeyu Yang <[email protected]>
Reviewed-By: Shelley Vohr <[email protected]>
Reviewed-By: Ben Noordhuis <[email protected]>
Reviewed-By: Colin Ihrig <[email protected]>
Reviewed-By: James M Snell <[email protected]>
Reviewed-By: Gus Caplan <[email protected]>
@BridgeAR BridgeAR mentioned this pull request Apr 28, 2020
targos pushed a commit that referenced this pull request Apr 30, 2020
Based on nodejs/help#2600 (comment)
the condition (amount < 0) won't be possible.

PR-URL: #32818
Reviewed-By: Anna Henningsen <[email protected]>
Reviewed-By: Yongsheng Zhang <[email protected]>
Reviewed-By: Zeyu Yang <[email protected]>
Reviewed-By: Shelley Vohr <[email protected]>
Reviewed-By: Ben Noordhuis <[email protected]>
Reviewed-By: Colin Ihrig <[email protected]>
Reviewed-By: James M Snell <[email protected]>
Reviewed-By: Gus Caplan <[email protected]>
@juanarbol juanarbol deleted the juanarbol/node_os-validation branch January 19, 2021 16:26
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
author ready PRs that have at least one approval, no pending requests for changes, and a CI started. c++ Issues and PRs that require attention from people who are familiar with C++. os Issues and PRs related to the os subsystem.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

10 participants