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

Benno Lossin lossin at kernel.org
Wed May 28 15:34:53 UTC 2025


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 <lossin at kernel.org> 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 is useful from macros that have a normal string literal,
>> > but can't turn it into a `c""` one.
>> 
>> Uh, can you give an example? I'm not attached to the name.
>
> I also think it should be renamed. Right now it sounds like it creates a
> c string while avoiding literals in the input ... whatever that means.

Yeah that's a good way to put why the name is weird.

> I like Benno's suggestions, but str_to_cstr! could also work?

Hmm, I think then people won't know that it can also concat? I don't
think it matters too much, the macro probably won't be used that often
and if someone needs to use it, they probably wouldn't fine it by name
alone.

---
Cheers,
Benno


More information about the dri-devel mailing list