On Tue, Mar 11, 2025 at 3:22 PM kernel test robot <lkp@xxxxxxxxx> wrote: > > Hi Tamir, > > kernel test robot noticed the following build warnings: > > [auto build test WARNING on ff64846bee0e7e3e7bc9363ebad3bab42dd27e24] > > url: https://github.com/intel-lab-lkp/linux/commits/Tamir-Duberstein/rust-enable-clippy-ptr_as_ptr-lint/20250308-004557 > base: ff64846bee0e7e3e7bc9363ebad3bab42dd27e24 > patch link: https://lore.kernel.org/r/20250307-ptr-as-ptr-v1-1-582d06514c98%40gmail.com > patch subject: [PATCH] rust: enable `clippy::ptr_as_ptr` lint > config: x86_64-rhel-9.4-rust (https://download.01.org/0day-ci/archive/20250312/202503120332.YTCpFEvv-lkp@xxxxxxxxx/config) > compiler: clang version 18.1.8 (https://github.com/llvm/llvm-project 3b5b5c1ec4a3095ab096dd780e84d7ab81f3d7ff) > reproduce (this is a W=1 build): (https://download.01.org/0day-ci/archive/20250312/202503120332.YTCpFEvv-lkp@xxxxxxxxx/reproduce) > > If you fix the issue in a separate patch/commit (i.e. not just a new version of > the same patch/commit), kindly add following tags > | Reported-by: kernel test robot <lkp@xxxxxxxxx> > | Closes: https://lore.kernel.org/oe-kbuild-all/202503120332.YTCpFEvv-lkp@xxxxxxxxx/ > > All warnings (new ones prefixed by >>): > > >> warning: `as` casting between raw pointers without changing its mutability > --> rust/kernel/firmware.rs:64:35 > | > 64 | let ret = unsafe { func.0(pfw as _, name.as_char_ptr(), dev.as_raw()) }; > | ^^^^^^^^ help: try `pointer::cast`, a safer alternative: `pfw.cast()` > | > = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#ptr_as_ptr > = note: requested on the command line with `-W clippy::ptr-as-ptr` > > -- > 0-DAY CI Kernel Test Service > https://github.com/intel/lkp-tests/wiki Indeed missed this one because I wasn't building with CONFIG_RUST_FW_LOADER_ABSTRACTIONS. Fixed in v3 by: diff --git a/rust/kernel/firmware.rs b/rust/kernel/firmware.rs index c5162fdc95ff..74df815d2f4e 100644 --- a/rust/kernel/firmware.rs +++ b/rust/kernel/firmware.rs @@ -58,10 +58,11 @@ impl Firmware { fn request_internal(name: &CStr, dev: &Device, func: FwFunc) -> Result<Self> { let mut fw: *mut bindings::firmware = core::ptr::null_mut(); let pfw: *mut *mut bindings::firmware = &mut fw; + let pfw: *mut *const bindings::firmware = pfw.cast(); // SAFETY: `pfw` is a valid pointer to a NULL initialized `bindings::firmware` pointer. // `name` and `dev` are valid as by their type invariants. - let ret = unsafe { func.0(pfw as _, name.as_char_ptr(), dev.as_raw()) }; + let ret = unsafe { func.0(pfw, name.as_char_ptr(), dev.as_raw()) }; if ret != 0 { return Err(Error::from_errno(ret)); } By the way, it would be great if the email also included the rustc version used.