Skip to content

Fixing Coverity copy/move issue #19452

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

Open
wants to merge 2 commits into
base: sycl
Choose a base branch
from

Conversation

Krishn1412
Copy link

Fixes Issue

@Krishn1412 Krishn1412 requested a review from a team as a code owner July 15, 2025 17:11
@@ -71,8 +71,7 @@ class StringTable {
if (!str)
return xpti::invalid_id<xpti::string_id_t>;

std::string LocalStr = str;
return add(LocalStr, ref_str);
return add(std::move(str), ref_str);
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
return add(std::move(str), ref_str);
return add(std::string(str), ref_str);

Otherwise, this looks like it will result in infinite recursion.

Comment on lines 1576 to 1581
auto Acc = StreamCBs.find(TraceType);
if (Acc == StreamCBs.end()) {
// Create a new slot and return the accessor for the trace type
auto Tmp = StreamCBs[TraceType];
auto& Tmp = StreamCBs[TraceType];
Acc = StreamCBs.find(TraceType);
}
Copy link
Contributor

@sergey-semenov sergey-semenov Jul 16, 2025

Choose a reason for hiding this comment

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

This whole block of code seems equivalent to just auto &Acc = StreamCBs[TraceType];, assuming Acc->second is changed to Acc below.

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.

[Coverity][XPTI] Unnecessary copies/copy instead of move
2 participants