Skip to content

Commit

Permalink
Fix clippy warnings (#724)
Browse files Browse the repository at this point in the history
  • Loading branch information
philipc authored Jun 28, 2024
1 parent 9810fdd commit cf9bfa1
Show file tree
Hide file tree
Showing 8 changed files with 12 additions and 15 deletions.
2 changes: 1 addition & 1 deletion crates/examples/src/bin/dwarfdump.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2031,7 +2031,7 @@ fn dump_line_program<R: Reader, W: Write>(w: &mut W, unit: gimli::UnitRef<R>) ->
writeln!(w, "<pc> [lno,col]")?;
}
let mut rows = program.rows();
let mut file_index = std::u64::MAX;
let mut file_index = u64::MAX;
while let Some((header, row)) = rows.next_row()? {
let line = match row.line() {
Some(line) => line.get(),
Expand Down
2 changes: 1 addition & 1 deletion crates/examples/src/bin/simple_line.rs
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ fn dump_file(
// Determine the path. Real applications should cache this for performance.
let mut path = path::PathBuf::new();
if let Some(file) = row.file(header) {
path = comp_dir.clone();
path.clone_from(&comp_dir);

// The directory index 0 is defined to correspond to the compilation unit directory.
if file.directory_index() != 0 {
Expand Down
4 changes: 2 additions & 2 deletions src/leb128.rs
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ fn low_bits_of_byte(byte: u8) -> u8 {
#[inline]
#[allow(dead_code)]
fn low_bits_of_u64(val: u64) -> u8 {
let byte = val & u64::from(core::u8::MAX);
let byte = val & u64::from(u8::MAX);
low_bits_of_byte(byte as u8)
}

Expand Down Expand Up @@ -465,7 +465,7 @@ mod tests {
for i in -513..513 {
inner(i);
}
inner(core::i64::MIN);
inner(i64::MIN);
}

#[test]
Expand Down
2 changes: 1 addition & 1 deletion src/read/dwarf.rs
Original file line number Diff line number Diff line change
Expand Up @@ -739,7 +739,7 @@ impl<R: Clone> Dwarf<R> {
// parent file.
self.ranges
.set_debug_ranges(parent.ranges.debug_ranges().clone());
self.sup = parent.sup.clone();
self.sup.clone_from(&parent.sup);
}
}

Expand Down
6 changes: 2 additions & 4 deletions src/read/line.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1686,8 +1686,8 @@ impl FileEntryFormat {
let mut path_count = 0;
for _ in 0..format_count {
let content_type = input.read_uleb128()?;
let content_type = if content_type > u64::from(u16::max_value()) {
constants::DwLnct(u16::max_value())
let content_type = if content_type > u64::from(u16::MAX) {
constants::DwLnct(u16::MAX)
} else {
constants::DwLnct(content_type as u16)
};
Expand Down Expand Up @@ -1886,8 +1886,6 @@ mod tests {
use crate::endianity::LittleEndian;
use crate::read::{EndianSlice, Error};
use crate::test_util::GimliSectionMethods;
use core::u64;
use core::u8;
use test_assembler::{Endian, Label, LabelMaker, Section};

#[test]
Expand Down
6 changes: 3 additions & 3 deletions src/read/loclists.rs
Original file line number Diff line number Diff line change
Expand Up @@ -626,7 +626,7 @@ impl<R: Reader> LocListIter<R> {
RawLocListEntry::DefaultLocation { data } => (
Range {
begin: 0,
end: u64::max_value(),
end: u64::MAX,
},
data,
),
Expand Down Expand Up @@ -880,7 +880,7 @@ mod tests {
Ok(Some(LocationListEntry {
range: Range {
begin: 0,
end: u64::max_value(),
end: u64::MAX,
},
data: Expression(EndianSlice::new(&[10, 0, 0, 0], LittleEndian)),
}))
Expand Down Expand Up @@ -1144,7 +1144,7 @@ mod tests {
Ok(Some(LocationListEntry {
range: Range {
begin: 0,
end: u64::max_value(),
end: u64::MAX,
},
data: Expression(EndianSlice::new(&[10, 0, 0, 0], LittleEndian)),
}))
Expand Down
3 changes: 1 addition & 2 deletions src/read/unit.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@
use core::cell::Cell;
use core::ops::{Range, RangeFrom, RangeTo};
use core::{u16, u8};

use crate::common::{
DebugAbbrevOffset, DebugAddrBase, DebugAddrIndex, DebugInfoOffset, DebugLineOffset,
Expand Down Expand Up @@ -1849,7 +1848,7 @@ where
AttributeValue::Data8(data) => data as i64,
AttributeValue::Sdata(data) => data,
AttributeValue::Udata(data) => {
if data > i64::max_value() as u64 {
if data > i64::MAX as u64 {
// Maybe we should emit a warning here
return None;
}
Expand Down
2 changes: 1 addition & 1 deletion src/write/unit.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
use alloc::vec::Vec;
use std::ops::{Deref, DerefMut};
use std::{slice, usize};
use std::slice;

use crate::common::{
DebugAbbrevOffset, DebugInfoOffset, DebugLineOffset, DebugMacinfoOffset, DebugMacroOffset,
Expand Down

0 comments on commit cf9bfa1

Please sign in to comment.