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
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 1 addition & 2 deletions xptifw/include/xpti_string_table.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -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::string(str), ref_str);
}

xpti::string_id_t add(std::string str, const char **ref_str = nullptr) {
Expand Down
13 changes: 4 additions & 9 deletions xptifw/src/xpti_trace_framework.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -473,7 +473,7 @@ class Subscribers {
{
std::lock_guard<std::mutex> Lock(MMutex);
MNameLUT[Path] = Data;
MHandleLUT[Handle] = Data;
MHandleLUT[Handle] = std::move(Data);
}
} else {
// We may have loaded another shared object that is not a tool plugin
Expand Down Expand Up @@ -1573,12 +1573,7 @@ class Notifications {
// What we get is a concurrent_hash_map
// of vectors holding the callbacks we
// need access to;
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];
Acc = StreamCBs.find(TraceType);
}
auto &Acc = StreamCBs[TraceType];
// If the key does not exist, a new entry is created and an accessor to it
// is returned. If it exists, we have access to the previous entry.
//
Expand All @@ -1588,7 +1583,7 @@ class Notifications {
// If not, we set the first element of new entry to 'true' indicating that
// it is valid. Unregister will just set this flag to false, indicating
// that it is no longer valid and is unregistered.
for (auto &Ele : Acc->second) {
for (auto &Ele : Acc) {
if (Ele.second == cbFunc) {
if (Ele.first) // Already here and active
return xpti::result_t::XPTI_RESULT_DUPLICATE;
Expand All @@ -1600,7 +1595,7 @@ class Notifications {
}
// If we come here, then we did not find the callback being registered
// already in the framework. So, we insert it.
Acc->second.push_back(std::make_pair(true, cbFunc));
Acc.push_back(std::make_pair(true, cbFunc));
return xpti::result_t::XPTI_RESULT_SUCCESS;
}

Expand Down
Loading