Skip to content

Commit cb5a0a5

Browse files
[UR] fix coverity issues (#19914)
This is a cherry-pick of #19817 Patch-by: Piotr Balcer <[email protected]>
1 parent 40e247d commit cb5a0a5

File tree

3 files changed

+14
-13
lines changed

3 files changed

+14
-13
lines changed

unified-runtime/source/adapters/level_zero/enqueued_pool.hpp

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,8 @@ class EnqueuedPool {
3434

3535
EnqueuedPool(event_release_callback_t EventReleaseFn,
3636
memory_free_callback_t MemFreeFn)
37-
: EventReleaseFn(EventReleaseFn), MemFreeFn(MemFreeFn) {}
37+
: EventReleaseFn(std::move(EventReleaseFn)),
38+
MemFreeFn(std::move(MemFreeFn)) {}
3839

3940
~EnqueuedPool();
4041
std::optional<Allocation> getBestFit(size_t Size, size_t Alignment,

unified-runtime/source/loader/layers/sanitizer/msan/msan_shadow.cpp

Lines changed: 3 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -88,12 +88,9 @@ ur_result_t MsanShadowMemoryCPU::Setup() {
8888
uptr End = kMemoryLayout[i].end;
8989
uptr Size = End - Start;
9090
MappingDesc::Type Type = kMemoryLayout[i].type;
91-
bool InitOrigins = true;
9291

93-
bool IsMap = Type == MappingDesc::SHADOW ||
94-
(InitOrigins && Type == MappingDesc::ORIGIN);
95-
bool IsProtect = Type == MappingDesc::INVALID ||
96-
(!InitOrigins && Type == MappingDesc::ORIGIN);
92+
bool IsMap = Type == MappingDesc::SHADOW || Type == MappingDesc::ORIGIN;
93+
bool IsProtect = Type == MappingDesc::INVALID;
9794

9895
if (IsMap) {
9996
if (MmapFixedNoReserve(Start, Size) == 0) {
@@ -124,9 +121,7 @@ ur_result_t MsanShadowMemoryCPU::Destory() {
124121
uptr End = kMemoryLayout[i].end;
125122
uptr Size = End - Start;
126123
MappingDesc::Type Type = kMemoryLayout[i].type;
127-
bool InitOrigins = true;
128-
bool IsMap = Type == MappingDesc::SHADOW ||
129-
(InitOrigins && Type == MappingDesc::ORIGIN);
124+
bool IsMap = Type == MappingDesc::SHADOW || Type == MappingDesc::ORIGIN;
130125
if (IsMap) {
131126
if (Munmap(Start, Size)) {
132127
return UR_RESULT_ERROR_UNKNOWN;

unified-runtime/source/loader/ur_lib.cpp

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -647,10 +647,15 @@ ur_result_t urDeviceGetSelected(ur_platform_handle_t hPlatform,
647647
[&](ur_device_handle_t urDeviceHandle) {
648648
// obtain and record device type from platform (squash
649649
// errors)
650-
ur_device_type_t hardwareType = ::UR_DEVICE_TYPE_DEFAULT;
651-
urDeviceGetInfo(urDeviceHandle, UR_DEVICE_INFO_TYPE,
652-
sizeof(ur_device_type_t), &hardwareType,
653-
0);
650+
ur_device_type_t hardwareType;
651+
ur_result_t res = urDeviceGetInfo(
652+
urDeviceHandle, UR_DEVICE_INFO_TYPE,
653+
sizeof(ur_device_type_t), &hardwareType, 0);
654+
// ignore failures and just assume the default hw type
655+
if (res != UR_RESULT_SUCCESS) {
656+
hardwareType = ::UR_DEVICE_TYPE_DEFAULT;
657+
}
658+
654659
return DeviceSpec{DevicePartLevel::ROOT, hardwareType,
655660
deviceCount++, DeviceIdTypeALL,
656661
DeviceIdTypeALL, urDeviceHandle};

0 commit comments

Comments
 (0)