"Alice Ryhl" <alicer...@google.com> writes: > This validates at compile time that the signatures match what is in the > header file. It highlights one annoyance with the compile-time check, > which is that it can only be used with functions marked unsafe.
It would indeed be nice if there was a way to mark some functions to be emitted as safe by bindgen. > > If the function is not unsafe, then this error is emitted: > > error[E0308]: `if` and `else` have incompatible types > --> <linux>/drivers/gpu/drm/drm_panic_qr.rs:987:19 > | > 986 | #[export] > | --------- expected because of this > 987 | pub extern "C" fn drm_panic_qr_max_data_size(version: u8, url_len: > usize) -> usize { > | ^^^^^^^^^^^^^^^^^^^^^^^^^^ expected unsafe fn, found > safe fn > | > = note: expected fn item `unsafe extern "C" fn(_, _) -> _ > {kernel::bindings::drm_panic_qr_max_data_size}` > found fn item `extern "C" fn(_, _) -> _ > {drm_panic_qr_max_data_size}` > > Signed-off-by: Alice Ryhl <alicer...@google.com> Reviewed-by: Andreas Hindborg <a.hindb...@kernel.org> Best regards, Andreas Hindborg