Skip to content

Commit f206fef

Browse files
Merge pull request #381 from wcampbell0x2a/fix-clippy-unnecessary_fallible_conversions
Fix clippy::unnecessary_fallible_conversions
2 parents 1085dc0 + a5e14a3 commit f206fef

File tree

3 files changed

+8
-8
lines changed

3 files changed

+8
-8
lines changed

backhand-cli/src/bin/unsquashfs.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ use std::time::{Duration, Instant};
3131
static ALLOC: jemallocator::Jemalloc = jemallocator::Jemalloc;
3232

3333
pub fn required_root(a: &str) -> Result<PathBuf, String> {
34-
let p = PathBuf::try_from(a).or(Err("could not".to_string()))?;
34+
let p = PathBuf::from(a);
3535

3636
if p.has_root() {
3737
Ok(p)
@@ -560,7 +560,7 @@ fn extract_all<'a, S: ParallelIterator<Item = &'a Node<SquashfsFileReader>>>(
560560
&filepath,
561561
SFlag::S_IFCHR,
562562
Mode::from_bits(mode_t::from(node.header.permissions)).unwrap(),
563-
dev_t::try_from(*device_number).unwrap(),
563+
dev_t::from(*device_number),
564564
) {
565565
Ok(_) => {
566566
if args.info && !args.quiet {
@@ -602,7 +602,7 @@ fn extract_all<'a, S: ParallelIterator<Item = &'a Node<SquashfsFileReader>>>(
602602
&filepath,
603603
SFlag::S_IFBLK,
604604
Mode::from_bits(mode_t::from(node.header.permissions)).unwrap(),
605-
dev_t::try_from(*device_number).unwrap(),
605+
dev_t::from(*device_number),
606606
) {
607607
Ok(_) => {
608608
if args.info && !args.quiet {

backhand/src/filesystem/writer.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -685,7 +685,7 @@ impl<'a, 'b, 'c> FilesystemWriter<'a, 'b, 'c> {
685685

686686
// Write 1K at a time
687687
let mut total_written = 0;
688-
while w.stream_position()? < (superblock.bytes_used + u64::try_from(pad_len).unwrap()) {
688+
while w.stream_position()? < (superblock.bytes_used + u64::from(pad_len)) {
689689
let arr = &[0x00; 1024];
690690

691691
// check if last block to write
@@ -720,7 +720,7 @@ impl<'a, 'b, 'c> FilesystemWriter<'a, 'b, 'c> {
720720

721721
//clean any cache, make sure the output is on disk
722722
w.flush()?;
723-
Ok(superblock.bytes_used + u64::try_from(pad_len).unwrap())
723+
Ok(superblock.bytes_used + u64::from(pad_len))
724724
}
725725

726726
/// For example, writing a fragment table:

backhand/src/squashfs.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -496,15 +496,15 @@ impl<'b> Squashfs<'b> {
496496
InodeInner::BasicDirectory(basic_dir) => {
497497
trace!("BASIC_DIR inodes: {:02x?}", basic_dir);
498498
self.dir_from_index(
499-
basic_dir.block_index.try_into().unwrap(),
500-
basic_dir.file_size.try_into().unwrap(),
499+
u64::from(basic_dir.block_index),
500+
u32::from(basic_dir.file_size),
501501
basic_dir.block_offset as usize,
502502
)?
503503
}
504504
InodeInner::ExtendedDirectory(ext_dir) => {
505505
trace!("EXT_DIR: {:#02x?}", ext_dir);
506506
self.dir_from_index(
507-
ext_dir.block_index.try_into().unwrap(),
507+
u64::from(ext_dir.block_index),
508508
ext_dir.file_size,
509509
ext_dir.block_offset as usize,
510510
)?

0 commit comments

Comments
 (0)