Thread (34 messages) 34 messages, 4 authors, 2025-05-29

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

From: "Benno Lossin" <lossin@kernel.org>
Date: 2025-05-26 23:03:39
Also in: dri-devel, linux-block, linux-devicetree, linux-kselftest, linux-pci, lkml, llvm, nouveau, rust-for-linux

On Tue May 27, 2025 at 12:24 AM CEST, Tamir Duberstein wrote:
On Mon, May 26, 2025 at 10:56 AM Benno Lossin [off-list ref] wrote:
quoted
On Sat May 24, 2025 at 10:33 PM CEST, Tamir Duberstein wrote:
quoted
`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's this supposed to mean?
It means that kernel::str::CStr was introduced before core::ffi:CStr
was available. I didn't check this before, but it is indeed true - see
https://github.com/Rust-for-Linux/linux/commit/faa3cbcca03d0dec8f8e43f1d8d5c0860d98a23f.
I see, then just write that and mention the commit.
quoted
quoted
C-String literals were added in Rust 1.77. Opportunistically replace
instances of `kernel::c_str!` with C-String literals where other code
changes were already necessary; the rest will be done in a later commit.
Similarly this, the message should explain the motivation for the
change, the change itself and can include additional information.
The motivation is implied (that using standard types is preferable to
having custom ones; this is also implicit rather than explicit in
https://github.com/Rust-for-Linux/linux/issues/1075), but I can
sharpen it.
Please add this information to the commit message.
quoted
quoted
Signed-off-by: Tamir Duberstein <redacted>
---
 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/kernel/miscdevice.rs       |   2 +-
 rust/kernel/net/phy.rs          |   2 +-
 rust/kernel/of.rs               |   2 +-
 rust/kernel/prelude.rs          |   5 +-
 rust/kernel/seq_file.rs         |   4 +-
 rust/kernel/str.rs              | 358 +++++++++-------------------------------
 rust/kernel/sync/condvar.rs     |   2 +-
 rust/kernel/sync/lock.rs        |   2 +-
 rust/kernel/sync/lock/global.rs |   2 +-
 14 files changed, 112 insertions(+), 294 deletions(-)
I'm a bit confused by some of the diffs here, they seem pretty messy,
any chance that they can be improved?
I'm open to suggestions. I think the confusion arises from git trying
to keep code from moving; fundamentally much of the change is moving
methods to an extension trait, which means git has to choose between
keeping the documentation where it is, or keeping the implementation
where it is. If I use `--patience` then everything moves together, but
then the diffstat swells. Thoughts?
I haven't viewed this patch with color-moved (since I haven't applied it
locally), I can try that first and see if it helps.

---
Cheers,
Benno
Keyboard shortcuts
hback out one level
jnext message in thread
kprevious message in thread
ldrill in
Escclose help / fold thread tree
?toggle this help