diff options
author | Jakub Jirutka <jakub@jirutka.cz> | 2023-09-01 11:21:23 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2023-09-01 11:21:23 +0200 |
commit | 3436f65e20bd612fdfb8bdee5c20f52fbd11b21a (patch) | |
tree | a74ca7c99eed867c0560cd6122436d1462483deb /ext/node | |
parent | cd0fcc2257198e33c319555091b7081dc8387c8d (diff) |
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 in aa8078b6888ee4d55ef348e336e076676dffc25f by
@crowlKats.
Relevant sources:
-
https://github.com/rust-lang/libc/blob/835661543db1ec42a6d9a809d69c3c5b5b978b81/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>
Diffstat (limited to 'ext/node')
-rw-r--r-- | ext/node/ops/os.rs | 17 |
1 files changed, 2 insertions, 15 deletions
diff --git a/ext/node/ops/os.rs b/ext/node/ops/os.rs index 44ff0a3a7..7dc1a7684 100644 --- a/ext/node/ops/os.rs +++ b/ext/node/ops/os.rs @@ -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(()), } |