lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <871qjhe9xh.fsf@metaspace.dk>
Date:   Mon, 15 May 2023 20:12:57 +0200
From:   Andreas Hindborg <nmi@...aspace.dk>
To:     Alice Ryhl <alice@...l.io>
Cc:     Gary Guo <gary@...yguo.net>, Miguel Ojeda <ojeda@...nel.org>,
        Wedson Almeida Filho <wedsonaf@...il.com>,
        Alex Gaynor <alex.gaynor@...il.com>,
        Boqun Feng <boqun.feng@...il.com>,
        Björn Roy Baron <bjorn3_gh@...tonmail.com>,
        Benno Lossin <benno.lossin@...ton.me>,
        Martin Rodriguez Reboredo <yakoyoku@...il.com>,
        rust-for-linux@...r.kernel.org, linux-kernel@...r.kernel.org,
        patches@...ts.linux.dev
Subject: Re: [PATCH v2] rust: str: add conversion from `CStr` to `CString`


Alice Ryhl <alice@...l.io> writes:

> On 5/8/23 13:41, Gary Guo wrote:
>> On Wed,  3 May 2023 14:10:16 +0000
>> Alice Ryhl <aliceryhl@...gle.com> wrote:
>> 
>>> These methods can be used to copy the data in a temporary c string into
>>> a separate allocation, so that it can be accessed later even if the
>>> original is deallocated.
>>>
>>> The API in this change mirrors the standard library API for the `&str`
>>> and `String` types. The `ToOwned` trait is not implemented because it
>>> assumes that allocations are infallible.
>> How about add a `TryToOwned` trait to the kernel crate and implement
>> that trait for `CStr` instead?
>
> Eh, I don't think it's worth it. It doesn't give anything new to the CStr api,
> and I think it's rather unlikely that someone will actually need to be generic
> over such a trait any time soon.

It is just as valid as having `From<&str>` and `ToOwned<&str>`. While it
does not add anything in terms of function, it carries intention. I
think we should consider adding it at some point.

BR Andreas

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ