Skip to content

Commit e90cdad

Browse files
committed
process/renice: cross-platform clippy fix
1 parent aa7f821 commit e90cdad

File tree

1 file changed

+7
-4
lines changed

1 file changed

+7
-4
lines changed

process/renice.rs

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -79,12 +79,13 @@ fn lookup_uid(username: &str) -> Result<u32, &'static str> {
7979
Ok(passwd.pw_uid)
8080
}
8181

82+
#[allow(clippy::unnecessary_cast)] // PRIO_* types differ: i32 on macOS, u32 on Linux
8283
fn parse_id(which: u32, input: &str) -> Result<u32, &'static str> {
8384
match input.parse::<u32>() {
8485
Ok(0) => Err("Invalid ID"),
8586
Ok(n) => Ok(n),
8687
Err(e) => {
87-
if which != libc::PRIO_USER {
88+
if which != libc::PRIO_USER as u32 {
8889
eprintln!("{}", e);
8990
Err("Invalid ID")
9091
} else {
@@ -108,13 +109,15 @@ fn main() -> Result<(), Box<dyn std::error::Error>> {
108109
let args = Args::parse();
109110

110111
// which class of priority to modify
112+
// Cast to u32 for cross-platform compatibility (i32 on macOS, u32 on Linux)
113+
#[allow(clippy::unnecessary_cast)]
111114
let which: u32 = {
112115
if args.pgrp {
113-
libc::PRIO_PGRP
116+
libc::PRIO_PGRP as u32
114117
} else if args.user {
115-
libc::PRIO_USER
118+
libc::PRIO_USER as u32
116119
} else {
117-
libc::PRIO_PROCESS
120+
libc::PRIO_PROCESS as u32
118121
}
119122
};
120123

0 commit comments

Comments
 (0)