From de92106d491d3f60f836641849540d677d428199 Mon Sep 17 00:00:00 2001 From: Krishn Parasar <76171905+Krishn1412@users.noreply.github.com> Date: Tue, 15 Jul 2025 22:38:09 +0530 Subject: [PATCH 1/3] Fixing Coverity copy/move issue --- xptifw/include/xpti_string_table.hpp | 3 +-- xptifw/src/xpti_trace_framework.cpp | 4 ++-- 2 files changed, 3 insertions(+), 4 deletions(-) diff --git a/xptifw/include/xpti_string_table.hpp b/xptifw/include/xpti_string_table.hpp index bd48df01921b1..08c72c89520c9 100644 --- a/xptifw/include/xpti_string_table.hpp +++ b/xptifw/include/xpti_string_table.hpp @@ -71,8 +71,7 @@ class StringTable { if (!str) return xpti::invalid_id; - std::string LocalStr = str; - return add(LocalStr, ref_str); + return add(std::move(str), ref_str); } xpti::string_id_t add(std::string str, const char **ref_str = nullptr) { diff --git a/xptifw/src/xpti_trace_framework.cpp b/xptifw/src/xpti_trace_framework.cpp index 264ad2122ecc4..c18cb7f5fc85b 100644 --- a/xptifw/src/xpti_trace_framework.cpp +++ b/xptifw/src/xpti_trace_framework.cpp @@ -473,7 +473,7 @@ class Subscribers { { std::lock_guard 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 @@ -1576,7 +1576,7 @@ class Notifications { 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); } // If the key does not exist, a new entry is created and an accessor to it From 4d6206e582bb5877382c23b42bac08dbf6671d2e Mon Sep 17 00:00:00 2001 From: Krishn Parasar <76171905+Krishn1412@users.noreply.github.com> Date: Fri, 18 Jul 2025 21:22:24 +0530 Subject: [PATCH 2/3] Changes based on comments --- xptifw/include/xpti_string_table.hpp | 2 +- xptifw/src/xpti_trace_framework.cpp | 11 +++-------- 2 files changed, 4 insertions(+), 9 deletions(-) diff --git a/xptifw/include/xpti_string_table.hpp b/xptifw/include/xpti_string_table.hpp index 08c72c89520c9..1309e5ca1e566 100644 --- a/xptifw/include/xpti_string_table.hpp +++ b/xptifw/include/xpti_string_table.hpp @@ -71,7 +71,7 @@ class StringTable { if (!str) return xpti::invalid_id; - return add(std::move(str), ref_str); + return add(std::string(str), ref_str); } xpti::string_id_t add(std::string str, const char **ref_str = nullptr) { diff --git a/xptifw/src/xpti_trace_framework.cpp b/xptifw/src/xpti_trace_framework.cpp index c18cb7f5fc85b..77f0433f5e8df 100644 --- a/xptifw/src/xpti_trace_framework.cpp +++ b/xptifw/src/xpti_trace_framework.cpp @@ -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. // @@ -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; @@ -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; } From 23a7f886ce38a447450b2ceaab93fc8a259afc32 Mon Sep 17 00:00:00 2001 From: Krishn Parasar <76171905+Krishn1412@users.noreply.github.com> Date: Wed, 23 Jul 2025 23:37:58 +0530 Subject: [PATCH 3/3] Lint issues --- xptifw/src/xpti_trace_framework.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/xptifw/src/xpti_trace_framework.cpp b/xptifw/src/xpti_trace_framework.cpp index 77f0433f5e8df..f30df87c74137 100644 --- a/xptifw/src/xpti_trace_framework.cpp +++ b/xptifw/src/xpti_trace_framework.cpp @@ -1573,7 +1573,7 @@ class Notifications { // What we get is a concurrent_hash_map // of vectors holding the callbacks we // need access to; - auto &Acc = StreamCBs[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. //