Hi Miguel, "Miguel Ojeda" <miguel.ojeda.sandonis@xxxxxxxxx> writes: > On Fri, Dec 13, 2024 at 12:33 PM Andreas Hindborg <a.hindborg@xxxxxxxxxx> wrote: >> >> +#![feature(sync_unsafe_cell)] > > Please mention this in the commit message, the status of the feature > and justify the addition. I forgot, thanks for pointing that out. Following the discussion of v2 of this series I can understand that `mut static` is discouraged and scheduled for removal. Interior mutability via `SyncUnsafeCell` provides the same functionality and it is my understanding that this feature is on track to be stabilized. > >> +//! C header: [`include/linux/moduleparam.h`](../../../include/linux/moduleparam.h) > > Please use `srctree`. Ok. > >> +/// Newtype to make `bindings::kernel_param` `Sync`. > > Please add intra-doc links where applicable, e.g. `Sync` here. Will do. > >> +unsafe extern "C" fn set_param<T>( >> + val: *const core::ffi::c_char, >> + param: *const crate::bindings::kernel_param, >> +) -> core::ffi::c_int >> +where >> + T: ModuleParam, >> +{ >> + // NOTE: If we start supporting arguments without values, val _is_ allowed >> + // to be null here. >> + assert!(!val.is_null()); > > Should this return an error instead? Not sure. `val` being null not supposed to happen in the current configuration. It should be an unreachable state. So BUG is the right thing? > >> +/// Write a string representation of the current parameter value to `buf`. >> +/// >> +/// # Safety >> +/// >> +/// Must not be called. >> +/// >> +/// # Note >> +/// >> +/// This should not be called as we declare all parameters as read only. >> +#[allow(clippy::extra_unused_type_parameters)] >> +unsafe extern "C" fn get_param<T>( >> + _buf: *mut core::ffi::c_char, >> + _param: *const crate::bindings::kernel_param, >> +) -> core::ffi::c_int >> +where >> + T: ModuleParam, >> +{ >> + unreachable!("Parameters are not readable"); >> +} > > Do we need this? Can't the `ops` callback be `null`? Not in the current configuration. The parameters can only be declared "read only". It should be impossible for anyone to call this function. > >> +/// The `arg` field of `param` must be an initialized instance of `Self`. > > `Self`? That whole line is wrong, thanks for spotting. It should read "`arg` must be an initialized instance of `T`. This function takes ownership of the `T` pointed to by `arg`.". > >> +/// Generate a static [`kernel_param_ops`](../../../include/linux/moduleparam.h) struct. > > `srctree`. 👍 > >> +/// Parse a token stream of the form `expected_name: "value",` and return the >> +/// string in the position of "value". Panics on parse error. > > `# Panics` section. Ok. > >> +/// `type` may be one of >> +/// >> +/// - `i8` >> +/// - `u8` >> +/// - `i8` >> +/// - `u8` >> +/// - `i16` >> +/// - `u16` >> +/// - `i32` >> +/// - `u32` >> +/// - `i64` >> +/// - `u64` >> +/// - `isize` >> +/// - `usize` > > Can these be intra-doc links? Yes! Thanks for the comments! Best regards, Andreas Hindborg