Skip to content

Commit

Permalink
Fix some clippy warnings (#692)
Browse files Browse the repository at this point in the history
* src/write/*: Fix clippy::redundant_guards
* src/read/aranges.rs: Fix clippy::try_err
* Fix clippy::unnecessary_cast
  • Loading branch information
Enselic committed Jan 31, 2024
1 parent c173a41 commit 49d872e
Show file tree
Hide file tree
Showing 7 changed files with 9 additions and 9 deletions.
2 changes: 1 addition & 1 deletion src/read/aranges.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
4 changes: 2 additions & 2 deletions src/read/endian_reader.rs
Original file line number Diff line number Diff line change
Expand Up @@ -393,8 +393,8 @@ where

#[inline]
fn offset_from(&self, base: &EndianReader<Endian, T>) -> 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
Expand Down
4 changes: 2 additions & 2 deletions src/read/endian_slice.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion src/read/value.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
2 changes: 1 addition & 1 deletion src/write/loc.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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,
_ => (),
Expand Down
2 changes: 1 addition & 1 deletion src/write/range.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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,
_ => (),
Expand Down
2 changes: 1 addition & 1 deletion src/write/unit.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down

0 comments on commit 49d872e

Please sign in to comment.