[PATCH v12 5/5] rust: remove core::ffi::CStr reexport

2025-06-19 Thread Tamir Duberstein
Clean up references to `kernel::str::CStr`. Signed-off-by: Tamir Duberstein --- drivers/gpu/drm/drm_panic_qr.rs | 3 ++- drivers/gpu/nova-core/firmware.rs | 2 +- drivers/gpu/nova-core/nova_core.rs| 2 +- drivers/net/phy/ax88796b_rust.rs | 1 + drivers/net/phy/qt2025.rs

[PATCH v12 0/5] rust: replace kernel::str::CStr w/ core::ffi::CStr

2025-06-19 Thread Tamir Duberstein
inux/linux/issues/1075 Signed-off-by: Tamir Duberstein --- Changes in v12: - Introduce `kernel::fmt::Display` to allow implementations on foreign types. - Tidy up doc comment on `str_to_cstr`. (Alice Ryhl). - Link to v11: https://lore.kernel.org/r/20250530-cstr-core-v11-0-cd9c0cbcb...@gmail.com Chan

[PATCH v12 2/5] rust: support formatting of foreign types

2025-06-19 Thread Tamir Duberstein
Signed-off-by: Tamir Duberstein --- drivers/block/rnull.rs | 2 +- drivers/gpu/nova-core/gpu.rs | 4 +- rust/kernel/block/mq.rs | 2 +- rust/kernel/device.rs| 2 +- rust/kernel/fmt.rs | 89 +++ rust/kernel/kunit.rs | 6

[PATCH v12 3/5] rust: replace `CStr` with `core::ffi::CStr`

2025-06-19 Thread Tamir Duberstein
nux/commit/faa3cbcca03d0dec8f8e43f1d8d5c0860d98a23f [0] Signed-off-by: Tamir Duberstein --- drivers/gpu/drm/drm_panic_qr.rs | 2 +- rust/kernel/auxiliary.rs| 4 +- rust/kernel/configfs.rs | 4 +- rust/kernel/cpufreq.rs | 2 +- rust/kernel/device.rs | 4 +- rust/

[PATCH v12 4/5] rust: replace `kernel::c_str!` with C-Strings

2025-06-19 Thread Tamir Duberstein
C-String literals were added in Rust 1.77. Replace instances of `kernel::c_str!` with C-String literals where possible and rename `kernel::c_str!` to `str_to_cstr!` to clarify its intended use. Closes: https://github.com/Rust-for-Linux/linux/issues/1075 Signed-off-by: Tamir Duberstein

[PATCH v12 1/5] rust: macros: reduce collections in `quote!` macro

2025-06-19 Thread Tamir Duberstein
Remove a handful of unncessary intermediate vectors and token streams; mainly the top-level stream can be directly extended with the notable exception of groups. Remove an unnecessary `#[allow(dead_code)]` added in commit dbd5058ba60c ("rust: make pin-init its own crate"). Signed-off

Re: [PATCH v12 1/6] rust: enable `clippy::ptr_as_ptr` lint

2025-06-18 Thread Tamir Duberstein
On Wed, Jun 18, 2025 at 1:44 PM Danilo Krummrich wrote: > > On 6/18/25 6:45 PM, Miguel Ojeda wrote: > > On Wed, Jun 18, 2025 at 3:54 PM Tamir Duberstein wrote: > >> > >> @Andreas Hindborg could you please have a look for configfs? > >> > >> @Rafae

Re: [PATCH v12 4/6] rust: enable `clippy::as_underscore` lint

2025-06-18 Thread Tamir Duberstein
On Wed, Jun 18, 2025 at 1:50 PM Miguel Ojeda wrote: > > On Wed, Jun 18, 2025 at 7:38 PM Danilo Krummrich wrote: > > > > Shouldn't this be `c_long`? > > Yeah, agreed, it is clearer -- I mentioned that for similar ones in a > previous version. +1 Miguel, would you mind taking care of this on appl

Re: [PATCH v12 1/6] rust: enable `clippy::ptr_as_ptr` lint

2025-06-18 Thread Tamir Duberstein
On Sun, Jun 15, 2025 at 4:55 PM Tamir Duberstein wrote: > > In Rust 1.51.0, Clippy introduced the `ptr_as_ptr` lint [1]: > > > Though `as` casts between raw pointers are not terrible, > > `pointer::cast` is safer because it cannot accidentally change the > > pointer

Re: [PATCH v12 5/6] rust: enable `clippy::cast_lossless` lint

2025-06-18 Thread Tamir Duberstein
On Sun, Jun 15, 2025 at 4:55 PM Tamir Duberstein wrote: > > Before Rust 1.29.0, Clippy introduced the `cast_lossless` lint [1]: > > > Rust’s `as` keyword will perform many kinds of conversions, including > > silently lossy conversions. Conversion functions such as `i32

Re: [PATCH v12 4/6] rust: enable `clippy::as_underscore` lint

2025-06-18 Thread Tamir Duberstein
On Sun, Jun 15, 2025 at 4:55 PM Tamir Duberstein wrote: > > In Rust 1.63.0, Clippy introduced the `as_underscore` lint [1]: > > > The conversion might include lossy conversion or a dangerous cast that > > might go undetected due to the type being inferred. > > > &g

Re: [PATCH] rust: types: add Opaque::from_raw

2025-06-17 Thread Tamir Duberstein
To help catch this kind of mistake, add a new Opaque::from_raw that > wraps a raw pointer in Opaque without changing the inner type. > > Signed-off-by: Alice Ryhl Reviewed-by: Tamir Duberstein > --- > rust/kernel/drm/device.rs | 4 +--- > rust/kernel/drm/gem/mod.rs |

[PATCH v12 0/6] rust: reduce `as` casts, enable related lints

2025-06-15 Thread Tamir Duberstein
x27;t missed. As a later addition, `clippy::cast_lossless` and `clippy::ref_as_ptr` are also enabled. Signed-off-by: Tamir Duberstein --- Changes in v12: - Remove stale mention of a dependency. (Miguel Ojeda) - Apply to config, cpufreq, and nova. (Miguel Ojeda) - Link to v11: https://lore.kernel.

[PATCH v12 5/6] rust: enable `clippy::cast_lossless` lint

2025-06-15 Thread Tamir Duberstein
d8ortxsutkgl.1kojagbm8f...@proton.me/ Reviewed-by: Benno Lossin Reviewed-by: Boqun Feng Signed-off-by: Tamir Duberstein --- Makefile | 1 + drivers/gpu/drm/drm_panic_qr.rs | 4 ++-- drivers/gpu/nova-core/regs.rs| 2 +- drivers/gpu/nova-core/regs/macros.rs | 2 +

[PATCH v12 6/6] rust: enable `clippy::ref_as_ptr` lint

2025-06-15 Thread Tamir Duberstein
iewed-by: Benno Lossin Reviewed-by: Boqun Feng Signed-off-by: Tamir Duberstein --- Makefile | 1 + rust/bindings/lib.rs | 1 + rust/kernel/configfs.rs | 20 ++-- rust/kernel/device_id.rs | 2 +- rust/kernel/fs/file.rs | 2 +- rust/kernel/str.rs | 4 ++

[PATCH v12 2/6] rust: enable `clippy::ptr_cast_constness` lint

2025-06-15 Thread Tamir Duberstein
https://rust-lang.github.io/rust-clippy/master/index.html#ptr_cast_constness [1] Reviewed-by: Benno Lossin Reviewed-by: Boqun Feng Signed-off-by: Tamir Duberstein --- Makefile| 1 + rust/kernel/block/mq/request.rs | 4 ++-- rust/kernel/drm/device.rs | 4 ++-- 3 fil

[PATCH v12 1/6] rust: enable `clippy::ptr_as_ptr` lint

2025-06-15 Thread Tamir Duberstein
wed-by: Boqun Feng Signed-off-by: Tamir Duberstein --- Makefile | 1 + rust/bindings/lib.rs | 1 + rust/kernel/alloc/allocator_test.rs| 2 +- rust/kernel/alloc/kvec.rs | 4 ++-- rust/kernel/configfs.rs| 2 +- rust

[PATCH v12 4/6] rust: enable `clippy::as_underscore` lint

2025-06-15 Thread Tamir Duberstein
us apply the changes and enable the lint -- no functional change intended. Link: https://rust-lang.github.io/rust-clippy/master/index.html#as_underscore [1] Reviewed-by: Benno Lossin Reviewed-by: Boqun Feng Signed-off-by: Tamir Duberstein --- Makefile | 1 + d

[PATCH v12 3/6] rust: enable `clippy::as_ptr_cast_mut` lint

2025-06-15 Thread Tamir Duberstein
tml#as_ptr_cast_mut [1] Reviewed-by: Benno Lossin Reviewed-by: Boqun Feng Signed-off-by: Tamir Duberstein --- Makefile | 1 + rust/kernel/devres.rs | 2 +- 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/Makefile b/Makefile index 5eeddfbf5900..bb33023f87c3 100644 --- a/

Re: [PATCH v11 0/6] rust: reduce `as` casts, enable related lints

2025-06-15 Thread Tamir Duberstein
On Fri, Jun 13, 2025 at 2:14 PM Miguel Ojeda wrote: > > On Wed, Jun 11, 2025 at 12:23 PM Tamir Duberstein wrote: > > > > This series depends on "rust: retain pointer mut-ness in > > `container_of!`"[1]. > > Not anymore! :) > > > Signed-off-by: Ta

[PATCH v11 3/6] rust: enable `clippy::as_ptr_cast_mut` lint

2025-06-11 Thread Tamir Duberstein
tml#as_ptr_cast_mut [1] Reviewed-by: Benno Lossin Reviewed-by: Boqun Feng Signed-off-by: Tamir Duberstein --- Makefile | 1 + rust/kernel/devres.rs | 2 +- 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/Makefile b/Makefile index 5eeddfbf5900..bb33023f87c3 100644 --- a/

[PATCH v11 4/6] rust: enable `clippy::as_underscore` lint

2025-06-11 Thread Tamir Duberstein
us apply the changes and enable the lint -- no functional change intended. Link: https://rust-lang.github.io/rust-clippy/master/index.html#as_underscore [1] Reviewed-by: Benno Lossin Reviewed-by: Boqun Feng Signed-off-by: Tamir Duberstein --- Makefile | 1 +

[PATCH v11 6/6] rust: enable `clippy::ref_as_ptr` lint

2025-06-11 Thread Tamir Duberstein
iewed-by: Benno Lossin Reviewed-by: Boqun Feng Signed-off-by: Tamir Duberstein --- Makefile | 1 + rust/bindings/lib.rs | 1 + rust/kernel/device_id.rs | 2 +- rust/kernel/fs/file.rs | 2 +- rust/kernel/str.rs | 4 ++-- rust/kernel/uaccess.rs | 4 ++-- rust/uap

[PATCH v11 1/6] rust: enable `clippy::ptr_as_ptr` lint

2025-06-11 Thread Tamir Duberstein
wed-by: Boqun Feng Signed-off-by: Tamir Duberstein --- Makefile | 1 + rust/bindings/lib.rs | 1 + rust/kernel/alloc/allocator_test.rs| 2 +- rust/kernel/alloc/kvec.rs | 4 ++-- rust/kernel/device.rs | 4 ++-- rus

[PATCH v11 5/6] rust: enable `clippy::cast_lossless` lint

2025-06-11 Thread Tamir Duberstein
d8ortxsutkgl.1kojagbm8f...@proton.me/ Reviewed-by: Benno Lossin Reviewed-by: Boqun Feng Signed-off-by: Tamir Duberstein --- Makefile| 1 + drivers/gpu/drm/drm_panic_qr.rs | 4 ++-- rust/bindings/lib.rs| 1 + rust/kernel/net/phy.rs | 4 ++-- rust/uapi/lib.rs

[PATCH v11 2/6] rust: enable `clippy::ptr_cast_constness` lint

2025-06-11 Thread Tamir Duberstein
https://rust-lang.github.io/rust-clippy/master/index.html#ptr_cast_constness [1] Reviewed-by: Benno Lossin Reviewed-by: Boqun Feng Signed-off-by: Tamir Duberstein --- Makefile| 1 + rust/kernel/block/mq/request.rs | 4 ++-- rust/kernel/drm/device.rs | 4 ++-- 3 fil

[PATCH v11 0/6] rust: reduce `as` casts, enable related lints

2025-06-11 Thread Tamir Duberstein
- Added additional patches, converted to series. - Link to v1: https://lore.kernel.org/r/20250307-ptr-as-ptr-v1-1-582d06514...@gmail.com --- Tamir Duberstein (6): rust: enable `clippy::ptr_as_ptr` lint rust: enable `clippy::ptr_cast_constness` lint rust: enable `clippy::as_ptr_c

Re: [PATCH v10 4/6] rust: enable `clippy::as_underscore` lint

2025-06-10 Thread Tamir Duberstein
On Sun, Jun 8, 2025 at 5:06 PM Miguel Ojeda wrote: > > On Fri, Apr 18, 2025 at 5:37 PM Tamir Duberstein wrote: > > > > -bindings::BLK_STS_OK as _ > > +bindings::BLK_STS_OK as u8 > > > -unsafe { bindings::blk_mq_end_request(request_

Re: [PATCH v11 4/5] rust: replace `kernel::c_str!` with C-Strings

2025-06-02 Thread Tamir Duberstein
On Mon, Jun 2, 2025 at 4:45 AM Alice Ryhl wrote: > > On Fri, May 30, 2025 at 08:27:45AM -0400, Tamir Duberstein wrote: > > C-String literals were added in Rust 1.77. Replace instances of > > `kernel::c_str!` with C-String literals where possible and rename > > `kernel:

Re: [PATCH v11 3/5] rust: replace `CStr` with `core::ffi::CStr`

2025-06-02 Thread Tamir Duberstein
On Mon, Jun 2, 2025 at 4:46 AM Alice Ryhl wrote: > > On Fri, May 30, 2025 at 08:27:44AM -0400, Tamir Duberstein wrote: > > `kernel::ffi::CStr` was introduced in commit d126d2380131 ("rust: str: > > add `CStr` type") in November 2022 as an upstreaming of earlier work &

Re: [PATCH v11 1/5] rust: macros: reduce collections in `quote!` macro

2025-06-01 Thread Tamir Duberstein
On Sun, Jun 1, 2025 at 12:24 PM Benno Lossin wrote: > > On Fri May 30, 2025 at 2:27 PM CEST, Tamir Duberstein wrote: > > Remove a handful of unncessary intermediate vectors and token streams; > > mainly the top-level stream can be directly extended with the notable >

[PATCH v11 5/5] rust: remove core::ffi::CStr reexport

2025-05-30 Thread Tamir Duberstein
Clean up references to `kernel::str::CStr`. Signed-off-by: Tamir Duberstein --- drivers/gpu/drm/drm_panic_qr.rs | 3 ++- drivers/gpu/nova-core/firmware.rs | 2 +- drivers/net/phy/ax88796b_rust.rs | 1 + drivers/net/phy/qt2025.rs | 1 + rust/kernel/device.rs | 3

[PATCH v11 3/5] rust: replace `CStr` with `core::ffi::CStr`

2025-05-30 Thread Tamir Duberstein
nux/commit/faa3cbcca03d0dec8f8e43f1d8d5c0860d98a23f [0] Signed-off-by: Tamir Duberstein --- drivers/gpu/drm/drm_panic_qr.rs | 2 +- rust/kernel/device.rs | 4 +- rust/kernel/error.rs| 4 +- rust/kernel/firmware.rs | 11 +- rust/kernel/kunit.rs| 6 +- r

[PATCH v11 1/5] rust: macros: reduce collections in `quote!` macro

2025-05-30 Thread Tamir Duberstein
Remove a handful of unncessary intermediate vectors and token streams; mainly the top-level stream can be directly extended with the notable exception of groups. Remove an unnecessary `#[allow(dead_code)]` added in commit dbd5058ba60c ("rust: make pin-init its own crate"). Signed-off

[PATCH v11 4/5] rust: replace `kernel::c_str!` with C-Strings

2025-05-30 Thread Tamir Duberstein
C-String literals were added in Rust 1.77. Replace instances of `kernel::c_str!` with C-String literals where possible and rename `kernel::c_str!` to `str_to_cstr!` to clarify its intended use. Closes: https://github.com/Rust-for-Linux/linux/issues/1075 Signed-off-by: Tamir Duberstein

[PATCH v11 2/5] rust: support formatting of foreign types

2025-05-30 Thread Tamir Duberstein
/516476467 Signed-off-by: Tamir Duberstein --- drivers/block/rnull.rs | 2 +- rust/kernel/block/mq.rs | 2 +- rust/kernel/device.rs | 2 +- rust/kernel/fmt.rs | 77 +++ rust/kernel/kunit.rs| 6 +-- rust/kernel/lib.rs | 1 + r

[PATCH v11 0/5] rust: replace kernel::str::CStr w/ core::ffi::CStr

2025-05-30 Thread Tamir Duberstein
inux/linux/issues/1075 Signed-off-by: Tamir Duberstein --- Changes in v11: - Use `quote_spanned!` to avoid `use<'a, T>` and generally reduce manual token construction. - Add a commit to simplify `quote_spanned!`. - Drop first commit in favor of https://lore.kernel.org/rust-for-linux/202

Re: [PATCH v10 4/5] rust: replace `kernel::c_str!` with C-Strings

2025-05-29 Thread Tamir Duberstein
On Wed, May 28, 2025 at 11:35 AM Benno Lossin wrote: > > On Wed May 28, 2025 at 12:36 PM CEST, Alice Ryhl wrote: > > On Mon, May 26, 2025 at 06:29:46PM -0400, Tamir Duberstein wrote: > >> On Mon, May 26, 2025 at 11:04 AM Benno Lossin wrote: > >> > > >&

Re: [PATCH v10 2/5] rust: support formatting of foreign types

2025-05-29 Thread Tamir Duberstein
On Tue, May 27, 2025 at 4:49 PM Benno Lossin wrote: > > On Tue May 27, 2025 at 5:02 PM CEST, Tamir Duberstein wrote: > > On Mon, May 26, 2025 at 7:01 PM Benno Lossin wrote: > >> On Tue May 27, 2025 at 12:17 AM CEST, Tamir Duberstein wrote: > >> > On Mon, May

Re: [PATCH v10 0/5] rust: replace kernel::str::CStr w/ core::ffi::CStr

2025-05-28 Thread Tamir Duberstein
On Wed, May 28, 2025 at 6:38 AM Alice Ryhl wrote: > > On Sat, May 24, 2025 at 04:33:00PM -0400, Tamir Duberstein wrote: > > This picks up from Michal Rostecki's work[0]. Per Michal's guidance I > > have omitted Co-authored tags, as the end result is quite differe

Re: [PATCH v10 4/5] rust: replace `kernel::c_str!` with C-Strings

2025-05-27 Thread Tamir Duberstein
On Mon, May 26, 2025 at 7:07 PM Benno Lossin wrote: > > On Tue May 27, 2025 at 12:29 AM CEST, Tamir Duberstein wrote: > > On Mon, May 26, 2025 at 11:04 AM Benno Lossin wrote: > >> On Sat May 24, 2025 at 10:33 PM CEST, Tamir Duberstein wrote: > >> > +

Re: [PATCH v10 3/5] rust: replace `CStr` with `core::ffi::CStr`

2025-05-27 Thread Tamir Duberstein
On Mon, May 26, 2025 at 7:03 PM Benno Lossin wrote: > > On Tue May 27, 2025 at 12:24 AM CEST, Tamir Duberstein wrote: > > On Mon, May 26, 2025 at 10:56 AM Benno Lossin wrote: > >> > >> On Sat May 24, 2025 at 10:33 PM CEST, Tamir Duberstein wrote: > >> >

Re: [PATCH v10 2/5] rust: support formatting of foreign types

2025-05-27 Thread Tamir Duberstein
On Mon, May 26, 2025 at 7:01 PM Benno Lossin wrote: > > On Tue May 27, 2025 at 12:17 AM CEST, Tamir Duberstein wrote: > > On Mon, May 26, 2025 at 10:48 AM Benno Lossin wrote: > >> On Sat May 24, 2025 at 10:33 PM CEST, Tamir Duberstein wrote: > >> > Introdu

Re: [PATCH v10 2/5] rust: support formatting of foreign types

2025-05-27 Thread Tamir Duberstein
On Tue, May 27, 2025 at 8:44 AM Alice Ryhl wrote: > > On Tue, May 27, 2025 at 12:18 AM Tamir Duberstein wrote: > > > > +} > > > > + > > > > +fn make_ident<'a, T: IntoIterator>( > > > > +span: Span, > > > > +name

Re: [PATCH v10 5/5] rust: remove core::ffi::CStr reexport

2025-05-26 Thread Tamir Duberstein
On Mon, May 26, 2025 at 11:05 AM Benno Lossin wrote: > > On Sat May 24, 2025 at 10:33 PM CEST, Tamir Duberstein wrote: > > Clean up references to `kernel::str::CStr`. > > > > Signed-off-by: Tamir Duberstein > > --- > > drivers/gpu/drm/drm_panic_qr.rs

Re: [PATCH v10 4/5] rust: replace `kernel::c_str!` with C-Strings

2025-05-26 Thread Tamir Duberstein
On Mon, May 26, 2025 at 11:04 AM Benno Lossin wrote: > > On Sat May 24, 2025 at 10:33 PM CEST, Tamir Duberstein wrote: > > +macro_rules! c_str_avoid_literals { > > I don't like this name, how about `concat_to_c_str` or > `concat_with_nul`? > > This macro also i

Re: [PATCH v10 3/5] rust: replace `CStr` with `core::ffi::CStr`

2025-05-26 Thread Tamir Duberstein
On Mon, May 26, 2025 at 10:56 AM Benno Lossin wrote: > > On Sat May 24, 2025 at 10:33 PM CEST, Tamir Duberstein wrote: > > `std::ffi::CStr` was moved to `core::ffi::CStr` in Rust 1.64. Replace > > `kernel::str::CStr` with `core::ffi::CStr` now that we can. > > What'

Re: [PATCH v10 2/5] rust: support formatting of foreign types

2025-05-26 Thread Tamir Duberstein
On Mon, May 26, 2025 at 10:48 AM Benno Lossin wrote: > > On Sat May 24, 2025 at 10:33 PM CEST, Tamir Duberstein wrote: > > Introduce a `fmt!` macro which wraps all arguments in > > `kernel::fmt::Adapter` This enables formatting of foreign types (like > > `core::ffi::CStr

Re: [PATCH v10 1/5] rust: retitle "Example" section as "Examples"

2025-05-26 Thread Tamir Duberstein
On Mon, May 26, 2025 at 12:15 PM Miguel Ojeda wrote: > > On Sat, May 24, 2025 at 10:33 PM Tamir Duberstein wrote: > > > > This title is consistent with all other macros' documentation, > > regardless of the number of examples contained in their "Examples&qu

[PATCH v10 4/5] rust: replace `kernel::c_str!` with C-Strings

2025-05-24 Thread Tamir Duberstein
C-String literals were added in Rust 1.77. Replace instances of `kernel::c_str!` with C-String literals where possible and rename `kernel::c_str!` to `c_str_avoid_literals` to clarify its intended use. Closes: https://github.com/Rust-for-Linux/linux/issues/1075 Signed-off-by: Tamir Duberstein

[PATCH v10 5/5] rust: remove core::ffi::CStr reexport

2025-05-24 Thread Tamir Duberstein
Clean up references to `kernel::str::CStr`. Signed-off-by: Tamir Duberstein --- drivers/gpu/drm/drm_panic_qr.rs | 3 ++- drivers/gpu/nova-core/firmware.rs | 2 +- drivers/net/phy/ax88796b_rust.rs | 1 + drivers/net/phy/qt2025.rs | 1 + rust/kernel/device.rs | 3

[PATCH v10 2/5] rust: support formatting of foreign types

2025-05-24 Thread Tamir Duberstein
/516476467 Signed-off-by: Tamir Duberstein --- drivers/block/rnull.rs | 2 +- rust/kernel/block/mq.rs | 2 +- rust/kernel/device.rs | 2 +- rust/kernel/fmt.rs | 77 + rust/kernel/kunit.rs| 6 +-- rust/kernel/lib.rs | 1 + r

[PATCH v10 0/5] rust: replace kernel::str::CStr w/ core::ffi::CStr

2025-05-24 Thread Tamir Duberstein
inux/linux/issues/1075 Signed-off-by: Tamir Duberstein --- Changes in v10: - Rebase on cbeaa41dfe26b72639141e87183cb23e00d4b0dd. - Implement Alice's suggestion to use a proc macro to work around orphan rules otherwise preventing `core::ffi::CStr` to be directly printed with `{}`. - Lin

[PATCH v10 3/5] rust: replace `CStr` with `core::ffi::CStr`

2025-05-24 Thread Tamir Duberstein
necessary; the rest will be done in a later commit. Signed-off-by: Tamir Duberstein --- drivers/gpu/drm/drm_panic_qr.rs | 2 +- rust/kernel/device.rs | 4 +- rust/kernel/error.rs| 4 +- rust/kernel/firmware.rs | 11 +- rust/kernel/kunit.rs| 6 +- rust

[PATCH v10 1/5] rust: retitle "Example" section as "Examples"

2025-05-24 Thread Tamir Duberstein
This title is consistent with all other macros' documentation, regardless of the number of examples contained in their "Examples" sections. Signed-off-by: Tamir Duberstein --- rust/macros/lib.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/rust/macros/lib.r

[PATCH v10 2/6] rust: enable `clippy::ptr_cast_constness` lint

2025-04-18 Thread Tamir Duberstein
ast_constness [1] Reviewed-by: Benno Lossin Signed-off-by: Tamir Duberstein --- Makefile| 1 + rust/kernel/block/mq/request.rs | 4 ++-- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/Makefile b/Makefile index 5d2931344490..7b85b2a8d371 100644 --- a/M

[PATCH v10 4/6] rust: enable `clippy::as_underscore` lint

2025-04-18 Thread Tamir Duberstein
us apply the changes and enable the lint -- no functional change intended. Link: https://rust-lang.github.io/rust-clippy/master/index.html#as_underscore [1] Reviewed-by: Benno Lossin Signed-off-by: Tamir Duberstein --- Makefile | 1 + rust/kernel/block/mq/operati

[PATCH v10 3/6] rust: enable `clippy::as_ptr_cast_mut` lint

2025-04-18 Thread Tamir Duberstein
tml#as_ptr_cast_mut [1] Reviewed-by: Benno Lossin Reviewed-by: Boqun Feng Signed-off-by: Tamir Duberstein --- Makefile | 1 + rust/kernel/devres.rs | 2 +- 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/Makefile b/Makefile index 7b85b2a8d371..04a5246171f9 100644 --- a/

[PATCH v10 1/6] rust: enable `clippy::ptr_as_ptr` lint

2025-04-18 Thread Tamir Duberstein
wed-by: Boqun Feng Signed-off-by: Tamir Duberstein --- Makefile | 1 + rust/bindings/lib.rs | 1 + rust/kernel/alloc/allocator_test.rs| 2 +- rust/kernel/alloc/kvec.rs | 4 ++-- rust/kernel/device.rs | 4 ++-- rus

[PATCH v10 6/6] rust: enable `clippy::ref_as_ptr` lint

2025-04-18 Thread Tamir Duberstein
iewed-by: Benno Lossin Reviewed-by: Boqun Feng Signed-off-by: Tamir Duberstein --- Makefile | 1 + rust/bindings/lib.rs | 1 + rust/kernel/device_id.rs | 2 +- rust/kernel/fs/file.rs | 2 +- rust/kernel/str.rs | 4 ++-- rust/kernel/uaccess.rs | 4 ++-- rust/uap

[PATCH v10 5/6] rust: enable `clippy::cast_lossless` lint

2025-04-18 Thread Tamir Duberstein
d8ortxsutkgl.1kojagbm8f...@proton.me/ Reviewed-by: Benno Lossin Signed-off-by: Tamir Duberstein --- Makefile| 1 + drivers/gpu/drm/drm_panic_qr.rs | 2 +- rust/bindings/lib.rs| 1 + rust/kernel/net/phy.rs | 4 ++-- rust/uapi/lib.rs|

[PATCH v10 0/6] rust: reduce `as` casts, enable related lints

2025-04-18 Thread Tamir Duberstein
- Added additional patches, converted to series. - Link to v1: https://lore.kernel.org/r/20250307-ptr-as-ptr-v1-1-582d06514...@gmail.com --- Tamir Duberstein (6): rust: enable `clippy::ptr_as_ptr` lint rust: enable `clippy::ptr_cast_constness` lint rust: enable `clippy::as_ptr_c

Re: [PATCH v9 4/6] rust: enable `clippy::as_underscore` lint

2025-04-18 Thread Tamir Duberstein
On Fri, Apr 18, 2025 at 11:09 AM Boqun Feng wrote: > > On Fri, Apr 18, 2025 at 08:08:02AM -0400, Tamir Duberstein wrote: > > On Thu, Apr 17, 2025 at 4:12 PM Boqun Feng wrote: > > > > > > On Thu, Apr 17, 2025 at 03:26:14PM

Re: [PATCH v9 4/6] rust: enable `clippy::as_underscore` lint

2025-04-18 Thread Tamir Duberstein
On Thu, Apr 17, 2025 at 4:12 PM Boqun Feng wrote: > > On Thu, Apr 17, 2025 at 03:26:14PM -0400, Tamir Duberstein wrote: > [...] > > > > > > > Ok(()) > > > > } > > > > diff --git a/rust/kernel/device_id.rs b/rust/kernel/device

Re: [PATCH v9 5/6] rust: enable `clippy::cast_lossless` lint

2025-04-17 Thread Tamir Duberstein
On Thu, Apr 17, 2025 at 1:29 PM Boqun Feng wrote: > > On Wed, Apr 16, 2025 at 01:36:09PM -0400, Tamir Duberstein wrote: > > Before Rust 1.29.0, Clippy introduced the `cast_lossless` lint [1]: > > > > > Rust’s `as` keyword will perform many kinds of conversions, inc

Re: [PATCH v9 4/6] rust: enable `clippy::as_underscore` lint

2025-04-17 Thread Tamir Duberstein
On Thu, Apr 17, 2025 at 1:55 PM Boqun Feng wrote: > > On Wed, Apr 16, 2025 at 01:36:08PM -0400, Tamir Duberstein wrote: > > In Rust 1.63.0, Clippy introduced the `as_underscore` lint [1]: > > > > > The conversion might include lossy conversion or a dangerous cast tha

Re: [PATCH v9 2/6] rust: enable `clippy::ptr_cast_constness` lint

2025-04-17 Thread Tamir Duberstein
On Thu, Apr 17, 2025 at 1:12 PM Boqun Feng wrote: > > On Wed, Apr 16, 2025 at 01:36:06PM -0400, Tamir Duberstein wrote: > > In Rust 1.72.0, Clippy introduced the `ptr_cast_constness` lint [1]: > > > > > Though `as` casts between raw pointers are not terrible, &g

Re: [PATCH v9 1/6] rust: enable `clippy::ptr_as_ptr` lint

2025-04-17 Thread Tamir Duberstein
On Thu, Apr 17, 2025 at 12:48 PM Boqun Feng wrote: > > On Wed, Apr 16, 2025 at 01:36:05PM -0400, Tamir Duberstein wrote: > > In Rust 1.51.0, Clippy introduced the `ptr_as_ptr` lint [1]: > > > > > Though `as` casts between raw pointers are not terrible, > > >

Re: [PATCH v9 6/6] rust: enable `clippy::ref_as_ptr` lint

2025-04-16 Thread Tamir Duberstein
On Wed, Apr 16, 2025 at 1:51 PM Boqun Feng wrote: > > On Wed, Apr 16, 2025 at 01:36:10PM -0400, Tamir Duberstein wrote: > > In Rust 1.78.0, Clippy introduced the `ref_as_ptr` lint [1]: > > > > > Using `as` casts may result in silently changing mutability or type.

[PATCH v9 4/6] rust: enable `clippy::as_underscore` lint

2025-04-16 Thread Tamir Duberstein
us apply the changes and enable the lint -- no functional change intended. Link: https://rust-lang.github.io/rust-clippy/master/index.html#as_underscore [1] Reviewed-by: Benno Lossin Signed-off-by: Tamir Duberstein --- Makefile | 1 + rust/kernel/block/mq/operati

[PATCH v9 1/6] rust: enable `clippy::ptr_as_ptr` lint

2025-04-16 Thread Tamir Duberstein
` is replaced with `let *mut *const T = (*mut *mut T)`.cast();` since pointer to pointer can be confusing. Apply these changes and enable the lint -- no functional change intended. Link: https://rust-lang.github.io/rust-clippy/master/index.html#ptr_as_ptr [1] Reviewed-by: Benno Lossin Si

[PATCH v9 3/6] rust: enable `clippy::as_ptr_cast_mut` lint

2025-04-16 Thread Tamir Duberstein
tml#as_ptr_cast_mut [1] Reviewed-by: Benno Lossin Signed-off-by: Tamir Duberstein --- Makefile | 1 + rust/kernel/devres.rs | 2 +- 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/Makefile b/Makefile index 7b85b2a8d371..04a5246171f9 100644 --- a/Makefile +++ b/Makefile @@

[PATCH v9 5/6] rust: enable `clippy::cast_lossless` lint

2025-04-16 Thread Tamir Duberstein
d8ortxsutkgl.1kojagbm8f...@proton.me/ Reviewed-by: Benno Lossin Signed-off-by: Tamir Duberstein --- Makefile| 1 + drivers/gpu/drm/drm_panic_qr.rs | 2 +- rust/bindings/lib.rs| 1 + rust/kernel/net/phy.rs | 4 ++-- rust/uapi/lib.rs|

[PATCH v9 6/6] rust: enable `clippy::ref_as_ptr` lint

2025-04-16 Thread Tamir Duberstein
iewed-by: Benno Lossin Signed-off-by: Tamir Duberstein --- Makefile | 1 + rust/bindings/lib.rs | 1 + rust/kernel/device_id.rs | 2 +- rust/kernel/fs/file.rs | 2 +- rust/kernel/str.rs | 4 ++-- rust/kernel/uaccess.rs | 4 ++-- rust/uapi/lib.rs | 1 + 7 files ch

[PATCH v9 0/6] rust: reduce `as` casts, enable related lints

2025-04-16 Thread Tamir Duberstein
-id: 20250409-container-of-mutness-b153dab4388d:v1 prerequisite-patch-id: 53d5889db599267f87642bb0ae3063c29bc24863 Best regards, -- Tamir Duberstein

[PATCH v9 2/6] rust: enable `clippy::ptr_cast_constness` lint

2025-04-16 Thread Tamir Duberstein
ast_constness [1] Reviewed-by: Benno Lossin Signed-off-by: Tamir Duberstein --- Makefile| 1 + rust/kernel/block/mq/request.rs | 4 ++-- rust/kernel/dma.rs | 2 +- 3 files changed, 4 insertions(+), 3 deletions(-) diff --git a/Makefile b/Makefile index

Re: [PATCH v8 6/6] rust: enable `clippy::ref_as_ptr` lint

2025-04-15 Thread Tamir Duberstein
On Tue, Apr 15, 2025 at 7:03 PM Boqun Feng wrote: > > On Tue, Apr 15, 2025 at 04:59:01PM -0400, Tamir Duberstein wrote: > [...] > > > > > > > > diff --git a/rust/kernel/device_id.rs b/rust/kernel/device_id.rs > > > > > > > > index 406

Re: [PATCH v8 6/6] rust: enable `clippy::ref_as_ptr` lint

2025-04-15 Thread Tamir Duberstein
On Tue, Apr 15, 2025 at 4:51 PM Boqun Feng wrote: > > On Tue, Apr 15, 2025 at 04:10:01PM -0400, Tamir Duberstein wrote: > > On Tue, Apr 15, 2025 at 2:18 PM Boqun Feng wrote: > > > > > > On Tue, Apr 15, 2025 at 01:58:41PM -0400, Tamir Duberstein wrote: > > &g

Re: [PATCH v8 6/6] rust: enable `clippy::ref_as_ptr` lint

2025-04-15 Thread Tamir Duberstein
On Tue, Apr 15, 2025 at 2:18 PM Boqun Feng wrote: > > On Tue, Apr 15, 2025 at 01:58:41PM -0400, Tamir Duberstein wrote: > > Hi Boqun, thanks for having a look! > > > > On Tue, Apr 15, 2025 at 1:37 PM Boqun Feng wrote: > > > > > > On Wed, Apr 09, 2025 a

Re: [PATCH v8 6/6] rust: enable `clippy::ref_as_ptr` lint

2025-04-15 Thread Tamir Duberstein
Hi Boqun, thanks for having a look! On Tue, Apr 15, 2025 at 1:37 PM Boqun Feng wrote: > > On Wed, Apr 09, 2025 at 10:47:23AM -0400, Tamir Duberstein wrote: > > In Rust 1.78.0, Clippy introduced the `ref_as_ptr` lint [1]: > > > > > Using `as` casts may result in sile

[PATCH v8 3/6] rust: enable `clippy::as_ptr_cast_mut` lint

2025-04-09 Thread Tamir Duberstein
tml#as_ptr_cast_mut [1] Reviewed-by: Benno Lossin Signed-off-by: Tamir Duberstein --- Makefile | 1 + rust/kernel/devres.rs | 2 +- 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/Makefile b/Makefile index 7b85b2a8d371..04a5246171f9 100644 --- a/Makefile +++ b/Makefile @@

[PATCH v8 6/6] rust: enable `clippy::ref_as_ptr` lint

2025-04-09 Thread Tamir Duberstein
d-off-by: Tamir Duberstein --- Makefile | 1 + rust/bindings/lib.rs | 1 + rust/kernel/device_id.rs | 3 ++- rust/kernel/fs/file.rs | 3 ++- rust/kernel/str.rs | 6 -- rust/kernel/uaccess.rs | 10 -- rust/uapi/lib.rs | 1 + 7 files cha

[PATCH v8 0/6] rust: reduce `as` casts, enable related lints

2025-04-09 Thread Tamir Duberstein
eries. - Link to v1: https://lore.kernel.org/r/20250307-ptr-as-ptr-v1-1-582d06514...@gmail.com --- Tamir Duberstein (6): rust: enable `clippy::ptr_as_ptr` lint rust: enable `clippy::ptr_cast_constness` lint rust: enable `clippy::as_ptr_cast_mut` lint rust: enable `clippy::as_

[PATCH v8 5/6] rust: enable `clippy::cast_lossless` lint

2025-04-09 Thread Tamir Duberstein
d8ortxsutkgl.1kojagbm8f...@proton.me/ Reviewed-by: Benno Lossin Signed-off-by: Tamir Duberstein --- Makefile| 1 + drivers/gpu/drm/drm_panic_qr.rs | 2 +- rust/bindings/lib.rs| 1 + rust/kernel/net/phy.rs | 4 ++-- rust/uapi/lib.rs|

[PATCH v8 4/6] rust: enable `clippy::as_underscore` lint

2025-04-09 Thread Tamir Duberstein
us apply the changes and enable the lint -- no functional change intended. Link: https://rust-lang.github.io/rust-clippy/master/index.html#as_underscore [1] Reviewed-by: Benno Lossin Signed-off-by: Tamir Duberstein --- Makefile | 1 + rust/kernel/block/mq/operati

[PATCH v8 1/6] rust: enable `clippy::ptr_as_ptr` lint

2025-04-09 Thread Tamir Duberstein
` is replaced with `let *mut *const T = (*mut *mut T)`.cast();` since pointer to pointer can be confusing. Apply these changes and enable the lint -- no functional change intended. Link: https://rust-lang.github.io/rust-clippy/master/index.html#ptr_as_ptr [1] Reviewed-by: Benno Lossin Si

[PATCH v8 2/6] rust: enable `clippy::ptr_cast_constness` lint

2025-04-09 Thread Tamir Duberstein
er/index.html#ptr_cast_constness [1] Reviewed-by: Benno Lossin Signed-off-by: Tamir Duberstein --- Makefile| 1 + rust/kernel/block/mq/request.rs | 5 +++-- rust/kernel/dma.rs | 2 +- 3 files changed, 5 insertions(+), 3 deletions(-) diff --git a/Makefile b/M

Re: [PATCH v2 2/3] rust: alloc: add Vec::resize method

2025-04-05 Thread Tamir Duberstein
Some(n) => self.extend_with(n, value, flags), None => { self.truncate(new_len); Ok(()) } } > } > > impl Drop for Vec > -- > 2.48.1 > > Either way: Reviewed-by: Tamir Duberstein

Re: [PATCH v7 7/7] rust: enable `clippy::ref_as_ptr` lint

2025-03-27 Thread Tamir Duberstein
On Thu, Mar 27, 2025 at 10:15 AM Tamir Duberstein wrote: > > On Wed, Mar 26, 2025 at 6:15 PM Benno Lossin wrote: > > > > On Wed Mar 26, 2025 at 11:09 PM CET, Tamir Duberstein wrote: > > > On Wed, Mar 26, 2025 at 5:09 PM Benno Lossin > > > wrote: > > &g

Re: [PATCH v7 7/7] rust: enable `clippy::ref_as_ptr` lint

2025-03-27 Thread Tamir Duberstein
On Wed, Mar 26, 2025 at 6:15 PM Benno Lossin wrote: > > On Wed Mar 26, 2025 at 11:09 PM CET, Tamir Duberstein wrote: > > On Wed, Mar 26, 2025 at 5:09 PM Benno Lossin wrote: > >> On Wed Mar 26, 2025 at 8:06 PM CET, Tamir Duberstein wrote: > >> > On Wed, Mar

Re: [PATCH v7 7/7] rust: enable `clippy::ref_as_ptr` lint

2025-03-26 Thread Tamir Duberstein
On Wed, Mar 26, 2025 at 5:09 PM Benno Lossin wrote: > > On Wed Mar 26, 2025 at 8:06 PM CET, Tamir Duberstein wrote: > > On Wed, Mar 26, 2025 at 1:36 PM Benno Lossin wrote: > >> On Wed Mar 26, 2025 at 5:57 PM CET, Tamir Duberstein wrote: > >> > In the current co

Re: [PATCH v7 7/7] rust: enable `clippy::ref_as_ptr` lint

2025-03-26 Thread Tamir Duberstein
On Wed, Mar 26, 2025 at 3:06 PM Tamir Duberstein wrote: > > On Wed, Mar 26, 2025 at 1:36 PM Benno Lossin wrote: > > > > On Wed Mar 26, 2025 at 5:57 PM CET, Tamir Duberstein wrote: > > > > > > > > > In the current code you're looking at, yes. Bu

Re: [PATCH v7 7/7] rust: enable `clippy::ref_as_ptr` lint

2025-03-26 Thread Tamir Duberstein
On Wed, Mar 26, 2025 at 1:36 PM Benno Lossin wrote: > > On Wed Mar 26, 2025 at 5:57 PM CET, Tamir Duberstein wrote: > > > > > > In the current code you're looking at, yes. But in the code I have > > locally I'm transmuting `[u8]` to `BStr`. See my earlier

Re: [PATCH v7 7/7] rust: enable `clippy::ref_as_ptr` lint

2025-03-26 Thread Tamir Duberstein
On Wed, Mar 26, 2025 at 12:43 PM Benno Lossin wrote: > > On Wed Mar 26, 2025 at 11:35 AM CET, Tamir Duberstein wrote: > > On Wed, Mar 26, 2025 at 6:31 AM Benno Lossin wrote: > >> On Wed Mar 26, 2025 at 12:54 AM CET, Tamir Duberstein wrote: > >> > On Tue, Mar

Re: [PATCH v7 7/7] rust: enable `clippy::ref_as_ptr` lint

2025-03-26 Thread Tamir Duberstein
On Wed, Mar 26, 2025 at 6:31 AM Benno Lossin wrote: > > On Wed Mar 26, 2025 at 12:54 AM CET, Tamir Duberstein wrote: > > On Tue, Mar 25, 2025 at 6:40 PM Benno Lossin wrote: > >> On Tue Mar 25, 2025 at 11:33 PM CET, Tamir Duberstein wrote: > >> > On Tue, Mar

Re: [PATCH v7 0/7] rust: reduce `as` casts, enable related lints

2025-03-25 Thread Tamir Duberstein
On Tue, Mar 25, 2025 at 4:23 PM Miguel Ojeda wrote: > > On Tue, Mar 25, 2025 at 9:07 PM Tamir Duberstein wrote: > > > > Changes in v7: > > - Add patch to enable `clippy::ref_as_ptr`. > > - Link to v6: > > https://lore.kernel.org/r/20250324-ptr-as-ptr-v6-0-49

Re: [PATCH v7 7/7] rust: enable `clippy::ref_as_ptr` lint

2025-03-25 Thread Tamir Duberstein
On Tue, Mar 25, 2025 at 6:40 PM Benno Lossin wrote: > > On Tue Mar 25, 2025 at 11:33 PM CET, Tamir Duberstein wrote: > > On Tue, Mar 25, 2025 at 6:11 PM Benno Lossin wrote: > >> > >> On Tue Mar 25, 2025 at 9:07 PM CET, Tamir Duberstein wrote: > >> > dif

Re: [PATCH v7 7/7] rust: enable `clippy::ref_as_ptr` lint

2025-03-25 Thread Tamir Duberstein
On Tue, Mar 25, 2025 at 6:11 PM Benno Lossin wrote: > > On Tue Mar 25, 2025 at 9:07 PM CET, Tamir Duberstein wrote: > > diff --git a/rust/kernel/str.rs b/rust/kernel/str.rs > > index 40034f77fc2f..6233af50bab7 100644 > > --- a/rust/kernel/str.rs > > +++ b/rust/ke

[PATCH v7 6/7] rust: enable `clippy::cast_lossless` lint

2025-03-25 Thread Tamir Duberstein
d8ortxsutkgl.1kojagbm8f...@proton.me/ Reviewed-by: Benno Lossin Signed-off-by: Tamir Duberstein --- Makefile| 1 + drivers/gpu/drm/drm_panic_qr.rs | 10 +- rust/bindings/lib.rs| 1 + rust/kernel/net/phy.rs | 4 ++-- rust/uapi/lib.rs

[PATCH v7 5/7] rust: enable `clippy::as_underscore` lint

2025-03-25 Thread Tamir Duberstein
us apply the changes and enable the lint -- no functional change intended. Link: https://rust-lang.github.io/rust-clippy/master/index.html#as_underscore [1] Reviewed-by: Benno Lossin Signed-off-by: Tamir Duberstein --- Makefile | 1 + rust/kernel/block/mq/operati

  1   2   >