"Alice Ryhl" <aliceryhl@xxxxxxxxxx> writes: > On Fri, Aug 15, 2025 at 09:30:40AM +0200, Andreas Hindborg wrote: <cut> >> +pub fn kstrtobool(string: &CStr) -> Result<bool> { >> + let mut result: bool = false; >> + >> + // SAFETY: `string` is a valid null-terminated C string, and `result` is a valid >> + // pointer to a bool that we own. >> + let ret = >> + unsafe { bindings::kstrtobool(string.as_char_ptr(), core::ptr::from_mut(&mut result)) }; > > Using ptr::from_mut here seesm excessive IMO. I think that function > makes sense when it replaces an explicit `as` cast, but now when it can > be done by a coercion. This is perfectly readable: > > let ret = unsafe { bindings::kstrtobool(string.as_char_ptr(), &mut result) }; > > Or if you insist, you could directly create a raw pointer: > > let ret = unsafe { bindings::kstrtobool(string.as_char_ptr(), &raw mut result) }; Oh, I'll do the implicit coercion then. I was using `&mut result as *mut bool` but clippy told me to do the `from_mut` instead. Best regards, Andreas Hindborg