Skip to content
Snippets Groups Projects
Commit b8c0c8d0 authored by Joe Richey's avatar Joe Richey Committed by Joseph Richey
Browse files

custom: Add check for function type


This makes sure we get a good compiler error if we give a bad path.

Signed-off-by: default avatarJoe Richey <joerichey@google.com>
parent 1ebd2ce0
No related branches found
No related tags found
No related merge requests found
......@@ -78,8 +78,9 @@ macro_rules! register_custom_getrandom {
// We use an extern "C" function to get the guarantees of a stable ABI.
#[no_mangle]
extern "C" fn __getrandom_custom(dest: *mut u8, len: usize) -> u32 {
let f: fn(&mut [u8]) -> Result<(), ::getrandom::Error> = $path;
let slice = unsafe { ::core::slice::from_raw_parts_mut(dest, len) };
match $path(slice) {
match f(slice) {
Ok(()) => 0,
Err(e) => e.code().get(),
}
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment