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 4, 2024
1 parent f3bc6f9 commit f49a54b
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 @@ -169,7 +169,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) }
}
Expand Down

0 comments on commit f49a54b

Please sign in to comment.