diff --git a/src/gallium/frontends/rusticl/api/device.rs b/src/gallium/frontends/rusticl/api/device.rs index 38f2e1a9e1e..497bcb49109 100644 --- a/src/gallium/frontends/rusticl/api/device.rs +++ b/src/gallium/frontends/rusticl/api/device.rs @@ -346,6 +346,11 @@ fn get_device_ids( return Err(CL_DEVICE_NOT_FOUND); } + debug_assert!( + devs.len() <= cl_uint::MAX as usize, + "number of available devices exceeds `cl_uint::MAX`" + ); + // num_devices returns the number of OpenCL devices available that match device_type. If // num_devices is NULL, this argument is ignored. // SAFETY: Caller is responsible for providing a null pointer or one valid diff --git a/src/gallium/frontends/rusticl/api/memory.rs b/src/gallium/frontends/rusticl/api/memory.rs index 1e25eda386d..a6515b7faf8 100644 --- a/src/gallium/frontends/rusticl/api/memory.rs +++ b/src/gallium/frontends/rusticl/api/memory.rs @@ -916,6 +916,11 @@ fn get_supported_image_formats( res.sort(); res.dedup(); + debug_assert!( + res.len() <= cl_uint::MAX as usize, + "number of supported formats exceeds `cl_uint::MAX`" + ); + // `num_image_formats` should be the full count of supported formats, // regardless of the value of `num_entries`. It may be null, in which case // it is ignored. diff --git a/src/gallium/frontends/rusticl/api/types.rs b/src/gallium/frontends/rusticl/api/types.rs index 351f898cd75..0c1d7c2c940 100644 --- a/src/gallium/frontends/rusticl/api/types.rs +++ b/src/gallium/frontends/rusticl/api/types.rs @@ -189,6 +189,13 @@ cl_callback!( impl SVMFreeCb { pub fn call(self, queue: &Queue, svm_pointers: &mut [usize]) { + // `clEnqueueSVMFree()` takes the length of the `svm_pointers` list as a + // `cl_uint`, so this will only occur in cases of implementation error. + debug_assert!( + svm_pointers.len() <= cl_uint::MAX as usize, + "svm_pointers count must not exceed `cl_uint::MAX`" + ); + let (num_svm_pointers, svm_pointers) = if !svm_pointers.is_empty() { ( svm_pointers.len() as cl_uint,