From e32101c7e043b10ceff74f69323a326239fbaf22 Mon Sep 17 00:00:00 2001 From: kkent030315 Date: Wed, 23 Oct 2024 22:43:38 +0900 Subject: [PATCH] Simplify the expression with same semantics --- src/pe/tls.rs | 13 ++----------- 1 file changed, 2 insertions(+), 11 deletions(-) diff --git a/src/pe/tls.rs b/src/pe/tls.rs index 24b00400..2369bb0e 100644 --- a/src/pe/tls.rs +++ b/src/pe/tls.rs @@ -190,17 +190,8 @@ impl<'a> TlsData<'a> { // VA to RVA let rva = itd.address_of_index as usize - image_base; - let offset = utils::find_offset(rva, sections, file_alignment, opts).ok_or_else(|| { - error::Error::Malformed(format!( - "cannot map tls address_of_index rva ({:#x}) into offset", - rva - )) - }); - - slot = match offset { - Ok(offset) => Some(bytes.pread_with::(offset, scroll::LE)?), - Err(_) => None, - }; + let offset = utils::find_offset(rva, sections, file_alignment, opts); + slot = offset.and_then(|x| bytes.pread_with::(x, scroll::LE).ok()); } // Parse the callbacks if any