Re: [PATCH RESEND v5] rust: str: Use `core::CStr`, remove the custom `CStr` implementation

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Wed, Aug 21, 2024 at 2:08 PM Alice Ryhl <aliceryhl@xxxxxxxxxx> wrote:
>
> On Mon, Aug 19, 2024 at 5:39 PM Michal Rostecki <vadorovsky@xxxxxxxxx> wrote:
> >
> > From: Michal Rostecki <vadorovsky@xxxxxxxxx>
> >
> > `CStr` became a part of `core` library in Rust 1.75. This change replaces
> > the custom `CStr` implementation with the one from `core`.
> >
> > `core::CStr` behaves generally the same as the removed implementation,
> > with the following differences:
> >
> > - It does not implement `Display`.
> > - It does not provide `from_bytes_with_nul_unchecked_mut` method.
> > - It has `as_ptr()` method instead of `as_char_ptr()`, which also returns
> >   `*const c_char`.
> >
> > The first two differences are handled by providing the `CStrExt` trait,
> > with `display()` and `from_bytes_with_nul_unchecked_mut()` methods.
> > `display()` returns a `CStrDisplay` wrapper, with a custom `Display`
> > implementation.
> >
> > `DerefMut` implementation for `CString` is removed here, as it's not
> > being used anywhere.
> >
> > Signed-off-by: Michal Rostecki <vadorovsky@xxxxxxxxx>
>
> A few comments:
>
> * I would probably add CStrExt to the kernel prelude.
> * I would probably remove `from_bytes_with_nul_unchecked_mut` and keep
> `DerefMut for CString` instead of the other way around.
> * Perhaps we should remove the `c_str!` macro and use c"" instead?

Ah, also, please add this tag:

Closes: https://github.com/Rust-for-Linux/linux/issues/1075

Alice





[Index of Archives]     [Linux Wireless]     [Linux Kernel]     [ATH6KL]     [Linux Bluetooth]     [Linux Netdev]     [Kernel Newbies]     [Share Photos]     [IDE]     [Security]     [Git]     [Netfilter]     [Bugtraq]     [Yosemite News]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Linux ATA RAID]     [Samba]     [Device Mapper]

  Powered by Linux