From 559c761a3e2da9e413bd5cf105327a5f951bb77b Mon Sep 17 00:00:00 2001 From: Ramil_Algayev Date: Mon, 30 Dec 2024 05:54:50 +0400 Subject: [PATCH] fixed the lazy_static part --- dtrfs_api/src/main.rs | 22 +++------------------- 1 file changed, 3 insertions(+), 19 deletions(-) diff --git a/dtrfs_api/src/main.rs b/dtrfs_api/src/main.rs index 7c09e0b..4e31bea 100644 --- a/dtrfs_api/src/main.rs +++ b/dtrfs_api/src/main.rs @@ -52,31 +52,15 @@ const KEY_FILE: &str = "/tmp/certs/dtrfs_api.key"; const CMDLINE_FILE: &str = "/proc/cmdline"; lazy_static! { - static ref SNP_REPORT: String = match get_cert_hash() - .and_then(|hash| snp::get_report_as_base64(hash).map_err(|err| err.into())) - { - Ok(report) => report, - Err(e) => { - eprintln!("Failed to get SNP report: {}", e); - String::new() - } - }; + static ref SNP_REPORT: String = snp::get_report_as_base64(get_cert_hash().unwrap()).unwrap(); static ref CRT_CONTENTS: String = { let mut msg = String::new(); - if let Err(e) = - File::open(CRT_FILE).and_then(|file| BufReader::new(file).read_to_string(&mut msg)) - { - eprintln!("Failed to read certificate file: {}", e); - } + let _ = BufReader::new(File::open(CRT_FILE).unwrap()).read_to_string(&mut msg); msg }; static ref CMDLINE: String = { let mut cmdline = String::new(); - if let Err(e) = File::open(CMDLINE_FILE) - .and_then(|file| BufReader::new(file).read_to_string(&mut cmdline)) - { - eprintln!("Failed to read cmdline file: {}", e); - } + let _ = BufReader::new(File::open(CMDLINE_FILE).unwrap()).read_to_string(&mut cmdline); cmdline }; }