Skip to content

Commit 40a790f

Browse files
Merge pull request #1995 from kswiecicki/refcount-clear
Coverity fixes
2 parents 2f67b38 + 5e240cf commit 40a790f

File tree

4 files changed

+7
-13
lines changed

4 files changed

+7
-13
lines changed

scripts/templates/valddi.cpp.mako

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -221,13 +221,11 @@ namespace ur_validation_layer
221221
}
222222

223223
${x}_result_t context_t::tearDown() {
224-
${x}_result_t result = ${X}_RESULT_SUCCESS;
225-
226224
if (enableLeakChecking) {
227225
getContext()->refCountContext->logInvalidReferences();
228-
getContext()->refCountContext->clear();
229226
}
230-
return result;
227+
228+
return ${X}_RESULT_SUCCESS;
231229
}
232230

233231
} // namespace ur_validation_layer

source/loader/layers/sanitizer/asan_options.hpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -98,7 +98,7 @@ struct AsanOptions {
9898

9999
auto KV = OptionsEnvMap->find("quarantine_size_mb");
100100
if (KV != OptionsEnvMap->end()) {
101-
auto Value = KV->second.front();
101+
const auto &Value = KV->second.front();
102102
try {
103103
auto temp_long = std::stoul(Value);
104104
if (temp_long > UINT32_MAX) {
@@ -129,7 +129,7 @@ struct AsanOptions {
129129

130130
KV = OptionsEnvMap->find("max_redzone");
131131
if (KV != OptionsEnvMap->end()) {
132-
auto Value = KV->second.front();
132+
const auto &Value = KV->second.front();
133133
try {
134134
MaxRZSize = std::stoul(Value);
135135
if (MaxRZSize > 2048) {

source/loader/layers/validation/ur_leak_check.hpp

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -109,7 +109,7 @@ struct RefCountContext {
109109
// No more active adapters, so any references still held are leaked
110110
if (adapterCount == 0) {
111111
logInvalidReferences();
112-
clear();
112+
counts.clear();
113113
}
114114
}
115115

@@ -133,8 +133,6 @@ struct RefCountContext {
133133
updateRefCount(handle, REFCOUNT_CREATE_OR_INCREASE, isAdapterHandle);
134134
}
135135

136-
void clear() { counts.clear(); }
137-
138136
template <typename T> bool isReferenceValid(T handle) {
139137
std::unique_lock<std::mutex> lock(mutex);
140138
auto it = counts.find(static_cast<void *>(handle));

source/loader/layers/validation/ur_valddi.cpp

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -11182,13 +11182,11 @@ ur_result_t context_t::init(ur_dditable_t *dditable,
1118211182
}
1118311183

1118411184
ur_result_t context_t::tearDown() {
11185-
ur_result_t result = UR_RESULT_SUCCESS;
11186-
1118711185
if (enableLeakChecking) {
1118811186
getContext()->refCountContext->logInvalidReferences();
11189-
getContext()->refCountContext->clear();
1119011187
}
11191-
return result;
11188+
11189+
return UR_RESULT_SUCCESS;
1119211190
}
1119311191

1119411192
} // namespace ur_validation_layer

0 commit comments

Comments
 (0)