Skip to content

Commit 4409422

Browse files
[SYCL] Fix Coverity hits (#19917)
- Make `Managed`'s move assignment safe for self-assignment - Move instead of copy in `GetCapabilitiesIntersectionSet`
1 parent a4f8899 commit 4409422

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
@@ -268,11 +268,12 @@ template <typename URResource> class Managed {
268268
}
269269
Managed &operator=(const Managed &) = delete;
270270
Managed &operator=(Managed &&Other) {
271+
URResource Temp = Other.R;
272+
Other.R = nullptr;
271273
if (R)
272274
Adapter->call<Release>(R);
275+
R = Temp;
273276

274-
R = Other.R;
275-
Other.R = nullptr;
276277
Adapter = Other.Adapter;
277278
return *this;
278279
}

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)