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: avoid strcmp in SecureContext::Init #34329

Closed

Conversation

tniessen
Copy link
Member

This change uses std::string::operator== instead of strcmp, and de-duplicates some code.

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

@nodejs-github-bot nodejs-github-bot added c++ Issues and PRs that require attention from people who are familiar with C++. crypto Issues and PRs related to the crypto subsystem. labels Jul 12, 2020
@yashLadha
Copy link
Contributor

Any particular reason to avoid using strcmp and use ==? Curious to know the underlying reason for the change.

Comment on lines 577 to 579
if (methodstr == "SSLv2_method" ||
methodstr == "SSLv2_server_method" ||
methodstr == "SSLv2_client_method") {
Copy link
Contributor

Choose a reason for hiding this comment

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

Nice 👍

@tniessen
Copy link
Member Author

Any particular reason to avoid using strcmp and use ==? Curious to know the underlying reason for the change.

In my opinion, operator== is simpler, has clearer semantics than strcmp(...) == 0, and makes the code easier to understand. A dozen branches containing strcmp(...) == 0 also kind of violate the DRY concept.

src/node_crypto.cc Outdated Show resolved Hide resolved
Copy link
Member

@bnoordhuis bnoordhuis left a comment

Choose a reason for hiding this comment

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

👍

@nodejs-github-bot
Copy link
Collaborator

@tniessen tniessen added the author ready PRs that have at least one approval, no pending requests for changes, and a CI started. label Jul 17, 2020
@nodejs-github-bot
Copy link
Collaborator

tniessen added a commit to tniessen/node that referenced this pull request Jul 19, 2020
PR-URL: nodejs#34329
Reviewed-By: Ben Noordhuis <[email protected]>
Reviewed-By: James M Snell <[email protected]>
@tniessen
Copy link
Member Author

Landed in efd1667, thank you for reviewing.

@tniessen tniessen closed this Jul 19, 2020
@tniessen tniessen removed the author ready PRs that have at least one approval, no pending requests for changes, and a CI started. label Jul 19, 2020
cjihrig pushed a commit that referenced this pull request Jul 23, 2020
PR-URL: #34329
Reviewed-By: Ben Noordhuis <[email protected]>
Reviewed-By: James M Snell <[email protected]>
MylesBorins pushed a commit that referenced this pull request Jul 27, 2020
PR-URL: #34329
Reviewed-By: Ben Noordhuis <[email protected]>
Reviewed-By: James M Snell <[email protected]>
@ruyadorno ruyadorno mentioned this pull request Jul 28, 2020
addaleax pushed a commit that referenced this pull request Sep 22, 2020
PR-URL: #34329
Reviewed-By: Ben Noordhuis <[email protected]>
Reviewed-By: James M Snell <[email protected]>
addaleax pushed a commit that referenced this pull request Sep 22, 2020
PR-URL: #34329
Reviewed-By: Ben Noordhuis <[email protected]>
Reviewed-By: James M Snell <[email protected]>
@codebytere codebytere mentioned this pull request Sep 28, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
c++ Issues and PRs that require attention from people who are familiar with C++. crypto Issues and PRs related to the crypto subsystem.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants