Closed
Description
This issue is for version 0.2.70
compiling for x86_64-unknown-linux-gnu
on 5.1.18-200.fc29.x86_64
The function signatures of getpriority
and setpriority
are defined as such:
pub fn getpriority(which: ::__priority_which_t, who: ::id_t) -> ::c_int;
pub fn setpriority(
which: ::__priority_which_t,
who: ::id_t,
prio: ::c_int,
) -> ::c_int;
The issue is the first argument, which
is defined as a __priority_which_t
(a c_uint) however, the which
constants (PRIO_PROCESS
, etc) are defined as c_int.
So passing PRIO_PROCESS
to either function results in a compiler error:
error[E0308]: mismatched types
--> src/main.rs:6:34
|
6 | let result = getpriority(PRIO_PROCESS, pid);
| ^^^^^^^^^^^^ expected `u32`, found `i32`
|
help: you can convert an `i32` to `u32` and panic if the converted value wouldn't fit
|
6 | let result = getpriority(PRIO_PROCESS.try_into().unwrap(), pid);
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
Here's my code to reproduce the issue:
use libc::{getpriority, PRIO_PROCESS, id_t};
fn main() {
let pid: id_t = 0;
unsafe {
let result = getpriority(PRIO_PROCESS, pid);
println!("{}", result);
}
}
Please let me know if there is anything else I can provide to help.
Metadata
Metadata
Assignees
Labels
No labels