diff options
author | Dennis Kobert <dennis@kobert.dev> | 2019-11-07 16:04:32 +0100 |
---|---|---|
committer | Dennis Kobert <dennis@kobert.dev> | 2019-11-07 16:04:32 +0100 |
commit | e19c8879eb7732d3bcb62194065c9cb2892cf1ab (patch) | |
tree | 96a32d8aefd75262e10061b3bc0e29aa28c5afce | |
parent | 403c53fd6c7059c159db1604eb178251239fc4bf (diff) |
Minor Cleanups
-rw-r--r-- | kernel/src/io/serial.rs | 4 | ||||
-rw-r--r-- | kernel/src/lib.rs | 16 |
2 files changed, 5 insertions, 15 deletions
diff --git a/kernel/src/io/serial.rs b/kernel/src/io/serial.rs index 2a3bae8..eb9377c 100644 --- a/kernel/src/io/serial.rs +++ b/kernel/src/io/serial.rs @@ -32,9 +32,7 @@ impl core::fmt::Write for SerialStream { fn write_str(&mut self, s: &str) -> core::fmt::Result { let mut guard = CONNECTION.lock(); if !guard.initialized { - unsafe { - guard.port.init(); - } + guard.port.init(); guard.initialized = true; } guard.port.write_str(s) diff --git a/kernel/src/lib.rs b/kernel/src/lib.rs index 8d967ad..d5a3e9e 100644 --- a/kernel/src/lib.rs +++ b/kernel/src/lib.rs @@ -17,19 +17,12 @@ use io::{qemu, serial, vga_text}; pub fn test_runner(tests: &[&dyn Fn(&mut OStream)]) { let mut stdout = OStream::new(); stdout.clear(); - write!(&mut stdout, "running {} tests\n", tests.len()); + write!(&mut stdout, "running {} tests\n", tests.len()).unwrap(); for test in tests { test(&mut stdout) } } -#[test_case] -fn test01(stdout: &mut OStream) { - write!(stdout, "running test01 . . . OK"); - write!(serial::SerialStream::new(), "running test01 . . . OK\n"); - assert_eq!(0, 1); -} - #[no_mangle] pub extern "C" fn _start() -> ! { if cfg!(test) { @@ -40,8 +33,7 @@ pub extern "C" fn _start() -> ! { let mut stdout = OStream::new(); stdout.clear(); - - write!(&mut stdout, "hello world!"); + panic!("panic!"); core::iter::successors(Some(0), |n| Some(n + 1)) .for_each(|n| write!(&mut stdout, "hello world {}!", n).unwrap()); @@ -69,14 +61,14 @@ pub extern "C" fn panic_handler(_info: &core::panic::PanicInfo) -> ! { let text = _info .payload() .downcast_ref::<&str>() - .unwrap_or(&"no panic informations are obtainable"); + .unwrap_or(&"no panic information is obtainable"); stderr.set_state(vga_text::CharState::from_colors( vga_text::Color::Cyan, vga_text::Color::Red, )); stderr.print_centered(text.as_bytes()); if cfg!(test) { - write!(serial::SerialStream::new(), "Testing failed\n"); + write!(serial::SerialStream::new(), "Testing failed\n").unwrap(); qemu::exit_qemu(qemu::QemuExitCode::Failed); } loop {} |