@@ -115,7 +115,7 @@ impl StdInput {
115115 /// The data you get might be cut in the middle of a UTF-8 character.
116116 fn get_data ( & mut self , buffer : & mut [ u8 ] ) -> usize {
117117 let count = self . get_buffered_data ( buffer) ;
118- if buffer. len ( ) == 0 || count > 0 {
118+ if buffer. is_empty ( ) || count > 0 {
119119 return count;
120120 }
121121
@@ -169,14 +169,14 @@ impl StdInput {
169169#[ macro_export]
170170macro_rules! osprint {
171171 ( $( $arg: tt) * ) => {
172- crate :: VGA_CONSOLE . with( |guard| {
172+ $ crate:: VGA_CONSOLE . with( |guard| {
173173 if let Some ( console) = guard. as_mut( ) {
174174 #[ allow( unused) ]
175175 use core:: fmt:: Write as _;
176176 write!( console, $( $arg) * ) . unwrap( ) ;
177177 }
178178 } ) . unwrap( ) ;
179- crate :: SERIAL_CONSOLE . with( |guard| {
179+ $ crate:: SERIAL_CONSOLE . with( |guard| {
180180 if let Some ( console) = guard. as_mut( ) {
181181 #[ allow( unused) ]
182182 use core:: fmt:: Write as _;
@@ -276,7 +276,11 @@ impl SerialConsole {
276276 fn read_data ( & mut self , buffer : & mut [ u8 ] ) -> Result < usize , bios:: Error > {
277277 let api = API . get ( ) ;
278278 let ffi_buffer = bios:: FfiBuffer :: new ( buffer) ;
279- let res = ( api. serial_read ) ( self . 0 , ffi_buffer, bios:: FfiOption :: Some ( bios:: Timeout :: new_ms ( 0 ) ) ) ;
279+ let res = ( api. serial_read ) (
280+ self . 0 ,
281+ ffi_buffer,
282+ bios:: FfiOption :: Some ( bios:: Timeout :: new_ms ( 0 ) ) ,
283+ ) ;
280284 res. into ( )
281285 }
282286}
@@ -377,17 +381,20 @@ pub extern "C" fn os_main(api: &bios::Api) -> ! {
377381 height as isize ,
378382 ) ;
379383 vga. clear ( ) ;
380- let mut guard = VGA_CONSOLE . try_lock ( ) . unwrap ( ) ;
384+ let mut guard = VGA_CONSOLE . lock ( ) ;
381385 * guard = Some ( vga) ;
386+ // Drop the lock before trying to grab it again to print something!
382387 drop ( guard) ;
383388 osprintln ! ( "\u{001b} [0mConfigured VGA console {}x{}" , width, height) ;
384389 }
385390 }
386391
387392 if let Some ( ( idx, serial_config) ) = config. get_serial_console ( ) {
388393 let _ignored = ( api. serial_configure ) ( idx, serial_config) ;
389- let mut guard = SERIAL_CONSOLE . try_lock ( ) . unwrap ( ) ;
394+ let mut guard = SERIAL_CONSOLE . lock ( ) ;
390395 * guard = Some ( SerialConsole ( idx) ) ;
396+ // Drop the lock before trying to grab it again to print something!
397+ drop ( guard) ;
391398 osprintln ! ( "Configured Serial console on Serial {}" , idx) ;
392399 }
393400
0 commit comments