Skip to content

Commit

Permalink
Merge pull request #1995 from kswiecicki/refcount-clear
Browse files Browse the repository at this point in the history
Coverity fixes
  • Loading branch information
omarahmed1111 authored Aug 22, 2024
2 parents 2f67b38 + 5e240cf commit 40a790f
Show file tree
Hide file tree
Showing 4 changed files with 7 additions and 13 deletions.
6 changes: 2 additions & 4 deletions scripts/templates/valddi.cpp.mako
Original file line number Diff line number Diff line change
Expand Up @@ -221,13 +221,11 @@ namespace ur_validation_layer
}

${x}_result_t context_t::tearDown() {
${x}_result_t result = ${X}_RESULT_SUCCESS;

if (enableLeakChecking) {
getContext()->refCountContext->logInvalidReferences();
getContext()->refCountContext->clear();
}
return result;

return ${X}_RESULT_SUCCESS;
}

} // namespace ur_validation_layer
4 changes: 2 additions & 2 deletions source/loader/layers/sanitizer/asan_options.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,7 @@ struct AsanOptions {

auto KV = OptionsEnvMap->find("quarantine_size_mb");
if (KV != OptionsEnvMap->end()) {
auto Value = KV->second.front();
const auto &Value = KV->second.front();
try {
auto temp_long = std::stoul(Value);
if (temp_long > UINT32_MAX) {
Expand Down Expand Up @@ -129,7 +129,7 @@ struct AsanOptions {

KV = OptionsEnvMap->find("max_redzone");
if (KV != OptionsEnvMap->end()) {
auto Value = KV->second.front();
const auto &Value = KV->second.front();
try {
MaxRZSize = std::stoul(Value);
if (MaxRZSize > 2048) {
Expand Down
4 changes: 1 addition & 3 deletions source/loader/layers/validation/ur_leak_check.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -109,7 +109,7 @@ struct RefCountContext {
// No more active adapters, so any references still held are leaked
if (adapterCount == 0) {
logInvalidReferences();
clear();
counts.clear();
}
}

Expand All @@ -133,8 +133,6 @@ struct RefCountContext {
updateRefCount(handle, REFCOUNT_CREATE_OR_INCREASE, isAdapterHandle);
}

void clear() { counts.clear(); }

template <typename T> bool isReferenceValid(T handle) {
std::unique_lock<std::mutex> lock(mutex);
auto it = counts.find(static_cast<void *>(handle));
Expand Down
6 changes: 2 additions & 4 deletions source/loader/layers/validation/ur_valddi.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -11182,13 +11182,11 @@ ur_result_t context_t::init(ur_dditable_t *dditable,
}

ur_result_t context_t::tearDown() {
ur_result_t result = UR_RESULT_SUCCESS;

if (enableLeakChecking) {
getContext()->refCountContext->logInvalidReferences();
getContext()->refCountContext->clear();
}
return result;

return UR_RESULT_SUCCESS;
}

} // namespace ur_validation_layer

0 comments on commit 40a790f

Please sign in to comment.