* Re: [PATCH 2/3] rust: clippy: disable `addr_of!` and `addr_of_mut` macros
@ 2025-03-13 12:16 Benno Lossin
0 siblings, 0 replies; 3+ messages in thread
From: Benno Lossin @ 2025-03-13 12:16 UTC (permalink / raw)
To: Antonio Hickey, Miguel Ojeda, Alex Gaynor, Boqun Feng, Gary Guo,
Björn Roy Baron, Andreas Hindborg, Alice Ryhl, Trevor Gross,
Danilo Krummrich
Cc: Benno Lossin, rust-for-linux, linux-kernel
On Thu Mar 13, 2025 at 6:33 AM CET, Antonio Hickey wrote:
> With the `raw_ref_op` feature enabled we no longer want to
> allow use of `addr_of!` and `addr_of_mut!` macros.
>
> We instead want to use `&raw` and `&raw mut` to get raw
> pointers to a place.
>
> Suggested-by: Benno Lossin <y86-dev@protonmail.com>
> Link: https://github.com/Rust-for-Linux/linux/issues/1148
> Signed-off-by: Antonio Hickey <contact@antoniohickey.com>
This patch needs to be done after changing all occurrences of
`addr_of[_mut]!`, ie the next one (otherwise it would warn about them).
I also noticed that this feature sadly doesn't work very well, see
https://rust-for-linux.zulipchat.com/#narrow/channel/291565-Help/topic/.2Eclippy.2Etoml.20has.20no.20effect
and
https://github.com/rust-lang/rust-clippy/issues/11431
---
Cheers,
Benno
> ---
> .clippy.toml | 4 ++++
> 1 file changed, 4 insertions(+)
>
> diff --git a/.clippy.toml b/.clippy.toml
> index 815c94732ed7..95c73959f039 100644
> --- a/.clippy.toml
> +++ b/.clippy.toml
> @@ -8,4 +8,8 @@ disallowed-macros = [
> # The `clippy::dbg_macro` lint only works with `std::dbg!`, thus we simulate
> # it here, see: https://github.com/rust-lang/rust-clippy/issues/11303.
> { path = "kernel::dbg", reason = "the `dbg!` macro is intended as a debugging tool" },
> + # With `raw_ref_op` feature enabled we no longer want to allow use of `addr_of!`
> + # and `addr_of_mut!` macros, but instead use `&raw` or `&raw mut`.
> + { path = "core::ptr::addr_of_mut", reason = "use `&raw mut` instead `addr_of_mut!`" },
> + { path = "core::ptr::addr_of", reason = "use `&raw` instead `addr_of!`" },
> ]
^ permalink raw reply [flat|nested] 3+ messages in thread
[parent not found: <20250313053340.405979-1-contact@antoniohickey.com>]
* [PATCH 2/3] rust: clippy: disable `addr_of!` and `addr_of_mut` macros
[not found] <20250313053340.405979-1-contact@antoniohickey.com>
@ 2025-03-13 5:33 ` Antonio Hickey
2025-03-14 5:54 ` kernel test robot
0 siblings, 1 reply; 3+ messages in thread
From: Antonio Hickey @ 2025-03-13 5:33 UTC (permalink / raw)
To: Miguel Ojeda, Alex Gaynor, Boqun Feng, Gary Guo,
Björn Roy Baron, Benno Lossin, Andreas Hindborg, Alice Ryhl,
Trevor Gross, Danilo Krummrich
Cc: Antonio Hickey, Benno Lossin, rust-for-linux, linux-kernel
With the `raw_ref_op` feature enabled we no longer want to
allow use of `addr_of!` and `addr_of_mut!` macros.
We instead want to use `&raw` and `&raw mut` to get raw
pointers to a place.
Suggested-by: Benno Lossin <y86-dev@protonmail.com>
Link: https://github.com/Rust-for-Linux/linux/issues/1148
Signed-off-by: Antonio Hickey <contact@antoniohickey.com>
---
.clippy.toml | 4 ++++
1 file changed, 4 insertions(+)
diff --git a/.clippy.toml b/.clippy.toml
index 815c94732ed7..95c73959f039 100644
--- a/.clippy.toml
+++ b/.clippy.toml
@@ -8,4 +8,8 @@ disallowed-macros = [
# The `clippy::dbg_macro` lint only works with `std::dbg!`, thus we simulate
# it here, see: https://github.com/rust-lang/rust-clippy/issues/11303.
{ path = "kernel::dbg", reason = "the `dbg!` macro is intended as a debugging tool" },
+ # With `raw_ref_op` feature enabled we no longer want to allow use of `addr_of!`
+ # and `addr_of_mut!` macros, but instead use `&raw` or `&raw mut`.
+ { path = "core::ptr::addr_of_mut", reason = "use `&raw mut` instead `addr_of_mut!`" },
+ { path = "core::ptr::addr_of", reason = "use `&raw` instead `addr_of!`" },
]
--
2.48.1
^ permalink raw reply related [flat|nested] 3+ messages in thread
* Re: [PATCH 2/3] rust: clippy: disable `addr_of!` and `addr_of_mut` macros
2025-03-13 5:33 ` Antonio Hickey
@ 2025-03-14 5:54 ` kernel test robot
0 siblings, 0 replies; 3+ messages in thread
From: kernel test robot @ 2025-03-14 5:54 UTC (permalink / raw)
To: Antonio Hickey, Miguel Ojeda, Alex Gaynor, Boqun Feng, Gary Guo,
Björn Roy Baron, Benno Lossin, Andreas Hindborg, Alice Ryhl,
Trevor Gross, Danilo Krummrich
Cc: oe-kbuild-all, Antonio Hickey, rust-for-linux, linux-kernel
Hi Antonio,
kernel test robot noticed the following build warnings:
[auto build test WARNING on rust/rust-next]
[also build test WARNING on driver-core/driver-core-testing driver-core/driver-core-next driver-core/driver-core-linus shuah-kselftest/kunit shuah-kselftest/kunit-fixes pci/next pci/for-linus linus/master v6.14-rc6 next-20250313]
[cannot apply to rust/rust-block-next]
[If your patch is applied to the wrong git tree, kindly drop us a note.
And when submitting patch, we suggest to use '--base' as documented in
https://git-scm.com/docs/git-format-patch#_base_tree_information]
url: https://github.com/intel-lab-lkp/linux/commits/Antonio-Hickey/rust-clippy-disable-addr_of-and-addr_of_mut-macros/20250313-133646
base: https://github.com/Rust-for-Linux/linux rust-next
patch link: https://lore.kernel.org/r/010001958dfeb4c7-0ed042d2-613b-4023-bb91-0c64f8a84fc9-000000%40email.amazonses.com
patch subject: [PATCH 2/3] rust: clippy: disable `addr_of!` and `addr_of_mut` macros
config: x86_64-rhel-9.4-rust (https://download.01.org/0day-ci/archive/20250314/202503141300.7VvqEzvm-lkp@intel.com/config)
compiler: clang version 18.1.8 (https://github.com/llvm/llvm-project 3b5b5c1ec4a3095ab096dd780e84d7ab81f3d7ff)
rustc: rustc 1.78.0 (9b00956e5 2024-04-29)
reproduce (this is a W=1 build): (https://download.01.org/0day-ci/archive/20250314/202503141300.7VvqEzvm-lkp@intel.com/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@intel.com>
| Closes: https://lore.kernel.org/oe-kbuild-all/202503141300.7VvqEzvm-lkp@intel.com/
All warnings (new ones prefixed by >>):
>> warning: use of a disallowed macro `core::ptr::addr_of`
--> rust/kernel/fs/file.rs:334:18
|
334 | unsafe { core::ptr::addr_of!((*self.as_ptr()).f_flags).read_volatile() }
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
= note: use `&raw` instead `addr_of!` (from clippy.toml)
= help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#disallowed_macros
--
>> warning: use of a disallowed macro `core::ptr::addr_of`
--> rust/kernel/list.rs:179:34
|
179 | unsafe { Opaque::raw_get(ptr::addr_of!((*me).inner)) }
| ^^^^^^^^^^^^^^^^^^^^^^^^^^
|
= note: use `&raw` instead `addr_of!` (from clippy.toml)
= help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#disallowed_macros
--
>> warning: use of a disallowed macro `core::ptr::addr_of`
--> rust/kernel/sync/arc.rs:246:18
|
246 | unsafe { core::ptr::addr_of!((*ptr).data) }
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
= note: use `&raw` instead `addr_of!` (from clippy.toml)
= help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#disallowed_macros
--
>> warning: use of a disallowed macro `core::ptr::addr_of`
--> rust/kernel/task.rs:260:29
|
260 | let ptr = unsafe { *ptr::addr_of!((*self.as_ptr()).group_leader) };
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
= note: use `&raw` instead `addr_of!` (from clippy.toml)
= help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#disallowed_macros
--
>> warning: use of a disallowed macro `core::ptr::addr_of`
--> rust/kernel/task.rs:272:19
|
272 | unsafe { *ptr::addr_of!((*self.as_ptr()).pid) }
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
= note: use `&raw` instead `addr_of!` (from clippy.toml)
= help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#disallowed_macros
--
>> warning: use of a disallowed macro `core::ptr::addr_of`
--> rust/kernel/workqueue.rs:406:34
|
406 | unsafe { Opaque::raw_get(core::ptr::addr_of!((*ptr).work)) }
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
= note: use `&raw` instead `addr_of!` (from clippy.toml)
= help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#disallowed_macros
--
0-DAY CI Kernel Test Service
https://github.com/intel/lkp-tests/wiki
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2025-03-14 5:54 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2025-03-13 12:16 [PATCH 2/3] rust: clippy: disable `addr_of!` and `addr_of_mut` macros Benno Lossin
[not found] <20250313053340.405979-1-contact@antoniohickey.com>
2025-03-13 5:33 ` Antonio Hickey
2025-03-14 5:54 ` kernel test robot
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).