lkml.org 
[lkml]   [2023]   [Dec]   [8]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
/
Date
From
SubjectRe: [PATCH v2 5/7] rust: file: add `Kuid` wrapper
On 12/6/23 12:59, Alice Ryhl wrote:
> + /// Returns the given task's pid in the current pid namespace.
> + pub fn pid_in_current_ns(&self) -> Pid {
> + // SAFETY: Calling `task_active_pid_ns` with the current task is always safe.
> + let namespace = unsafe { bindings::task_active_pid_ns(bindings::get_current()) };

Why not create a safe wrapper for `bindings::get_current()`?
This patch series has three occurrences of `get_current`, so I think it
should be ok to add a wrapper.
I would also prefer to move the call to `bindings::get_current()` out of
the `unsafe` block.

> + // SAFETY: We know that `self.0.get()` is valid by the type invariant.

What about `namespace`?

--
Cheers,
Benno

> + unsafe { bindings::task_tgid_nr_ns(self.0.get(), namespace) }
> + }

\
 
 \ /
  Last update: 2023-12-08 17:42    [W:0.188 / U:1.900 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site