On Fri, Feb 28, 2025 at 4:34 PM Andy Shevchenko <andriy.shevchenko@xxxxxxxxxxxxxxx> wrote: > > On Fri, Feb 28, 2025 at 12:39:34PM +0000, Alice Ryhl wrote: > > 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. > > > > 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}` > > ... > > > +#if defined(CONFIG_DRM_PANIC_SCREEN_QR_CODE) > > +extern size_t drm_panic_qr_max_data_size(u8 version, size_t url_len); > > + > > +extern u8 drm_panic_qr_generate(const char *url, u8 *data, size_t data_len, size_t data_size, > > + u8 *tmp, size_t tmp_size); > > Is extern needed? I doubt it. I just copied the declaration without changing it. Alice