Skip to content

Commit c2464ee

Browse files
committed
duplicate getDevice() implementation to avoid const_cast
1 parent fff258a commit c2464ee

File tree

1 file changed

+4
-1
lines changed

1 file changed

+4
-1
lines changed

offload/plugins-nextgen/common/include/PluginInterface.h

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1295,7 +1295,10 @@ struct GenericPluginTy {
12951295
return *Devices[DeviceId];
12961296
}
12971297
const GenericDeviceTy &getDevice(int32_t DeviceId) const {
1298-
return const_cast<GenericPluginTy *>(this)->getDevice(DeviceId);
1298+
assert(isValidDeviceId(DeviceId) && "Invalid device id");
1299+
assert(Devices[DeviceId] && "Device is uninitialized");
1300+
1301+
return *Devices[DeviceId];
12991302
}
13001303

13011304
/// Get the number of active devices.

0 commit comments

Comments
 (0)