mirror of
https://gitlab.freedesktop.org/mesa/mesa.git
synced 2025-12-30 18:40:13 +01:00
rusticl: add debug assertions to avoid truncating casts
v2: reorder commits for cherry-picking Reviewed-by: Karol Herbst <kherbst@redhat.com> Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/33989>
This commit is contained in:
parent
474d8b6316
commit
4fc4f3425a
3 changed files with 17 additions and 0 deletions
|
|
@ -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
|
||||
|
|
|
|||
|
|
@ -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.
|
||||
|
|
|
|||
|
|
@ -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,
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue