File tree Expand file tree Collapse file tree 1 file changed +7
-4
lines changed
Expand file tree Collapse file tree 1 file changed +7
-4
lines changed Original file line number Diff line number Diff 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
8283fn 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
You can’t perform that action at this time.
0 commit comments