Skip to content

Commit c42ef53

Browse files
committed
Fix warnings
1 parent 46c7b12 commit c42ef53

File tree

8 files changed

+29
-20
lines changed

8 files changed

+29
-20
lines changed

libsave3ds/src/cart_save_data.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -155,8 +155,8 @@ mod test {
155155

156156
crate::file_system::test::fuzzer(
157157
file_system,
158-
param.max_dir as usize,
159-
param.max_file as usize,
158+
param.max_dir,
159+
param.max_file,
160160
|| CartSaveData::new(raw.clone(), &cart_format).unwrap(),
161161
gen_name,
162162
gen_len,

libsave3ds/src/ext_data.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -504,7 +504,7 @@ impl File {
504504
if quota.free_block < block {
505505
return make_error(Error::NoSpace);
506506
}
507-
quota.mount_id = file_index as u32;
507+
quota.mount_id = file_index;
508508
quota.mount_len = physical_len as u64;
509509
quota.potential_free_block = quota.free_block;
510510
quota.free_block -= block;
@@ -572,7 +572,7 @@ impl File {
572572

573573
if let Some(quota_file) = self.center.quota_file.as_ref() {
574574
let mut quota: Quota = read_struct(quota_file.partition().as_ref(), 0)?;
575-
quota.mount_id = file_index as u32;
575+
quota.mount_id = file_index;
576576
quota.mount_len = physical_len as u64;
577577
let block = (divide_up(physical_len, 0x1000)) as u32;
578578
quota.free_block += block;
@@ -854,8 +854,8 @@ mod test {
854854
let file_system = ExtData::new(nand.clone(), &[], 0, [0; 16], false, true).unwrap();
855855
crate::file_system::test::fuzzer(
856856
file_system,
857-
param.max_dir as usize,
858-
param.max_file as usize,
857+
param.max_dir,
858+
param.max_file,
859859
|| ExtData::new(nand.clone(), &[], 0, [0; 16], false, true).unwrap(),
860860
gen_name,
861861
gen_len,

libsave3ds/src/file_system.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -410,7 +410,7 @@ pub mod test {
410410
Err(Error::NoSpace) => {
411411
let stat = file_system.stat().unwrap();
412412
assert!(
413-
file_mirrors.len() == max_file as usize
413+
file_mirrors.len() == max_file
414414
|| stat.free_blocks * stat.block_len < len
415415
);
416416
}

libsave3ds/src/lib.rs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,6 @@
1+
// digit grouping in this lib has some special meaning
2+
#![allow(clippy::unusual_byte_groupings)]
3+
14
mod aes_ctr_file;
25
mod byte_struct_common;
36
pub mod cart_save_data;

libsave3ds/src/misc.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ use sha2::*;
22

33
pub fn hash_movable(key: [u8; 16]) -> String {
44
let mut hasher = Sha256::new();
5-
hasher.update(&key);
5+
hasher.update(key);
66
let hash = hasher.finalize();
77
let mut result = String::new();
88
for index in &[3, 2, 1, 0, 7, 6, 5, 4, 11, 10, 9, 8, 15, 14, 13, 12] {

libsave3ds/src/save_data.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -834,8 +834,8 @@ mod test {
834834

835835
crate::file_system::test::fuzzer(
836836
file_system,
837-
param.max_dir as usize,
838-
param.max_file as usize,
837+
param.max_dir,
838+
param.max_file,
839839
|| SaveData::new(disa_raw.clone(), SaveDataType::Bare).unwrap(),
840840
gen_name,
841841
gen_len,

libsave3ds/src/sd.rs

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -45,11 +45,9 @@ impl SdNandFileSystem for Sd {
4545

4646
let hash_path: Vec<u8> = path
4747
.iter()
48-
.map(|s| std::iter::once(b'/').chain(s.bytes()))
49-
.flatten()
48+
.flat_map(|s| std::iter::once(b'/').chain(s.bytes()))
5049
.chain(std::iter::once(0))
51-
.map(|c| std::iter::once(c).chain(std::iter::once(0)))
52-
.flatten()
50+
.flat_map(|c| std::iter::once(c).chain(std::iter::once(0)))
5351
.collect();
5452

5553
let mut hasher = Sha256::new();

save3ds_fuse/src/main.rs

Lines changed: 14 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,6 @@ use libsave3ds::Resource;
88
use std::collections::HashMap;
99
use std::ffi::OsStr;
1010
use std::io::Read;
11-
use std::time::{Duration, SystemTime};
1211

1312
#[cfg(all(unix, feature = "unixfuse"))]
1413
use {
@@ -17,6 +16,7 @@ use {
1716
getegid, geteuid, EBADF, EEXIST, EIO, EISDIR, ENAMETOOLONG, ENOENT, ENOSPC, ENOSYS,
1817
ENOTDIR, ENOTEMPTY, EROFS,
1918
},
19+
std::time::{Duration, SystemTime},
2020
};
2121

2222
enum FileSystemOperation {
@@ -27,7 +27,7 @@ enum FileSystemOperation {
2727
}
2828

2929
fn is_legal_char(c: u8) -> bool {
30-
c >= 32 && c < 127 && c != 47 && c != 92
30+
(32..127).contains(&c) && c != 47 && c != 92
3131
}
3232

3333
trait NameConvert {
@@ -176,11 +176,15 @@ where
176176
Ok(())
177177
}
178178

179-
fn import_impl<T: FileSystem>(save: &T, dir: &T::DirType, path: &std::path::Path) -> Result<(), Error>
179+
fn import_impl<T: FileSystem>(
180+
_save: &T,
181+
dir: &T::DirType,
182+
path: &std::path::Path,
183+
) -> Result<(), Error>
180184
where
181185
T::NameType: NameConvert + Clone,
182186
{
183-
for entry in std::fs::read_dir(&path)? {
187+
for entry in std::fs::read_dir(path)? {
184188
let entry = entry?;
185189
println!("{:?}", entry.path());
186190
let name = if let Some(name) = entry
@@ -198,7 +202,7 @@ where
198202
let file_type = entry.file_type()?;
199203
if file_type.is_dir() {
200204
let dir = dir.new_sub_dir(name)?;
201-
import_impl(save, &dir, &entry.path())?
205+
import_impl(_save, &dir, &entry.path())?
202206
} else if file_type.is_file() {
203207
let mut host_file = std::fs::File::open(&entry.path())?;
204208
let len = host_file.metadata()?.len() as usize;
@@ -230,7 +234,11 @@ where
230234
}
231235

232236
#[allow(unreachable_code, unused_variables)]
233-
fn do_mount<T: FileSystem>(save: T, read_only: bool, mountpoint: &std::path::Path) -> Result<(), Error>
237+
fn do_mount<T: FileSystem>(
238+
save: T,
239+
read_only: bool,
240+
mountpoint: &std::path::Path,
241+
) -> Result<(), Error>
234242
where
235243
T::NameType: NameConvert + Clone,
236244
{

0 commit comments

Comments
 (0)