diff options
author | David Sherret <dsherret@users.noreply.github.com> | 2023-08-01 16:08:41 -0400 |
---|---|---|
committer | GitHub <noreply@github.com> | 2023-08-01 16:08:41 -0400 |
commit | 5e89d1a0ab7dd21ccabc91fb3226bab18a2bc18c (patch) | |
tree | 4ee9d9401ba3740c35cb5209091c4846ff120ac2 /ext/node/ops/os.rs | |
parent | 45572e329a395cb20ecb8c2867cc66b7d3a28cfe (diff) |
ci: lint on all operating systems (#20012)
Diffstat (limited to 'ext/node/ops/os.rs')
-rw-r--r-- | ext/node/ops/os.rs | 14 |
1 files changed, 9 insertions, 5 deletions
diff --git a/ext/node/ops/os.rs b/ext/node/ops/os.rs index 0a841a72a..59bfba4b8 100644 --- a/ext/node/ops/os.rs +++ b/ext/node/ops/os.rs @@ -4,9 +4,6 @@ use crate::NodePermissions; use deno_core::error::AnyError; use deno_core::op; use deno_core::OpState; -use errno::errno; -use errno::set_errno; -use errno::Errno; #[op] pub fn op_node_os_get_priority<P>( @@ -54,11 +51,12 @@ where Ok(whoami::username()) } -const PRIORITY_HIGH: i32 = -14; - #[cfg(unix)] mod priority { use super::*; + use errno::errno; + use errno::set_errno; + use errno::Errno; use libc::id_t; use libc::PRIO_PROCESS; @@ -69,6 +67,8 @@ mod priority { #[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 pub fn get_priority(pid: u32) -> Result<i32, AnyError> { set_errno(Errno(0)); @@ -119,10 +119,12 @@ mod priority { const PRIORITY_BELOW_NORMAL: i32 = 10; const PRIORITY_NORMAL: i32 = 0; const PRIORITY_ABOVE_NORMAL: i32 = -7; + const PRIORITY_HIGH: i32 = -14; const PRIORITY_HIGHEST: i32 = -20; // Ported from: https://github.com/libuv/libuv/blob/a877ca2435134ef86315326ef4ef0c16bdbabf17/src/win/util.c#L1649-L1685 pub fn get_priority(pid: u32) -> Result<i32, AnyError> { + // SAFETY: Windows API calls unsafe { let handle = if pid == 0 { GetCurrentProcess() @@ -150,6 +152,7 @@ mod priority { // Ported from: https://github.com/libuv/libuv/blob/a877ca2435134ef86315326ef4ef0c16bdbabf17/src/win/util.c#L1688-L1719 pub fn set_priority(pid: u32, priority: i32) -> Result<(), AnyError> { + // SAFETY: Windows API calls unsafe { let handle = if pid == 0 { GetCurrentProcess() @@ -159,6 +162,7 @@ mod priority { if handle == NULL { Err(std::io::Error::last_os_error().into()) } else { + #[allow(clippy::manual_range_contains)] let priority_class = if priority < PRIORITY_HIGHEST || priority > PRIORITY_LOW { return Err(type_error("Invalid priority")); |