Skip to content

Commit b54bde5

Browse files
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 <[email protected]>
1 parent f3bc6f9 commit b54bde5

File tree

1 file changed

+2
-1
lines changed

1 file changed

+2
-1
lines changed

rust/kernel/task.rs

+2-1
Original file line numberDiff line numberDiff line change
@@ -168,8 +168,9 @@ impl Task {
168168

169169
/// Returns the given task's pid in the current pid namespace.
170170
pub fn pid_in_current_ns(&self) -> Pid {
171+
let current = current!();
171172
// SAFETY: Calling `task_active_pid_ns` with the current task is always safe.
172-
let namespace = unsafe { bindings::task_active_pid_ns(bindings::get_current()) };
173+
let namespace = unsafe { bindings::task_active_pid_ns(current.as_raw()) };
173174
// SAFETY: We know that `self.raw()` is valid by the type invariant.
174175
unsafe { bindings::task_tgid_nr_ns(self.as_raw(), namespace) }
175176
}

0 commit comments

Comments
 (0)