Skip to content

Commit 16dca6f

Browse files
[SYCL] Fix Coverity hits
- Make Managed's move assignment safe for self-assignment - Move instead of copy in GetCapabilitiesIntersectionSet
1 parent 29d4440 commit 16dca6f

File tree

2 files changed

+4
-3
lines changed

2 files changed

+4
-3
lines changed

sycl/source/detail/adapter_impl.hpp

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -264,11 +264,12 @@ template <typename URResource> class Managed {
264264
}
265265
Managed &operator=(const Managed &) = delete;
266266
Managed &operator=(Managed &&Other) {
267+
URResource Temp = Other.R;
268+
Other.R = nullptr;
267269
if (R)
268270
Adapter->call<Release>(R);
271+
R = Temp;
269272

270-
R = Other.R;
271-
Other.R = nullptr;
272273
Adapter = Other.Adapter;
273274
return *this;
274275
}

sycl/source/detail/context_impl.hpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -348,7 +348,7 @@ void GetCapabilitiesIntersectionSet(devices_range Devices,
348348
CapabilityList.begin(), CapabilityList.end(),
349349
DeviceCapabilities.begin(), DeviceCapabilities.end(),
350350
std::inserter(NewCapabilityList, NewCapabilityList.begin()));
351-
CapabilityList = NewCapabilityList;
351+
CapabilityList = std::move(NewCapabilityList);
352352
}
353353
CapabilityList.shrink_to_fit();
354354
}

0 commit comments

Comments
 (0)