mirror of
https://github.com/denoland/deno.git
synced 2024-12-22 07:14:47 -05:00
fix(ext/node): remove unnecessary and incorrect type priority_t (#20276)
`getpriority` and `setpriority` on musl libc accepts `int` / `c_int` / `i32` as the first argument, not `u32`. Since the `PRIO_PROCESS` constant is imported from the same crate (libc) as the `getpriority` and `setpriority` functions, this type cast seems to be completely unnecessary here. It was introduced inaa8078b688
by @crowlKats. Relevant sources: -835661543d/src/unix/linux_like/linux/musl/mod.rs (L739-L740)
- https://git.musl-libc.org/cgit/musl/tree/src/misc/setpriority.c - https://git.musl-libc.org/cgit/musl/tree/src/misc/getpriority.c Co-authored-by: Aapo Alasuutari <aapo.alasuutari@gmail.com>
This commit is contained in:
parent
cd0fcc2257
commit
3436f65e20
1 changed files with 2 additions and 15 deletions
|
@ -60,17 +60,6 @@ mod priority {
|
|||
use libc::id_t;
|
||||
use libc::PRIO_PROCESS;
|
||||
|
||||
#[cfg(any(
|
||||
target_os = "macos",
|
||||
target_os = "freebsd",
|
||||
target_os = "openbsd"
|
||||
))]
|
||||
#[allow(non_camel_case_types)]
|
||||
type priority_t = i32;
|
||||
#[cfg(target_os = "linux")]
|
||||
#[allow(non_camel_case_types)]
|
||||
type priority_t = u32;
|
||||
|
||||
const PRIORITY_HIGH: i32 = -14;
|
||||
|
||||
// Ref: https://github.com/libuv/libuv/blob/55376b044b74db40772e8a6e24d67a8673998e02/src/unix/core.c#L1533-L1547
|
||||
|
@ -78,7 +67,7 @@ mod priority {
|
|||
set_errno(Errno(0));
|
||||
match (
|
||||
// SAFETY: libc::getpriority is unsafe
|
||||
unsafe { libc::getpriority(PRIO_PROCESS as priority_t, pid as id_t) },
|
||||
unsafe { libc::getpriority(PRIO_PROCESS, pid as id_t) },
|
||||
errno(),
|
||||
) {
|
||||
(-1, Errno(0)) => Ok(PRIORITY_HIGH),
|
||||
|
@ -89,9 +78,7 @@ mod priority {
|
|||
|
||||
pub fn set_priority(pid: u32, priority: i32) -> Result<(), AnyError> {
|
||||
// SAFETY: libc::setpriority is unsafe
|
||||
match unsafe {
|
||||
libc::setpriority(PRIO_PROCESS as priority_t, pid as id_t, priority)
|
||||
} {
|
||||
match unsafe { libc::setpriority(PRIO_PROCESS, pid as id_t, priority) } {
|
||||
-1 => Err(std::io::Error::last_os_error().into()),
|
||||
_ => Ok(()),
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue