Skip to content

Commit 55de8bc

Browse files
authored
[SYCL][UR][L0 v2] Fixes for coverity issues (#17874)
1 parent c2b5a90 commit 55de8bc

File tree

6 files changed

+21
-10
lines changed

6 files changed

+21
-10
lines changed

unified-runtime/source/adapters/level_zero/v2/command_list_manager.hpp

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,13 @@ struct ur_command_list_manager {
3737
ur_device_handle_t device,
3838
v2::raii::command_list_unique_handle &&commandList,
3939
v2::event_flags_t flags, ur_queue_t_ *queue);
40+
ur_command_list_manager(const ur_command_list_manager &src) = delete;
4041
ur_command_list_manager(ur_command_list_manager &&src) = default;
42+
43+
ur_command_list_manager &
44+
operator=(const ur_command_list_manager &src) = delete;
45+
ur_command_list_manager &operator=(ur_command_list_manager &&src) = default;
46+
4147
~ur_command_list_manager();
4248

4349
ur_result_t appendKernelLaunch(ur_kernel_handle_t hKernel, uint32_t workDim,

unified-runtime/source/adapters/level_zero/v2/event_pool.hpp

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,8 @@ class event_pool {
4040
event_pool(const event_pool &) = delete;
4141
event_pool &operator=(const event_pool &) = delete;
4242

43+
~event_pool() = default;
44+
4345
// Allocate an event from the pool. Thread safe.
4446
ur_event_handle_t allocate();
4547

unified-runtime/source/adapters/level_zero/v2/event_pool_cache.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ namespace v2 {
1616
event_pool_cache::event_pool_cache(ur_context_handle_t hContext,
1717
size_t max_devices,
1818
ProviderCreateFunc ProviderCreate)
19-
: hContext(hContext), providerCreate(ProviderCreate) {
19+
: hContext(hContext), providerCreate(std::move(ProviderCreate)) {
2020
pools.resize(max_devices * (1ULL << EVENT_FLAGS_USED_BITS));
2121
}
2222

unified-runtime/source/adapters/level_zero/v2/kernel.cpp

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -117,10 +117,11 @@ ur_result_t ur_kernel_handle_t_::release() {
117117
void ur_kernel_handle_t_::completeInitialization() {
118118
// Cache kernel name. Should be the same for all devices
119119
assert(deviceKernels.size() > 0);
120-
nonEmptyKernel =
121-
&std::find_if(deviceKernels.begin(), deviceKernels.end(),
122-
[](const auto &kernel) { return kernel.has_value(); })
123-
->value();
120+
auto nonEmptyKernelIt =
121+
std::find_if(deviceKernels.begin(), deviceKernels.end(),
122+
[](const auto &kernel) { return kernel.has_value(); });
123+
assert(nonEmptyKernelIt != deviceKernels.end());
124+
nonEmptyKernel = &nonEmptyKernelIt->value();
124125

125126
zeCommonProperties.Compute = [kernel = nonEmptyKernel](
126127
common_properties_t &props) {

unified-runtime/source/adapters/level_zero/v2/memory.cpp

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -158,13 +158,15 @@ getSyncCommandListForCopy(ur_context_handle_t hContext,
158158

159159
static ur_result_t synchronousZeCopy(ur_context_handle_t hContext,
160160
ur_device_handle_t hDevice, void *dst,
161-
const void *src, size_t size) {
161+
const void *src, size_t size) try {
162162
auto commandList = getSyncCommandListForCopy(hContext, hDevice);
163163

164164
ZE2UR_CALL(zeCommandListAppendMemoryCopy,
165165
(commandList.get(), dst, src, size, nullptr, 0, nullptr));
166166

167167
return UR_RESULT_SUCCESS;
168+
} catch (...) {
169+
return exceptionToResult(std::current_exception());
168170
}
169171

170172
void *ur_discrete_buffer_handle_t::allocateOnDevice(ur_device_handle_t hDevice,
@@ -414,20 +416,20 @@ void *ur_mem_sub_buffer_t::getDevicePtr(
414416
ur_device_handle_t hDevice, device_access_mode_t access, size_t offset,
415417
size_t size, std::function<void(void *src, void *dst, size_t)> migrate) {
416418
return hParent->getBuffer()->getDevicePtr(
417-
hDevice, access, offset + this->offset, size, migrate);
419+
hDevice, access, offset + this->offset, size, std::move(migrate));
418420
}
419421

420422
void *ur_mem_sub_buffer_t::mapHostPtr(
421423
ur_map_flags_t flags, size_t offset, size_t size,
422424
std::function<void(void *src, void *dst, size_t)> migrate) {
423425
return hParent->getBuffer()->mapHostPtr(flags, offset + this->offset, size,
424-
migrate);
426+
std::move(migrate));
425427
}
426428

427429
void ur_mem_sub_buffer_t::unmapHostPtr(
428430
void *pMappedPtr,
429431
std::function<void(void *src, void *dst, size_t)> migrate) {
430-
return hParent->getBuffer()->unmapHostPtr(pMappedPtr, migrate);
432+
return hParent->getBuffer()->unmapHostPtr(pMappedPtr, std::move(migrate));
431433
}
432434

433435
ur_shared_mutex &ur_mem_sub_buffer_t::getMutex() {

unified-runtime/source/adapters/level_zero/v2/queue_immediate_in_order.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -870,7 +870,7 @@ ur_result_t ur_queue_immediate_in_order_t::enqueueTimestampRecordingExp(
870870
"ur_queue_immediate_in_order_t::enqueueTimestampRecordingExp");
871871

872872
auto commandListLocked = commandListManager.lock();
873-
if (!phEvent && !*phEvent) {
873+
if (!phEvent) {
874874
return UR_RESULT_ERROR_INVALID_NULL_HANDLE;
875875
}
876876
getSignalEvent(commandListLocked, phEvent,

0 commit comments

Comments
 (0)