Skip to content

Commit 8e1ab1a

Browse files
committed
custom: Add check for function type
This makes sure we get a good compiler error if we give a bad path. Signed-off-by: Joe Richey <[email protected]>
1 parent c8f40e1 commit 8e1ab1a

File tree

1 file changed

+2
-1
lines changed

1 file changed

+2
-1
lines changed

src/custom.rs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -78,8 +78,9 @@ macro_rules! register_custom_getrandom {
7878
// We use an extern "C" function to get the guarantees of a stable ABI.
7979
#[no_mangle]
8080
extern "C" fn __getrandom_custom(dest: *mut u8, len: usize) -> u32 {
81+
let f: fn(&mut [u8]) -> Result<(), ::getrandom::Error> = $path;
8182
let slice = unsafe { ::core::slice::from_raw_parts_mut(dest, len) };
82-
match $path(slice) {
83+
match f(slice) {
8384
Ok(()) => 0,
8485
Err(e) => e.code().get(),
8586
}

0 commit comments

Comments
 (0)