[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <20231211153429.4161511-1-aliceryhl@google.com>
Date: Mon, 11 Dec 2023 15:34:29 +0000
From: Alice Ryhl <aliceryhl@...gle.com>
To: boqun.feng@...il.com
Cc: a.hindborg@...sung.com, alex.gaynor@...il.com,
aliceryhl@...gle.com, arve@...roid.com, benno.lossin@...ton.me,
bjorn3_gh@...tonmail.com, brauner@...nel.org, cmllamas@...gle.com,
dan.j.williams@...el.com, dxu@...uu.xyz, gary@...yguo.net,
gregkh@...uxfoundation.org, joel@...lfernandes.org,
keescook@...omium.org, linux-fsdevel@...r.kernel.org,
linux-kernel@...r.kernel.org, maco@...roid.com, ojeda@...nel.org,
peterz@...radead.org, rust-for-linux@...r.kernel.org,
surenb@...gle.com, tglx@...utronix.de, tkjos@...roid.com,
viro@...iv.linux.org.uk, wedsonaf@...il.com, willy@...radead.org
Subject: Re: [PATCH v2 2/7] rust: cred: add Rust abstraction for `struct cred`
Boqun Feng <boqun.feng@...il.com> writes:
> On Wed, Dec 06, 2023 at 11:59:47AM +0000, Alice Ryhl wrote:
> [...]
> > @@ -151,6 +152,21 @@ pub fn as_ptr(&self) -> *mut bindings::file {
> > self.0.get()
> > }
> >
> > + /// Returns the credentials of the task that originally opened the file.
> > + pub fn cred(&self) -> &Credential {
>
> I wonder whether it would be helpful if we use explicit lifetime here:
>
> pub fn cred<'file>(&'file self) -> &'file Credential
>
> It might be easier for people to get. For example, the lifetime of the
> returned Credential reference is constrainted by 'file, the lifetime of
> the file reference.
>
> But yes, maybe need to hear others' feedback first.
>
> Regards,
> Boqun
That would trigger a compiler warning because the lifetime is
unnecessary.
The safety comment explains what the signature means. I think that
should be enough.
Alice
Powered by blists - more mailing lists