Skip to content

Commit dc23c28

Browse files
RossBruntonsvkeerthy
authored andcommitted
[Offload] Fix Error checking (#141939)
All errors must be checked - this includes the local variable we were using to increase the lifetime of `Res`. As we were not explicitly checking it, it resulted in an `abort` in debug builds.
1 parent dedf75b commit dc23c28

File tree

1 file changed

+9
-7
lines changed

1 file changed

+9
-7
lines changed

offload/liboffload/src/OffloadImpl.cpp

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -416,18 +416,20 @@ Error olMemcpy_impl(ol_queue_handle_t Queue, void *DstPtr,
416416

417417
// If no queue is given the memcpy will be synchronous
418418
auto QueueImpl = Queue ? Queue->AsyncInfo : nullptr;
419-
Error Res = Error::success();
420419

421420
if (DstDevice == HostDevice()) {
422-
Res = SrcDevice->Device->dataRetrieve(DstPtr, SrcPtr, Size, QueueImpl);
421+
if (auto Res =
422+
SrcDevice->Device->dataRetrieve(DstPtr, SrcPtr, Size, QueueImpl))
423+
return Res;
423424
} else if (SrcDevice == HostDevice()) {
424-
Res = DstDevice->Device->dataSubmit(DstPtr, SrcPtr, Size, QueueImpl);
425+
if (auto Res =
426+
DstDevice->Device->dataSubmit(DstPtr, SrcPtr, Size, QueueImpl))
427+
return Res;
425428
} else {
426-
Res = SrcDevice->Device->dataExchange(SrcPtr, *DstDevice->Device, DstPtr,
427-
Size, QueueImpl);
429+
if (auto Res = SrcDevice->Device->dataExchange(SrcPtr, *DstDevice->Device,
430+
DstPtr, Size, QueueImpl))
431+
return Res;
428432
}
429-
if (Res)
430-
return Res;
431433

432434
if (EventOut)
433435
*EventOut = makeEvent(Queue);

0 commit comments

Comments
 (0)