Skip to content

Commit b6ac322

Browse files
authored
Merge pull request #132 from Freax13/fix/getpriority
fix return value of getpriority
2 parents 019f335 + 2cb91d2 commit b6ac322

File tree

2 files changed

+7
-7
lines changed

2 files changed

+7
-7
lines changed

tee/kernel/src/user/process/syscall.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -3051,7 +3051,7 @@ fn getpriority(thread: &mut ThreadGuard, which: Which, who: u32) -> SyscallResul
30513051
let min = targets
30523052
.into_iter()
30533053
.map(|thread| thread.nice.load())
3054-
.min()
3054+
.max()
30553055
.unwrap();
30563056
Ok(min.as_syscall_return_value())
30573057
}

tee/kernel/src/user/process/syscall/args.rs

+6-6
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
use core::{
2-
cmp,
2+
cmp::{self, Reverse},
33
fmt::{self, Display},
44
marker::PhantomData,
55
net::{Ipv4Addr, SocketAddrV4},
@@ -1466,25 +1466,25 @@ enum_arg! {
14661466
}
14671467

14681468
#[derive(Clone, Copy, PartialEq, Eq, PartialOrd, Ord)]
1469-
pub struct Nice(i8);
1469+
pub struct Nice(Reverse<i8>);
14701470

14711471
impl Nice {
1472-
pub const DEFAULT: Self = Self(0);
1472+
pub const DEFAULT: Self = Self(Reverse(0));
14731473

14741474
pub fn get(&self) -> i8 {
1475-
self.0
1475+
self.0.0
14761476
}
14771477

14781478
pub fn as_syscall_return_value(self) -> u64 {
1479-
(self.0 + 21) as u64
1479+
(20 - self.get()) as u64
14801480
}
14811481
}
14821482

14831483
impl SyscallArg for Nice {
14841484
fn parse(value: u64, _: Abi) -> Result<Self> {
14851485
let value = value as u32 as i32;
14861486
ensure!((-20..=19).contains(&value), Inval);
1487-
Ok(Self(value as i8))
1487+
Ok(Self(Reverse(value as i8)))
14881488
}
14891489

14901490
fn display(f: &mut dyn fmt::Write, value: u64, _: Abi, _: &ThreadGuard<'_>) -> fmt::Result {

0 commit comments

Comments
 (0)