Skip to content

Commit bd7502b

Browse files
Run cargo clippy --fix
1 parent 2fc5429 commit bd7502b

File tree

3 files changed

+13
-13
lines changed

3 files changed

+13
-13
lines changed

src/fs.rs

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -506,9 +506,9 @@ impl<Storage: driver::Storage> Filesystem<'_, Storage> {
506506
extern "C" fn lfs_config_erase(c: *const ll::lfs_config, block: ll::lfs_block_t) -> cty::c_int {
507507
// println!("in lfs_config_erase");
508508
let storage = unsafe { &mut *((*c).context as *mut Storage) };
509-
let off = block as usize * Storage::BLOCK_SIZE as usize;
509+
let off = block as usize * Storage::BLOCK_SIZE;
510510

511-
io::error_code_from(storage.erase(off, Storage::BLOCK_SIZE as usize))
511+
io::error_code_from(storage.erase(off, Storage::BLOCK_SIZE))
512512
}
513513

514514
/// C callback interface used by LittleFS to sync data with the lower level interface below the
@@ -673,7 +673,7 @@ impl<'a, 'b, Storage: driver::Storage> File<'a, 'b, Storage> {
673673

674674
// Safety-hatch to experiment with missing parts of API
675675
pub unsafe fn borrow_filesystem<'c>(&'c mut self) -> &'c Filesystem<'a, Storage> {
676-
&self.fs
676+
self.fs
677677
}
678678

679679
/// Sync the file and drop it from the internal linked list.
@@ -1052,7 +1052,7 @@ impl<'a, 'b, S: driver::Storage> Iterator for ReadDir<'a, 'b, S> {
10521052
impl<'a, 'b, S: driver::Storage> ReadDir<'a, 'b, S> {
10531053
// Safety-hatch to experiment with missing parts of API
10541054
pub unsafe fn borrow_filesystem<'c>(&'c mut self) -> &'c Filesystem<'a, S> {
1055-
&self.fs
1055+
self.fs
10561056
}
10571057
}
10581058

@@ -1367,7 +1367,7 @@ mod tests {
13671367
let mut alloc = Allocation::new();
13681368
let fs = Filesystem::mount(&mut alloc, &mut test_storage).unwrap();
13691369
// fs.write(b"/z.txt\0".try_into().unwrap(), &jackson5).unwrap();
1370-
fs.write(&PathBuf::from("z.txt"), &jackson5).unwrap();
1370+
fs.write(&PathBuf::from("z.txt"), jackson5).unwrap();
13711371
}
13721372

13731373
#[cfg(feature = "dir-entry-path")]
@@ -1446,7 +1446,7 @@ mod tests {
14461446
// One usecase is to read data from the files iterated over.
14471447
//
14481448
if entry.metadata.is_file() {
1449-
fs.write(&entry.file_name(), b"wowee zowie")?;
1449+
fs.write(entry.file_name(), b"wowee zowie")?;
14501450
}
14511451
}
14521452
Ok(())
@@ -1477,11 +1477,11 @@ mod tests {
14771477
})?;
14781478

14791479
let mut a1 = File::allocate();
1480-
let f1 = unsafe { File::open(&fs, &mut a1, b"a.txt\0".try_into().unwrap())? };
1480+
let f1 = unsafe { File::open(fs, &mut a1, b"a.txt\0".try_into().unwrap())? };
14811481
f1.write(b"some text")?;
14821482

14831483
let mut a2 = File::allocate();
1484-
let f2 = unsafe { File::open(&fs, &mut a2, b"b.txt\0".try_into().unwrap())? };
1484+
let f2 = unsafe { File::open(fs, &mut a2, b"b.txt\0".try_into().unwrap())? };
14851485
f2.write(b"more text")?;
14861486

14871487
unsafe { f1.close()? }; // program hangs here

src/path.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -300,7 +300,7 @@ impl From<&[u8]> for PathBuf {
300300
} else {
301301
bytes
302302
};
303-
let has_no_embedded_nul = bytes.iter().find(|&&byte| byte == b'\0').is_none();
303+
let has_no_embedded_nul = !bytes.iter().any(|&byte| byte == b'\0');
304304
assert!(has_no_embedded_nul);
305305

306306
let mut buf = [0; consts::PATH_MAX_PLUS_ONE];

src/tests.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -197,20 +197,20 @@ fn test_create() {
197197
assert_eq!(fs.available_blocks().unwrap(), 512 - 2);
198198
assert_eq!(fs.available_space().unwrap(), 130_560);
199199

200-
assert!(!crate::path::PathBuf::from(b"/test_open.txt").exists(&fs));
200+
assert!(!crate::path::PathBuf::from(b"/test_open.txt").exists(fs));
201201
assert_eq!(
202202
File::open_and_then(fs, b"/test_open.txt\0".try_into().unwrap(), |_| { Ok(()) })
203203
.map(drop)
204204
.unwrap_err(), // "real" contains_err is experimental
205205
Error::NoSuchEntry
206206
);
207-
assert!(!crate::path::PathBuf::from(b"/test_open.txt").exists(&fs));
207+
assert!(!crate::path::PathBuf::from(b"/test_open.txt").exists(fs));
208208

209209
fs.create_dir(b"/tmp\0".try_into().unwrap()).unwrap();
210210
assert_eq!(fs.available_blocks().unwrap(), 512 - 2 - 2);
211211

212212
// can create new files
213-
assert!(!crate::path::PathBuf::from(b"/tmp/test_open.txt").exists(&fs));
213+
assert!(!crate::path::PathBuf::from(b"/tmp/test_open.txt").exists(fs));
214214
fs.create_file_and_then(b"/tmp/test_open.txt\0".try_into().unwrap(), |file| {
215215
// can write to files
216216
assert!(file.write(&[0u8, 1, 2]).unwrap() == 3);
@@ -221,7 +221,7 @@ fn test_create() {
221221
// file.close()?;
222222
Ok(())
223223
})?;
224-
assert!(crate::path::PathBuf::from(b"/tmp/test_open.txt").exists(&fs));
224+
assert!(crate::path::PathBuf::from(b"/tmp/test_open.txt").exists(fs));
225225

226226
// // cannot remove non-empty directories
227227
assert_eq!(

0 commit comments

Comments
 (0)