From 30022ea065ca8d8ef52a145d9615944b224d4236 Mon Sep 17 00:00:00 2001 From: Antonio Hickey Date: Thu, 4 Jan 2024 01:43:36 -0500 Subject: [PATCH] rust: task: use safe `current!` macro Refactor the `Task::pid_in_current_ns()` to use the safe abstraction `current!()` instead of the unsafe `bindings::get_current()` binding. Signed-off-by: Antonio Hickey --- rust/kernel/task.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/rust/kernel/task.rs b/rust/kernel/task.rs index d1d38eebbcc5fd..e5abf83f47b6c4 100644 --- a/rust/kernel/task.rs +++ b/rust/kernel/task.rs @@ -173,7 +173,7 @@ impl Task { /// 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()) }; + let namespace = unsafe { bindings::task_active_pid_ns(current!().as_raw()) }; // SAFETY: We know that `self.raw()` is valid by the type invariant. unsafe { bindings::task_tgid_nr_ns(self.as_raw(), namespace) } }