Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Don't panic if UUIDs or LUIDs are wrong size #15

Closed
kenba opened this issue Oct 17, 2021 · 2 comments
Closed

Don't panic if UUIDs or LUIDs are wrong size #15

kenba opened this issue Oct 17, 2021 · 2 comments
Assignees
Labels
bug Something isn't working

Comments

@kenba
Copy link
Owner

kenba commented Oct 17, 2021

The change for issue #14 returns UUIDs or LUIDs for the relevant device param names.

The current implementation gets the values as a Vec<u8> then copies them into arrays of the appropriate size, i.e.: [u8; CL_UUID_SIZE_KHR] and [u8; CL_LUID_SIZE_KHR], so far so good.

The issue is that the library will panic if a device returns the wrong size for a UUID or LUID, either from the explicit assert or in the call to copy_from_slice.

This is wrong: the library shouldn't panic on bad data from a device, it should just return a Result error value.

@kenba kenba added the bug Something isn't working label Oct 17, 2021
@kenba kenba self-assigned this Oct 17, 2021
@kenba
Copy link
Owner Author

kenba commented Oct 17, 2021

The fix for the issue is to get UUIDs or LUIDs explicitly as values using CL_UUID_SIZE_KHR and CL_LUID_SIZE_KHR as the appropriate size parameter when calling clGetDeviceInfo.

Not only does this no longer panic, but it also only calls clGetDeviceInfo once instead of twice: once to get the size and then again to get the data. It also saves copying the data from the Vec<u8> into the UUID or LUID array.

Unfortunately, it was not possible to use the api_info_value! macro since the array type does not implement the Default trait.

@kenba
Copy link
Owner Author

kenba commented Oct 17, 2021

Incorporated in version 0.6.1.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

1 participant