Skip to content

Commit

Permalink
changed syscall return value from i64 to isize
Browse files Browse the repository at this point in the history
  • Loading branch information
schoettner committed Sep 10, 2024
1 parent 0cd69e1 commit 313c873
Show file tree
Hide file tree
Showing 4 changed files with 10 additions and 10 deletions.
2 changes: 1 addition & 1 deletion os/kernel/src/syscall/sys_naming.rs
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ pub fn sys_mkentry(
name_buff: *const u8,
name_buff_len: usize,
data: usize,

Check warning on line 23 in os/kernel/src/syscall/sys_naming.rs

View workflow job for this annotation

GitHub Actions / build-on-linux

unused variable: `data`

Check warning on line 23 in os/kernel/src/syscall/sys_naming.rs

View workflow job for this annotation

GitHub Actions / build-on-apple-silicon-mac

unused variable: `data`

Check warning on line 23 in os/kernel/src/syscall/sys_naming.rs

View workflow job for this annotation

GitHub Actions / build-on-intel-mac

unused variable: `data`

Check warning on line 23 in os/kernel/src/syscall/sys_naming.rs

View workflow job for this annotation

GitHub Actions / build-on-apple-silicon-mac

unused variable: `data`

Check warning on line 23 in os/kernel/src/syscall/sys_naming.rs

View workflow job for this annotation

GitHub Actions / build-on-linux

unused variable: `data`

Check warning on line 23 in os/kernel/src/syscall/sys_naming.rs

View workflow job for this annotation

GitHub Actions / build-on-intel-mac

unused variable: `data`
) -> i64 {
) -> isize {
let path = from_utf8(unsafe {
slice_from_raw_parts(path_buff, path_buff_len)
.as_ref()
Expand Down
2 changes: 1 addition & 1 deletion os/library/naming/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@

use syscall::{return_vals::Errno, syscall, SystemCall};

pub fn mkentry(path: &str, name: &str, data: usize) -> Result<u64, Errno> {
pub fn mkentry(path: &str, name: &str, data: usize) -> Result<usize, Errno> {
// Check if params are valid
if path.is_empty() || name.is_empty() {
Err(Errno::EINVAL) // Abort, if not
Expand Down
6 changes: 3 additions & 3 deletions os/library/syscall/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
╟─────────────────────────────────────────────────────────────────────────╢
║ Descr.: Syscall interface in user mode. ║
╟─────────────────────────────────────────────────────────────────────────╢
║ Author: Fabian Ruhland, Michael Schoettner, 30.8.2024, HHU
║ Author: Fabian Ruhland, Michael Schoettner, 10.09.2024, HHU ║
╚═════════════════════════════════════════════════════════════════════════╝
*/
#![no_std]
Expand Down Expand Up @@ -49,7 +49,7 @@ pub const NUM_SYSCALLS: usize = SystemCall::LastEntryMarker as usize;
/// success >= 0 \
/// error, codes defined in consts.rs
pub fn syscall(call: SystemCall, args: &[usize]) -> SyscallResult {
let ret_code: i64;
let ret_code: isize;

if args.len() > 6 {
panic!("System calls with more than 6 params are not supported.");
Expand Down Expand Up @@ -77,5 +77,5 @@ pub fn syscall(call: SystemCall, args: &[usize]) -> SyscallResult {
clobber_abi("system"));
}

convert_ret_code_to_syscall_result(ret_code)
convert_ret_code_to_syscall_result(ret_code.try_into().unwrap())
}
10 changes: 5 additions & 5 deletions os/library/syscall/src/return_vals.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
╟─────────────────────────────────────────────────────────────────────────╢
║ Descr.: Consts and types for syscall return values. ║
╟─────────────────────────────────────────────────────────────────────────╢
║ Author: Michael Schoettner, 31.8.2024, HHU
║ Author: Michael Schoettner, 10.09.2024, HHU ║
╚═════════════════════════════════════════════════════════════════════════╝
*/

Expand All @@ -22,23 +22,23 @@ pub enum Errno {
ENOTEMPTY = -90, // Directory not empty
}

pub type SyscallResult = ::core::result::Result<u64, Errno>;
pub type SyscallResult = ::core::result::Result<usize, Errno>;

pub fn convert_ret_code_to_syscall_result(ret_code: i64) -> SyscallResult {
if ret_code < 0 {
return Err(Errno::from(ret_code));
} else {
return Ok(ret_code as u64);
return Ok(ret_code as usize);
}
}

pub fn convert_syscall_result_to_ret_code(syscall_result: SyscallResult) -> i64 {
pub fn convert_syscall_result_to_ret_code(syscall_result: SyscallResult) -> isize {
let ret_val: i64;
match syscall_result {
Ok(t) => ret_val = t as i64,
Err(e) => ret_val = e.into(),
}
ret_val
ret_val as isize
}


0 comments on commit 313c873

Please sign in to comment.