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

fix/suppress findings reported by Coverity #216

Closed
wants to merge 3 commits into from

Conversation

kdudka
Copy link
Member

@kdudka kdudka commented Dec 12, 2024

See the commit messages for details.

@kdudka kdudka requested a review from siteshwar December 12, 2024 09:03
@kdudka kdudka self-assigned this Dec 12, 2024
... to eliminate unnecessary string copies

Suggested by Coverity:
```
Error: COPY_INSTEAD_OF_MOVE:
src/cslinker.cc:236:29: copy_constructor_call: "fnCwe" is passed-by-value as parameter to "std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >::basic_string(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const &)", when it could be moved instead.
src/cslinker.cc:236:29: remediation: Use "std::move(""fnCwe"")" instead of "fnCwe".

Error: COPY_INSTEAD_OF_MOVE:
src/cslinker.cc:249:29: copy_constructor_call: "fnImp" is passed-by-value as parameter to "std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >::basic_string(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const &)", when it could be moved instead.
src/cslinker.cc:249:29: remediation: Use "std::move(""fnImp"")" instead of "fnImp".
```

Related: csutils#216
Suggested by Coverity:
```
Error: COPY_INSTEAD_OF_MOVE:
src/lib/filter.cc:114:25: copy_constructor_call: "evt" is copied and then passed-by-reference as parameter to STL insertion function "std::vector<DefEvent, std::allocator<DefEvent> >::push_back(std::vector<DefEvent, std::allocator<DefEvent> >::value_type const &)", when it could be moved instead.
src/lib/filter.cc:114:25: remediation: Use "std::move(""evt"")" instead of "evt".

Error: COPY_INSTEAD_OF_MOVE:
src/lib/filter.cc:205:29: copy_constructor_call: "evt" is copied and then passed-by-reference as parameter to STL insertion function "std::set<DefEvent, std::less<DefEvent>, std::allocator<DefEvent> >::insert(std::set<DefEvent, std::less<DefEvent>, std::allocator<DefEvent> >::value_type const &)", when it could be moved instead.
src/lib/filter.cc:205:29: remediation: Use "std::move(""evt"")" instead of "evt".

Error: COPY_INSTEAD_OF_MOVE:
src/lib/parser-cov.cc:428:28: copy_constructor_call: "str" is copied and then passed-by-reference as parameter to STL insertion function "std::set<std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >, std::less<std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > >, std::allocator<std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > > >::insert(std::set<std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >, std::less<std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > >, std::allocator<std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > > >::value_type const &)", when it could be moved instead.
src/lib/parser-cov.cc:428:28: remediation: Use "std::move(""str"")" instead of "str".

Error: COPY_INSTEAD_OF_MOVE:
src/lib/parser-gcc.cc:552:46: copy_constructor_call: "evt" is copied and then passed-by-reference as parameter to STL insertion function "std::vector<DefEvent, std::allocator<DefEvent> >::push_back(std::vector<DefEvent, std::allocator<DefEvent> >::value_type const &)", when it could be moved instead.
src/lib/parser-gcc.cc:552:46: remediation: Use "std::move(""evt"")" instead of "evt".

Error: COPY_INSTEAD_OF_MOVE:
src/lib/parser-gcc.cc:558:46: copy_constructor_call: "evt" is copied and then passed-by-reference as parameter to STL insertion function "std::vector<DefEvent, std::allocator<DefEvent> >::push_back(std::vector<DefEvent, std::allocator<DefEvent> >::value_type const &)", when it could be moved instead.
src/lib/parser-gcc.cc:558:46: remediation: Use "std::move(""evt"")" instead of "evt".

Error: COPY_INSTEAD_OF_MOVE:
src/lib/parser-json-sarif.cc:205:13: copy_assignment_call: "uri" is copied in call to copy assignment for class "std::string const", when it could be moved instead.
src/lib/parser-json-sarif.cc:205:30: remediation: Use "std::move(""uri"")" instead of "uri".

Error: COPY_INSTEAD_OF_MOVE:
src/lib/parser-json-sarif.cc:250:32: copy_constructor_call: "evt" is copied and then passed-by-reference as parameter to STL insertion function "std::vector<DefEvent, std::allocator<DefEvent> >::push_back(std::vector<DefEvent, std::allocator<DefEvent> >::value_type const &)", when it could be moved instead.
src/lib/parser-json-sarif.cc:250:32: remediation: Use "std::move(""evt"")" instead of "evt".

Error: COPY_INSTEAD_OF_MOVE:
src/lib/parser-json-simple.cc:157:30: copy_constructor_call: "evt" is copied and then passed-by-reference as parameter to STL insertion function "std::vector<DefEvent, std::allocator<DefEvent> >::push_back(std::vector<DefEvent, std::allocator<DefEvent> >::value_type const &)", when it could be moved instead.
src/lib/parser-json-simple.cc:157:30: remediation: Use "std::move(""evt"")" instead of "evt".

Error: COPY_INSTEAD_OF_MOVE:
src/lib/parser-json-zap.cc:144:9: copy_assignment_call: "version" is copied in call to copy assignment for class "std::string const", when it could be moved instead.
src/lib/parser-json-zap.cc:144:49: remediation: Use "std::move(""version"")" instead of "version".

Error: COPY_INSTEAD_OF_MOVE:
src/lib/parser-xml-valgrind.cc:61:9: copy_assignment_call: "argVal" is copied in call to copy assignment for class "std::string const", when it could be moved instead.
src/lib/parser-xml-valgrind.cc:61:17: remediation: Use "std::move(""argVal"")" instead of "argVal".

Error: COPY_INSTEAD_OF_MOVE:
src/lib/parser-xml-valgrind.cc:227:32: copy_constructor_call: "noteEvt" is copied and then passed-by-reference as parameter to STL insertion function "std::vector<DefEvent, std::allocator<DefEvent> >::push_back(std::vector<DefEvent, std::allocator<DefEvent> >::value_type const &)", when it could be moved instead.
src/lib/parser-xml-valgrind.cc:227:32: remediation: Use "std::move(""noteEvt"")" instead of "noteEvt".
```

Related: csutils#216
```
Error: PASS_BY_VALUE (CWE-398):
src/lib/cwe-mapper.cc:38:45: pass_by_value: Passing parameter def of type "Defect" (size 200 bytes) by value, which exceeds the low threshold of 128 bytes.
```

Closes: csutils#216
@kdudka
Copy link
Member Author

kdudka commented Dec 13, 2024

@siteshwar Thanks for review!

@kdudka kdudka closed this in a61fae3 Dec 13, 2024
@kdudka kdudka deleted the cov-fixes branch December 13, 2024 18:13
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants