On Fri, Aug 22, 2025 at 2:15 PM Andreas Hindborg <a.hindborg@xxxxxxxxxx> wrote: > > Add a convenience function to convert byte slices to boolean values by > wrapping them in a null-terminated C string and delegating to the > existing `kstrtobool` function. Only considers the first two bytes of > the input slice, following the kernel's boolean parsing semantics. > > Signed-off-by: Andreas Hindborg <a.hindborg@xxxxxxxxxx> One nit below, but generally looks good. Reviewed-by: Alice Ryhl <aliceryhl@xxxxxxxxxx> > +/// # Safety > +/// > +/// - `string` must point to a null terminated string that is valid for read. > +unsafe fn kstrtobool_raw(string: *const u8) -> Result<bool> { > + let mut result: bool = false; > + > + // SAFETY: > + // - By function safety requirement, `string` is a valid null-terminated string. > + // - `result` is a valid `bool` that we own. > + let ret = unsafe { bindings::kstrtobool(string, &mut result) }; > + > + kernel::error::to_result(ret).map(|()| result) I think this is easier to read as: to_result(unsafe { bindings::kstrtobool(string, &mut result) })?; Ok(result) Alice