cargo clippy & fmt

This commit is contained in:
Yifan Wu 2022-01-21 14:21:32 -08:00
parent 5e4e0c4fa6
commit ce80bc2bfd
25 changed files with 139 additions and 130 deletions

View file

@ -25,4 +25,4 @@ fn main() -> i32 {
println!("{}^{} = {}(MOD {})", p, iter, s[cur], m);
println!("Test power_3 OK!");
0
}
}

View file

@ -15,4 +15,4 @@ fn main() -> i32 {
}
println!("Test sleep OK!");
0
}
}

View file

@ -1,5 +1,5 @@
use core::fmt::{self, Write};
use super::write;
use core::fmt::{self, Write};
struct Stdout;
@ -28,4 +28,4 @@ macro_rules! println {
($fmt: literal $(, $($arg: tt)+)?) => {
$crate::console::print(format_args!(concat!($fmt, "\n") $(, $($arg)+)?));
}
}
}

View file

@ -2,9 +2,14 @@
fn panic_handler(panic_info: &core::panic::PanicInfo) -> ! {
let err = panic_info.message().unwrap();
if let Some(location) = panic_info.location() {
println!("Panicked at {}:{}, {}", location.file(), location.line(), err);
println!(
"Panicked at {}:{}, {}",
location.file(),
location.line(),
err
);
} else {
println!("Panicked: {}", err);
}
loop {}
}
}

View file

@ -4,8 +4,8 @@
#[macro_use]
pub mod console;
mod syscall;
mod lang_items;
mod syscall;
#[no_mangle]
#[link_section = ".text.entry"]
@ -26,14 +26,22 @@ fn clear_bss() {
fn start_bss();
fn end_bss();
}
(start_bss as usize..end_bss as usize).for_each(|addr| {
unsafe { (addr as *mut u8).write_volatile(0); }
(start_bss as usize..end_bss as usize).for_each(|addr| unsafe {
(addr as *mut u8).write_volatile(0);
});
}
use syscall::*;
pub fn write(fd: usize, buf: &[u8]) -> isize { sys_write(fd, buf) }
pub fn exit(exit_code: i32) -> isize { sys_exit(exit_code) }
pub fn yield_() -> isize { sys_yield() }
pub fn get_time() -> isize { sys_get_time() }
pub fn write(fd: usize, buf: &[u8]) -> isize {
sys_write(fd, buf)
}
pub fn exit(exit_code: i32) -> isize {
sys_exit(exit_code)
}
pub fn yield_() -> isize {
sys_yield()
}
pub fn get_time() -> isize {
sys_get_time()
}