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

2025-03-25 Thread Tamir Duberstein
On Tue, Mar 25, 2025 at 6:40 AM Benno Lossin wrote: > > On Mon Mar 24, 2025 at 11:01 PM CET, 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, in

[PATCH v6 5/6] rust: enable `clippy::as_underscore` lint

2025-03-24 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 v6 0/6] rust: reduce `as` casts, enable related lints

2025-03-24 Thread Tamir Duberstein
x27;t missed. The first commit reduces the need for pointer casts and is shared with another series[1]. As a late addition, `clippy::cast_lossless` is also enabled. Link: https://lore.kernel.org/all/20250307-no-offset-v1-0-0c728f63b...@gmail.com/ [1] Signed-off-by: Tamir Duberstein --- Changes

[PATCH v6 2/6] rust: enable `clippy::ptr_as_ptr` lint

2025-03-24 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 v6 1/6] rust: retain pointer mut-ness in `container_of!`

2025-03-24 Thread Tamir Duberstein
example of this was in the macro's own doctest. Reviewed-by: Benno Lossin Reviewed-by: Alice Ryhl Signed-off-by: Tamir Duberstein --- rust/kernel/lib.rs | 5 ++--- rust/kernel/pci.rs | 2 +- rust/kernel/platform.rs | 2 +- rust/kernel/rbtree.rs | 23 ++- 4

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

2025-03-24 Thread Tamir Duberstein
d8ortxsutkgl.1kojagbm8f...@proton.me/ Signed-off-by: Tamir Duberstein --- Makefile| 1 + drivers/gpu/drm/drm_panic_qr.rs | 10 +- rust/bindings/lib.rs| 2 +- rust/kernel/net/phy.rs | 4 ++-- 4 files changed, 9 insertions(+), 8 deletions(-)

[PATCH v6 4/6] rust: enable `clippy::as_ptr_cast_mut` lint

2025-03-24 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 c62bae2b107b..bb15b86182a3 100644 --- a/Makefile +++ b/Makefile @@

[PATCH v6 3/6] rust: enable `clippy::ptr_cast_constness` lint

2025-03-24 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

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

2025-03-17 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 v9 4/4] rust: remove core::ffi::CStr reexport

2025-03-17 Thread Tamir Duberstein
Clean up references to `kernel::str::CStr`. Signed-off-by: Tamir Duberstein --- drivers/gpu/drm/drm_panic_qr.rs | 4 ++-- drivers/net/phy/ax88796b_rust.rs | 1 + drivers/net/phy/qt2025.rs| 1 + rust/kernel/device.rs| 3 +-- rust/kernel/driver.rs| 4

[PATCH v9 0/4] rust: replace kernel::str::CStr w/ core::ffi::CStr

2025-03-17 Thread Tamir Duberstein
inux/linux/issues/1075 Signed-off-by: Tamir Duberstein --- Changes in v9: - Rebase on rust-next. - Restore `impl Display for BStr` which exists upstream[1]. - Link: https://doc.rust-lang.org/nightly/std/bstr/struct.ByteStr.html#impl-Display-for-ByteStr [1] - Link to v8: https://lore.kernel.org/r/202

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

2025-03-19 Thread Tamir Duberstein
On Wed, Mar 19, 2025 at 12:06 PM Miguel Ojeda wrote: > > On Wed, Mar 19, 2025 at 4:59 PM Tamir Duberstein wrote: > > > > If we're talking about the same thing then I think we're both wrong > > and the correct phrasing would have been: "yo

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

2025-03-19 Thread Tamir Duberstein
On Wed, Mar 19, 2025 at 12:43 PM Miguel Ojeda wrote: > > On Wed, Mar 19, 2025 at 5:13 PM Tamir Duberstein wrote: > > > > No, I meant avoiding the check. The existing code already explicitly > > checks `new_len > self.len()` before evaluating `new_len - > >

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-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

[PATCH v7 2/7] rust: enable `clippy::ptr_as_ptr` lint

2025-03-25 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 v7 1/7] rust: retain pointer mut-ness in `container_of!`

2025-03-25 Thread Tamir Duberstein
example of this was in the macro's own doctest. Reviewed-by: Benno Lossin Reviewed-by: Alice Ryhl Signed-off-by: Tamir Duberstein --- rust/kernel/lib.rs | 5 ++--- rust/kernel/pci.rs | 2 +- rust/kernel/platform.rs | 2 +- rust/kernel/rbtree.rs | 23 ++- 4

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

2025-03-25 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 | 4 ++-- rust/kernel/uaccess.rs | 5 +++-- rust/uapi/lib.rs | 1 + 7 files changed, 12 insertio

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

2025-03-25 Thread Tamir Duberstein
sage. - 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 (7): rust: retain pointer mut-ness in `container_of!` rust: enable `clippy::ptr_as_ptr` lint rust: e

[PATCH v7 4/7] rust: enable `clippy::as_ptr_cast_mut` lint

2025-03-25 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 c62bae2b107b..bb15b86182a3 100644 --- a/Makefile +++ b/Makefile @@

[PATCH v7 3/7] rust: enable `clippy::ptr_cast_constness` lint

2025-03-25 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

[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

[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

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

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 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 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 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 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 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-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

[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 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 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 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 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 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 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

[PATCH v9 2/4] rust: replace `CStr` with `core::ffi::CStr`

2025-03-17 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 | 8 +- rust/kernel/kunit.rs| 4 +- rust

[PATCH v9 1/4] rust: move `CStr`'s `Display` to helper struct

2025-03-17 Thread Tamir Duberstein
icode data. Signed-off-by: Tamir Duberstein --- rust/kernel/kunit.rs | 9 +--- rust/kernel/str.rs | 63 ++-- 2 files changed, 57 insertions(+), 15 deletions(-) diff --git a/rust/kernel/kunit.rs b/rust/kernel/kunit.rs index 824da0e

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 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 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 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-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

[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

[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 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 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

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

[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

[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 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 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 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 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

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.

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

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 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

[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

Re: [PATCH v2 3/5] rust: add #[export] macro

2025-02-28 Thread Tamir Duberstein
+/// * Verifies at compile-time that the function signature matches the > declaration in the header > +/// file. > +/// > +/// You must declare the signature of the Rust function in a header file > that is included by > +/// `rust/bindings/bindings_helper.h`. > +/// > +/// This macro is *not* the same as the C macros `EXPORT_SYMBOL_*`, since > all Rust symbols are > +/// currently automatically exported with `EXPORT_SYMBOL_GPL`. nit: "since" implies causation, which isn't the case, I think. Consider if ", since" can be replaced with a semicolon. > +#[proc_macro_attribute] > +pub fn export(attr: TokenStream, ts: TokenStream) -> TokenStream { > +export::export(attr, ts) > +} > + > /// Concatenate two identifiers. > /// > /// This is useful in macros that need to declare or reference items with > names > > -- > 2.48.1.711.g2feabab25a-goog Minor comments. Reviewed-by: Tamir Duberstein

Re: [PATCH v2 4/5] print: use new #[export] macro for rust_fmt_argument

2025-02-28 Thread Tamir Duberstein
> // Called from `vsprintf` with format specifier `%pA`. > #[expect(clippy::missing_safety_doc)] > -#[no_mangle] > +#[export] > unsafe extern "C" fn rust_fmt_argument( > buf: *mut c_char, > end: *mut c_char, > > -- > 2.48.1.711.g2feabab25a-goog Reviewed-by: Tamir Duberstein

Re: [PATCH v2 5/5] panic_qr: use new #[export] macro

2025-02-28 Thread Tamir Duberstein
ings/bindings_helper.h b/rust/bindings/bindings_helper.h > index 55354e4dec14..5345aa93fb8a 100644 > --- a/rust/bindings/bindings_helper.h > +++ b/rust/bindings/bindings_helper.h > @@ -36,6 +36,10 @@ > #include > #include > > +#if defined(CONFIG_DRM_PANIC_SCREEN_QR_CODE) > +#include > +#endif Why the guard here? It'd be nice to have a comment here explaining the atypical need for this include. > + > /* `bindgen` gets confused at certain things. */ > const size_t RUST_CONST_HELPER_ARCH_SLAB_MINALIGN = ARCH_SLAB_MINALIGN; > const size_t RUST_CONST_HELPER_PAGE_SIZE = PAGE_SIZE; > > -- > 2.48.1.711.g2feabab25a-goog With Andy's comment about extern addressed: Reviewed-by: Tamir Duberstein

Re: [PATCH v2 2/5] rust: macros: support additional tokens in quote!

2025-02-28 Thread Tamir Duberstein
:tt)*) => { > +$v.push(::proc_macro::TokenTree::Ident(::proc_macro::Ident::new("_", > $span))); > + quote_spanned!(@proc $v $span $($tt)*); > +}; > (@proc $v:ident $span:ident $id:ident $($tt:tt)*) => { > > $v.push(::proc_macro::TokenTree::Ident(::proc_macro::Ident::new(stringify!($id), > $span))); > quote_spanned!(@proc $v $span $($tt)*); > > -- > 2.48.1.711.g2feabab25a-goog Reviewed-by: Tamir Duberstein

Re: [PATCH v2 3/5] rust: add #[export] macro

2025-02-28 Thread Tamir Duberstein
On Fri, Feb 28, 2025 at 10:49 AM Miguel Ojeda wrote: > > On Fri, Feb 28, 2025 at 4:41 PM Tamir Duberstein wrote: > > > > This needs an update given Miguel's comments on the cover letter. I > > wonder if the code should also justify the choice (over cbindgen). &g

Re: [PATCH v2 5/5] panic_qr: use new #[export] macro

2025-02-28 Thread Tamir Duberstein
On Fri, Feb 28, 2025 at 12:08 PM Alice Ryhl wrote: > > On Fri, Feb 28, 2025 at 4:55 PM Tamir Duberstein wrote: > > > > On Fri, Feb 28, 2025 at 7:41 AM Alice Ryhl wrote: > > > > > > @@ -980,8 +983,12 @@ fn draw_all(&mut self, data: impl Iterator > >

Re: [PATCH v2 1/5] rust: fix signature of rust_fmt_argument

2025-02-28 Thread Tamir Duberstein
tps://docs.kernel.org/core-api/printk-basics.html> > > -use core::{ > +use crate::{ > ffi::{c_char, c_void}, > -fmt, > +str::RawFormatter, > }; > - > -use crate::str::RawFormatter; > +use core::fmt; > > // Called from `vsprintf` with format specifier `%pA`. > #[expect(clippy::missing_safety_doc)] > > -- > 2.48.1.711.g2feabab25a-goog Reviewed-by: Tamir Duberstein

Re: [PATCH RESEND v3] drm/xe: xe_gen_wa_oob: replace program_invocation_short_name

2025-02-28 Thread Tamir Duberstein
Hi Lucas, chiming in here since I also care about building on macOS. On Mon, Feb 24, 2025 at 10:05 AM Lucas De Marchi wrote: > > Is this the approach taken for other similar issues you had? Note that > argv[0] and program_invocation_short_name are not the same thing. For > this particular binary

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

2025-03-19 Thread Tamir Duberstein
On Tue, Mar 18, 2025 at 8:50 PM Benno Lossin wrote: > > On Tue Mar 18, 2025 at 9:12 PM CET, Tamir Duberstein wrote: > > On Sun, Mar 16, 2025 at 7:17 AM Andrew Ballance > > wrote: > >> +pub fn resize(&mut self, new_len: usize, value: T, flags: Flags)

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

2025-03-19 Thread Tamir Duberstein
On Wed, Mar 19, 2025 at 10:34 AM Benno Lossin wrote: > > On Wed Mar 19, 2025 at 2:42 PM CET, Tamir Duberstein wrote: > > On Tue, Mar 18, 2025 at 8:50 PM Benno Lossin wrote: > >> > >> On Tue Mar 18, 2025 at 9:12 PM CET, Tamir Duberstein wrote: > >> &

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

[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

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

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 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 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 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

[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 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 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 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

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 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 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 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 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 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 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 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 >

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 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 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

[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

  1   2   3   >