Skip to content

Commit 76c80a0

Browse files
authored
[UR] fix coverity issues (#19817)
1 parent 8a9b62a commit 76c80a0

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
@@ -35,7 +35,8 @@ class EnqueuedPool {
3535

3636
EnqueuedPool(event_release_callback_t EventReleaseFn,
3737
memory_free_callback_t MemFreeFn)
38-
: EventReleaseFn(EventReleaseFn), MemFreeFn(MemFreeFn) {}
38+
: EventReleaseFn(std::move(EventReleaseFn)),
39+
MemFreeFn(std::move(MemFreeFn)) {}
3940

4041
~EnqueuedPool();
4142
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
@@ -648,10 +648,15 @@ ur_result_t urDeviceGetSelected(ur_platform_handle_t hPlatform,
648648
[&](ur_device_handle_t urDeviceHandle) {
649649
// obtain and record device type from platform (squash
650650
// errors)
651-
ur_device_type_t hardwareType = ::UR_DEVICE_TYPE_DEFAULT;
652-
urDeviceGetInfo(urDeviceHandle, UR_DEVICE_INFO_TYPE,
653-
sizeof(ur_device_type_t), &hardwareType,
654-
0);
651+
ur_device_type_t hardwareType;
652+
ur_result_t res = urDeviceGetInfo(
653+
urDeviceHandle, UR_DEVICE_INFO_TYPE,
654+
sizeof(ur_device_type_t), &hardwareType, 0);
655+
// ignore failures and just assume the default hw type
656+
if (res != UR_RESULT_SUCCESS) {
657+
hardwareType = ::UR_DEVICE_TYPE_DEFAULT;
658+
}
659+
655660
return DeviceSpec{DevicePartLevel::ROOT, hardwareType,
656661
deviceCount++, DeviceIdTypeALL,
657662
DeviceIdTypeALL, urDeviceHandle};

0 commit comments

Comments
 (0)