Skip to content

Commit

Permalink
rust: task: use safe current! macro
Browse files Browse the repository at this point in the history
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]>
  • Loading branch information
antonio-hickey committed Jan 3, 2024
1 parent 8f7e376 commit c1a0671
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion rust/kernel/task.rs
Original file line number Diff line number Diff line change
Expand Up @@ -164,7 +164,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!()) };
// SAFETY: We know that `self.0.get()` is valid by the type invariant.
unsafe { bindings::task_tgid_nr_ns(self.0.get(), namespace) }
}
Expand Down

0 comments on commit c1a0671

Please sign in to comment.