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

From: Gary Guo
Date: Fri Feb 21 2025 - 09:28:32 EST


On Wed, 19 Feb 2025 14:21:35 +0000
Alice Ryhl <aliceryhl@xxxxxxxxxx> wrote:

> On Tue, Feb 18, 2025 at 5:05 PM Tamir Duberstein <tamird@xxxxxxxxx> wrote:
> >
> > Gentle ping. Trevor, Alice, Benno: you all participated in the last
> > round of review - I'd appreciate it if you could take a look at this
> > series.
>
> The primary thing that comes to mind looking at this is that losing
> the Display impl is pretty sad. Having to jump through hoops every
> time you want to print a string isn't great :(
>
> Alice

I'd want to add that we currently also have our own `BStr` and then we
have the `CStr` -> `BStr` -> `[u8]` deref chain which is quite often
useful. If we move to the `core::ffi::CStr` then we would lose ability
to do so.

The `BStr` is quite useful as a thin layer on `[u8]` to give a
semantical meaning that this is supposed to be printable, user-facing
string, but it isn't always UTF-8.

Best,
Gary