From 3779e81b203c90d06626afcbc13ceb050d0e4e02 Mon Sep 17 00:00:00 2001 From: Julian Stecklina Date: Fri, 25 Nov 2022 18:08:54 +0100 Subject: [PATCH] lanzaboote: handle errors in print_logo --- rust/lanzaboote/src/main.rs | 19 +++++++++---------- 1 file changed, 9 insertions(+), 10 deletions(-) diff --git a/rust/lanzaboote/src/main.rs b/rust/lanzaboote/src/main.rs index 2dac3a8..485b9b2 100644 --- a/rust/lanzaboote/src/main.rs +++ b/rust/lanzaboote/src/main.rs @@ -17,7 +17,7 @@ use uefi::{ loaded_image::LoadedImage, media::file::{File, FileAttribute, FileMode, RegularFile}, }, - CString16, Error, + CString16, Result, }; use crate::{ @@ -25,12 +25,12 @@ use crate::{ uefi_helpers::{booted_image_cmdline, booted_image_file, read_all}, }; -fn print_logo(output: &mut Output) { - output.clear().unwrap(); +/// Print the startup logo on boot. +fn print_logo(output: &mut Output) -> Result<()> { + output.clear()?; - output - .output_string(cstr16!( - " + output.output_string(cstr16!( + " _ _ _\r | | | | | |\r | | __ _ _ __ ______ _| |__ ___ ___ | |_ ___\r @@ -39,8 +39,7 @@ fn print_logo(output: &mut Output) { |_|\\__,_|_| |_/___\\__,_|_.__/ \\___/ \\___/ \\__\\___|\r \r " - )) - .unwrap(); + )) } /// The configuration that is embedded at build time. @@ -59,7 +58,7 @@ struct EmbeddedConfiguration { } impl EmbeddedConfiguration { - fn new(file: &mut RegularFile) -> Result { + fn new(file: &mut RegularFile) -> Result { file.set_position(0)?; let file_data = read_all(file)?; @@ -79,7 +78,7 @@ impl EmbeddedConfiguration { fn main(handle: Handle, mut system_table: SystemTable) -> Status { uefi_services::init(&mut system_table).unwrap(); - print_logo(system_table.stdout()); + print_logo(system_table.stdout()).unwrap(); let config: EmbeddedConfiguration = EmbeddedConfiguration::new(&mut booted_image_file(system_table.boot_services()).unwrap())