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: fix coverity coverity warning #50846

Merged
merged 1 commit into from
Nov 24, 2023
Merged

Conversation

mhdawson
Copy link
Member

  • reduce copying by using std::move

@nodejs-github-bot nodejs-github-bot added c++ Issues and PRs that require attention from people who are familiar with C++. needs-ci PRs that need a full CI run. vm Issues and PRs related to the vm subsystem. labels Nov 21, 2023
@mhdawson
Copy link
Member Author

mhdawson commented Nov 21, 2023

Coverity warning

 std::vector<Local<String>> params = {
1464      String::NewFromUtf8(isolate, "exports").ToLocalChecked(),
1465      String::NewFromUtf8(isolate, "require").ToLocalChecked(),
1466      String::NewFromUtf8(isolate, "module").ToLocalChecked(),
1467      String::NewFromUtf8(isolate, "__filename").ToLocalChecked(),
1468      String::NewFromUtf8(isolate, "__dirname").ToLocalChecked()};
1469
1470  TryCatchScope try_catch(env);
1471
1472  ContextifyContext::CompileFunctionAndCacheResult(env,
1473                                                   context,
1474                                                   &source,
    	
CID 329955 (#1 of 1): COPY_INSTEAD_OF_MOVE (COPY_INSTEAD_OF_MOVE)
1. copy_constructor_call: params is passed-by-value as parameter to CompileFunctionAndCacheResult when it could be moved instead.
    	Use std::move(params) instead of params.
1475                                                   params,
1476                                                   std::vector<Local<Object>>(),
1477                                                   options,
1478                                                   true,
1479                                                   id_symbol,
1480                                                   try_catch);

I think the suggested std::move will avoid copying the contents of the vector.

@tniessen
Copy link
Member

Nit: duplicate word in commit message

- reduce copying by using std::move

Signed-off-by: Michael Dawson <[email protected]>
@mhdawson
Copy link
Member Author

mhdawson commented Nov 22, 2023

@tniessen thanks, fixed commit message.

@mhdawson mhdawson added the request-ci Add this label to start a Jenkins CI on a PR. label Nov 22, 2023
@github-actions github-actions bot removed the request-ci Add this label to start a Jenkins CI on a PR. label Nov 22, 2023
@nodejs-github-bot
Copy link
Collaborator

@nodejs-github-bot
Copy link
Collaborator

@nodejs-github-bot
Copy link
Collaborator

@lpinca lpinca added the commit-queue Add this label to land a pull request using GitHub Actions. label Nov 24, 2023
@nodejs-github-bot nodejs-github-bot removed the commit-queue Add this label to land a pull request using GitHub Actions. label Nov 24, 2023
@nodejs-github-bot nodejs-github-bot merged commit 6dbf678 into nodejs:main Nov 24, 2023
53 checks passed
@nodejs-github-bot
Copy link
Collaborator

Landed in 6dbf678

martenrichter pushed a commit to martenrichter/node that referenced this pull request Nov 26, 2023
- reduce copying by using std::move

Signed-off-by: Michael Dawson <[email protected]>
PR-URL: nodejs#50846
Reviewed-By: Tobias Nießen <[email protected]>
Reviewed-By: Marco Ippolito <[email protected]>
Reviewed-By: James M Snell <[email protected]>
Reviewed-By: Luigi Pinca <[email protected]>
lucshi pushed a commit to lucshi/node that referenced this pull request Nov 27, 2023
- reduce copying by using std::move

Signed-off-by: Michael Dawson <[email protected]>
PR-URL: nodejs#50846
Reviewed-By: Tobias Nießen <[email protected]>
Reviewed-By: Marco Ippolito <[email protected]>
Reviewed-By: James M Snell <[email protected]>
Reviewed-By: Luigi Pinca <[email protected]>
RafaelGSS pushed a commit that referenced this pull request Nov 27, 2023
- reduce copying by using std::move

Signed-off-by: Michael Dawson <[email protected]>
PR-URL: #50846
Reviewed-By: Tobias Nießen <[email protected]>
Reviewed-By: Marco Ippolito <[email protected]>
Reviewed-By: James M Snell <[email protected]>
Reviewed-By: Luigi Pinca <[email protected]>
@RafaelGSS RafaelGSS mentioned this pull request Nov 28, 2023
RafaelGSS pushed a commit that referenced this pull request Nov 29, 2023
- reduce copying by using std::move

Signed-off-by: Michael Dawson <[email protected]>
PR-URL: #50846
Reviewed-By: Tobias Nießen <[email protected]>
Reviewed-By: Marco Ippolito <[email protected]>
Reviewed-By: James M Snell <[email protected]>
Reviewed-By: Luigi Pinca <[email protected]>
RafaelGSS pushed a commit that referenced this pull request Nov 30, 2023
- reduce copying by using std::move

Signed-off-by: Michael Dawson <[email protected]>
PR-URL: #50846
Reviewed-By: Tobias Nießen <[email protected]>
Reviewed-By: Marco Ippolito <[email protected]>
Reviewed-By: James M Snell <[email protected]>
Reviewed-By: Luigi Pinca <[email protected]>
UlisesGascon pushed a commit that referenced this pull request Dec 11, 2023
- reduce copying by using std::move

Signed-off-by: Michael Dawson <[email protected]>
PR-URL: #50846
Reviewed-By: Tobias Nießen <[email protected]>
Reviewed-By: Marco Ippolito <[email protected]>
Reviewed-By: James M Snell <[email protected]>
Reviewed-By: Luigi Pinca <[email protected]>
@UlisesGascon UlisesGascon mentioned this pull request Dec 12, 2023
UlisesGascon pushed a commit that referenced this pull request Dec 13, 2023
- reduce copying by using std::move

Signed-off-by: Michael Dawson <[email protected]>
PR-URL: #50846
Reviewed-By: Tobias Nießen <[email protected]>
Reviewed-By: Marco Ippolito <[email protected]>
Reviewed-By: James M Snell <[email protected]>
Reviewed-By: Luigi Pinca <[email protected]>
UlisesGascon pushed a commit that referenced this pull request Dec 15, 2023
- reduce copying by using std::move

Signed-off-by: Michael Dawson <[email protected]>
PR-URL: #50846
Reviewed-By: Tobias Nießen <[email protected]>
Reviewed-By: Marco Ippolito <[email protected]>
Reviewed-By: James M Snell <[email protected]>
Reviewed-By: Luigi Pinca <[email protected]>
UlisesGascon pushed a commit that referenced this pull request Dec 19, 2023
- reduce copying by using std::move

Signed-off-by: Michael Dawson <[email protected]>
PR-URL: #50846
Reviewed-By: Tobias Nießen <[email protected]>
Reviewed-By: Marco Ippolito <[email protected]>
Reviewed-By: James M Snell <[email protected]>
Reviewed-By: Luigi Pinca <[email protected]>
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++. needs-ci PRs that need a full CI run. vm Issues and PRs related to the vm subsystem.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants