From 8c15dc99e18361f349041195c220d4835fb43006 Mon Sep 17 00:00:00 2001 From: Martin Nordholts Date: Mon, 29 Jan 2024 19:25:48 +0100 Subject: [PATCH 1/3] src/write/*: Fix clippy::redundant_guards --- src/write/loc.rs | 2 +- src/write/range.rs | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/src/write/loc.rs b/src/write/loc.rs index 6dfe45a6..b0f9ea94 100644 --- a/src/write/loc.rs +++ b/src/write/loc.rs @@ -410,7 +410,7 @@ mod convert { // In some cases, existing data may contain begin == end, filtering // these out. match loc { - Location::StartLength { length, .. } if length == 0 => continue, + Location::StartLength { length: 0, .. } => continue, Location::StartEnd { begin, end, .. } if begin == end => continue, Location::OffsetPair { begin, end, .. } if begin == end => continue, _ => (), diff --git a/src/write/range.rs b/src/write/range.rs index c707e1ea..2f0f169b 100644 --- a/src/write/range.rs +++ b/src/write/range.rs @@ -288,7 +288,7 @@ mod convert { }; // Filtering empty ranges out. match range { - Range::StartLength { length, .. } if length == 0 => continue, + Range::StartLength { length: 0, .. } => continue, Range::StartEnd { begin, end, .. } if begin == end => continue, Range::OffsetPair { begin, end, .. } if begin == end => continue, _ => (), From 31078e08598651d4c50fa598395d17b630fd171b Mon Sep 17 00:00:00 2001 From: Martin Nordholts Date: Mon, 29 Jan 2024 19:29:32 +0100 Subject: [PATCH 2/3] src/read/aranges.rs: Fix clippy::try_err --- src/read/aranges.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/read/aranges.rs b/src/read/aranges.rs index 83159b69..cffd5021 100644 --- a/src/read/aranges.rs +++ b/src/read/aranges.rs @@ -182,7 +182,7 @@ where .and_then(|x| x.checked_add(segment_size)) .ok_or(Error::InvalidAddressRange)?; if tuple_length == 0 { - return Err(Error::InvalidAddressRange)?; + return Err(Error::InvalidAddressRange); } let padding = if header_length % tuple_length == 0 { 0 From e9ab4dffefa03b50291fa255f43ba12e40666327 Mon Sep 17 00:00:00 2001 From: Martin Nordholts Date: Tue, 30 Jan 2024 19:51:02 +0100 Subject: [PATCH 3/3] Fix clippy::unnecessary_cast --- src/read/endian_reader.rs | 4 ++-- src/read/endian_slice.rs | 4 ++-- src/read/value.rs | 2 +- src/write/unit.rs | 2 +- 4 files changed, 6 insertions(+), 6 deletions(-) diff --git a/src/read/endian_reader.rs b/src/read/endian_reader.rs index 8852b380..ef927e52 100644 --- a/src/read/endian_reader.rs +++ b/src/read/endian_reader.rs @@ -393,8 +393,8 @@ where #[inline] fn offset_from(&self, base: &EndianReader) -> usize { - let base_ptr = base.bytes().as_ptr() as *const u8 as usize; - let ptr = self.bytes().as_ptr() as *const u8 as usize; + let base_ptr = base.bytes().as_ptr() as usize; + let ptr = self.bytes().as_ptr() as usize; debug_assert!(base_ptr <= ptr); debug_assert!(ptr + self.bytes().len() <= base_ptr + base.bytes().len()); ptr - base_ptr diff --git a/src/read/endian_slice.rs b/src/read/endian_slice.rs index 0db28dac..b327a84f 100644 --- a/src/read/endian_slice.rs +++ b/src/read/endian_slice.rs @@ -68,8 +68,8 @@ where /// of the given slice. #[inline] pub fn offset_from(&self, base: EndianSlice<'input, Endian>) -> usize { - let base_ptr = base.slice.as_ptr() as *const u8 as usize; - let ptr = self.slice.as_ptr() as *const u8 as usize; + let base_ptr = base.slice.as_ptr() as usize; + let ptr = self.slice.as_ptr() as usize; debug_assert!(base_ptr <= ptr); debug_assert!(ptr + self.slice.len() <= base_ptr + base.slice.len()); ptr - base_ptr diff --git a/src/read/value.rs b/src/read/value.rs index 77b08eda..20eb3d67 100644 --- a/src/read/value.rs +++ b/src/read/value.rs @@ -199,7 +199,7 @@ impl Value { Value::I32(value) => value as u64, Value::U32(value) => u64::from(value), Value::I64(value) => value as u64, - Value::U64(value) => value as u64, + Value::U64(value) => value, _ => return Err(Error::IntegralTypeRequired), }; Ok(value) diff --git a/src/write/unit.rs b/src/write/unit.rs index dd8ba674..da9704a2 100644 --- a/src/write/unit.rs +++ b/src/write/unit.rs @@ -1098,7 +1098,7 @@ impl AttributeValue { } AttributeValue::AddressClass(val) => { debug_assert_form!(constants::DW_FORM_udata); - uleb128_size(val.0 as u64) + uleb128_size(val.0) } AttributeValue::IdentifierCase(val) => { debug_assert_form!(constants::DW_FORM_udata);