Skip to content

Commit 321bd4d

Browse files
committed
move <u32 as SyscallArg> impl
1 parent 9a819ad commit 321bd4d

File tree

2 files changed

+16
-20
lines changed

2 files changed

+16
-20
lines changed

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

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -323,6 +323,21 @@ impl SyscallArg for i64 {
323323
}
324324
}
325325

326+
impl SyscallArg for u32 {
327+
fn parse(value: u64, _abi: Abi) -> Result<Self> {
328+
Ok(value as u32)
329+
}
330+
331+
fn display(
332+
f: &mut dyn fmt::Write,
333+
value: u64,
334+
abi: Abi,
335+
_thread: &ThreadGuard<'_>,
336+
) -> fmt::Result {
337+
write!(f, "{}", Self::parse(value, abi).unwrap())
338+
}
339+
}
340+
326341
impl SyscallArg for i32 {
327342
fn parse(value: u64, _abi: Abi) -> Result<Self> {
328343
Ok(value as u32 as i32)

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

Lines changed: 1 addition & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ use crate::{
1717
error::{Result, err},
1818
per_cpu::PerCpu,
1919
user::{
20-
syscall::{SYSCALL_HANDLERS, args::SyscallArg},
20+
syscall::SYSCALL_HANDLERS,
2121
thread::{Thread, ThreadGuard},
2222
},
2323
};
@@ -40,25 +40,6 @@ pub enum Abi {
4040

4141
pub type SyscallResult = Result<u64>;
4242

43-
impl SyscallArg for u32 {
44-
fn parse(value: u64, _abi: Abi) -> Result<Self> {
45-
Ok(u32::try_from(value)?)
46-
}
47-
48-
fn display(
49-
f: &mut dyn fmt::Write,
50-
value: u64,
51-
_abi: Abi,
52-
_thread: &ThreadGuard<'_>,
53-
) -> fmt::Result {
54-
if let Ok(value) = u32::try_from(value) {
55-
write!(f, "{value}")
56-
} else {
57-
write!(f, "{value} (out of bounds)")
58-
}
59-
}
60-
}
61-
6243
pub trait Syscall {
6344
const NO_I386: Option<usize>;
6445
const NO_AMD64: Option<usize>;

0 commit comments

Comments
 (0)