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

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

 



On Tue May 27, 2025 at 12:29 AM CEST, Tamir Duberstein wrote:
> On Mon, May 26, 2025 at 11:04 AM Benno Lossin <lossin@xxxxxxxxxx> 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.

There is one in this patch (:

    diff --git a/rust/kernel/kunit.rs b/rust/kernel/kunit.rs                                                                                     
    index e5621d596ed3..09148e982f48 100644                                                                                                      
    --- a/rust/kernel/kunit.rs                                                                                                                   
    +++ b/rust/kernel/kunit.rs                                                                                                                   
    @@ -58,9 +58,10 @@ macro_rules! kunit_assert {                                                                                               
                     break 'out;                                                                                                                 
                 }                                                                                                                               
                                                                                                                                                 
    -            static FILE: &'static $crate::str::CStr = $crate::c_str!($file);                                                                
    +            static FILE: &'static $crate::str::CStr = $crate::c_str_avoid_literals!($file);

---
Cheers,
Benno





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

  Powered by Linux