Skip to content

Commit 7b5b876

Browse files
committed
Appease clippy.
1 parent 44b63de commit 7b5b876

File tree

4 files changed

+54
-52
lines changed

4 files changed

+54
-52
lines changed

examples/readme_test.rs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,8 @@
33
//! We add enough stuff to make it compile, but it won't run because our fake
44
//! SPI doesn't do any replies.
55
6+
#![allow(dead_code)]
7+
68
use core::cell::RefCell;
79

810
use embedded_sdmmc::sdcard::DummyCsPin;

src/sdcard/proto.rs

Lines changed: 44 additions & 44 deletions
Original file line numberDiff line numberDiff line change
@@ -298,19 +298,19 @@ mod test {
298298

299299
// Partial Blocks for Read Allowed:
300300
// 0b1 [Interpreted: Yes]
301-
assert_eq!(EXAMPLE.read_partial_blocks(), true);
301+
assert!(EXAMPLE.read_partial_blocks());
302302

303303
// Write Block Misalignment:
304304
// 0b0 [Interpreted: No]
305-
assert_eq!(EXAMPLE.write_block_misalignment(), false);
305+
assert!(!EXAMPLE.write_block_misalignment());
306306

307307
// Read Block Misalignment:
308308
// 0b0 [Interpreted: No]
309-
assert_eq!(EXAMPLE.read_block_misalignment(), false);
309+
assert!(!EXAMPLE.read_block_misalignment());
310310

311311
// DSR Implemented: indicates configurable driver stage integrated on
312312
// card 0b0 [Interpreted: No]
313-
assert_eq!(EXAMPLE.dsr_implemented(), false);
313+
assert!(!EXAMPLE.dsr_implemented());
314314

315315
// Device Size: to calculate the card capacity excl. security area
316316
// ((device size + 1)*device size multiplier*max read data block
@@ -339,7 +339,7 @@ mod test {
339339

340340
// Erase Single Block Enabled:
341341
// 0x1 [Interpreted: Yes]
342-
assert_eq!(EXAMPLE.erase_single_block_enabled(), true);
342+
assert!(EXAMPLE.erase_single_block_enabled());
343343

344344
// Erase Sector Size: size of erasable sector in write blocks
345345
// 0x1f [Interpreted: 32 blocks]
@@ -351,7 +351,7 @@ mod test {
351351

352352
// Write Protect Group Enable:
353353
// 0x1 [Interpreted: Yes]
354-
assert_eq!(EXAMPLE.write_protect_group_enable(), true);
354+
assert!(EXAMPLE.write_protect_group_enable());
355355

356356
// Write Speed Factor: block program time as multiple of read access time
357357
// 0x4 [Interpreted: x16]
@@ -363,23 +363,23 @@ mod test {
363363

364364
// Partial Blocks for Write Allowed:
365365
// 0x0 [Interpreted: No]
366-
assert_eq!(EXAMPLE.write_partial_blocks(), false);
366+
assert!(!EXAMPLE.write_partial_blocks());
367367

368368
// File Format Group:
369369
// 0b0 [Interpreted: is either Hard Disk with Partition Table/DOS FAT without Partition Table/Universal File Format/Other/Unknown]
370-
assert_eq!(EXAMPLE.file_format_group_set(), false);
370+
assert!(!EXAMPLE.file_format_group_set());
371371

372372
// Copy Flag:
373373
// 0b1 [Interpreted: Non-Original]
374-
assert_eq!(EXAMPLE.copy_flag_set(), true);
374+
assert!(EXAMPLE.copy_flag_set());
375375

376376
// Permanent Write Protection:
377377
// 0b0 [Interpreted: No]
378-
assert_eq!(EXAMPLE.permanent_write_protection(), false);
378+
assert!(!EXAMPLE.permanent_write_protection());
379379

380380
// Temporary Write Protection:
381381
// 0b0 [Interpreted: No]
382-
assert_eq!(EXAMPLE.temporary_write_protection(), false);
382+
assert!(!EXAMPLE.temporary_write_protection());
383383

384384
// File Format:
385385
// 0x0 [Interpreted: Hard Disk with Partition Table]
@@ -424,19 +424,19 @@ mod test {
424424

425425
// Partial Blocks for Read Allowed:
426426
// 0b1 [Interpreted: Yes]
427-
assert_eq!(EXAMPLE.read_partial_blocks(), true);
427+
assert!(EXAMPLE.read_partial_blocks());
428428

429429
// Write Block Misalignment:
430430
// 0b0 [Interpreted: No]
431-
assert_eq!(EXAMPLE.write_block_misalignment(), false);
431+
assert!(!EXAMPLE.write_block_misalignment());
432432

433433
// Read Block Misalignment:
434434
// 0b0 [Interpreted: No]
435-
assert_eq!(EXAMPLE.read_block_misalignment(), false);
435+
assert!(!EXAMPLE.read_block_misalignment());
436436

437437
// DSR Implemented: indicates configurable driver stage integrated on card
438438
// 0b0 [Interpreted: No]
439-
assert_eq!(EXAMPLE.dsr_implemented(), false);
439+
assert!(!EXAMPLE.dsr_implemented());
440440

441441
// Device Size: to calculate the card capacity excl. security area
442442
// ((device size + 1)*device size multiplier*max read data block
@@ -465,7 +465,7 @@ mod test {
465465

466466
// Erase Single Block Enabled:
467467
// 0x1 [Interpreted: Yes]
468-
assert_eq!(EXAMPLE.erase_single_block_enabled(), true);
468+
assert!(EXAMPLE.erase_single_block_enabled());
469469

470470
// Erase Sector Size: size of erasable sector in write blocks
471471
// 0x1f [Interpreted: 32 blocks]
@@ -477,7 +477,7 @@ mod test {
477477

478478
// Write Protect Group Enable:
479479
// 0x0 [Interpreted: No]
480-
assert_eq!(EXAMPLE.write_protect_group_enable(), false);
480+
assert!(!EXAMPLE.write_protect_group_enable());
481481

482482
// Write Speed Factor: block program time as multiple of read access time
483483
// 0x5 [Interpreted: x32]
@@ -489,23 +489,23 @@ mod test {
489489

490490
// Partial Blocks for Write Allowed:
491491
// 0x0 [Interpreted: No]
492-
assert_eq!(EXAMPLE.write_partial_blocks(), false);
492+
assert!(!EXAMPLE.write_partial_blocks());
493493

494494
// File Format Group:
495495
// 0b0 [Interpreted: is either Hard Disk with Partition Table/DOS FAT without Partition Table/Universal File Format/Other/Unknown]
496-
assert_eq!(EXAMPLE.file_format_group_set(), false);
496+
assert!(!EXAMPLE.file_format_group_set());
497497

498498
// Copy Flag:
499499
// 0b0 [Interpreted: Original]
500-
assert_eq!(EXAMPLE.copy_flag_set(), false);
500+
assert!(!EXAMPLE.copy_flag_set());
501501

502502
// Permanent Write Protection:
503503
// 0b0 [Interpreted: No]
504-
assert_eq!(EXAMPLE.permanent_write_protection(), false);
504+
assert!(!EXAMPLE.permanent_write_protection());
505505

506506
// Temporary Write Protection:
507507
// 0b0 [Interpreted: No]
508-
assert_eq!(EXAMPLE.temporary_write_protection(), false);
508+
assert!(!EXAMPLE.temporary_write_protection());
509509

510510
// File Format:
511511
// 0x0 [Interpreted: Hard Disk with Partition Table]
@@ -550,19 +550,19 @@ mod test {
550550

551551
// Partial Blocks for Read Allowed:
552552
// 0b0 [Interpreted: Yes]
553-
assert_eq!(EXAMPLE.read_partial_blocks(), false);
553+
assert!(!EXAMPLE.read_partial_blocks());
554554

555555
// Write Block Misalignment:
556556
// 0b0 [Interpreted: No]
557-
assert_eq!(EXAMPLE.write_block_misalignment(), false);
557+
assert!(!EXAMPLE.write_block_misalignment());
558558

559559
// Read Block Misalignment:
560560
// 0b0 [Interpreted: No]
561-
assert_eq!(EXAMPLE.read_block_misalignment(), false);
561+
assert!(!EXAMPLE.read_block_misalignment());
562562

563563
// DSR Implemented: indicates configurable driver stage integrated on card
564564
// 0b0 [Interpreted: No]
565-
assert_eq!(EXAMPLE.dsr_implemented(), false);
565+
assert!(!EXAMPLE.dsr_implemented());
566566

567567
// Device Size: to calculate the card capacity excl. security area
568568
// ((device size + 1)* 512kbytes
@@ -571,7 +571,7 @@ mod test {
571571

572572
// Erase Single Block Enabled:
573573
// 0x1 [Interpreted: Yes]
574-
assert_eq!(EXAMPLE.erase_single_block_enabled(), true);
574+
assert!(EXAMPLE.erase_single_block_enabled());
575575

576576
// Erase Sector Size: size of erasable sector in write blocks
577577
// 0x7f [Interpreted: 128 blocks]
@@ -583,7 +583,7 @@ mod test {
583583

584584
// Write Protect Group Enable:
585585
// 0x0 [Interpreted: No]
586-
assert_eq!(EXAMPLE.write_protect_group_enable(), false);
586+
assert!(!EXAMPLE.write_protect_group_enable());
587587

588588
// Write Speed Factor: block program time as multiple of read access time
589589
// 0x2 [Interpreted: x4]
@@ -595,23 +595,23 @@ mod test {
595595

596596
// Partial Blocks for Write Allowed:
597597
// 0x0 [Interpreted: No]
598-
assert_eq!(EXAMPLE.write_partial_blocks(), false);
598+
assert!(!EXAMPLE.write_partial_blocks());
599599

600600
// File Format Group:
601601
// 0b0 [Interpreted: is either Hard Disk with Partition Table/DOS FAT without Partition Table/Universal File Format/Other/Unknown]
602-
assert_eq!(EXAMPLE.file_format_group_set(), false);
602+
assert!(!EXAMPLE.file_format_group_set());
603603

604604
// Copy Flag:
605605
// 0b0 [Interpreted: Original]
606-
assert_eq!(EXAMPLE.copy_flag_set(), false);
606+
assert!(!EXAMPLE.copy_flag_set());
607607

608608
// Permanent Write Protection:
609609
// 0b0 [Interpreted: No]
610-
assert_eq!(EXAMPLE.permanent_write_protection(), false);
610+
assert!(!EXAMPLE.permanent_write_protection());
611611

612612
// Temporary Write Protection:
613613
// 0b0 [Interpreted: No]
614-
assert_eq!(EXAMPLE.temporary_write_protection(), false);
614+
assert!(!EXAMPLE.temporary_write_protection());
615615

616616
// File Format:
617617
// 0x0 [Interpreted: Hard Disk with Partition Table]
@@ -656,19 +656,19 @@ mod test {
656656

657657
// Partial Blocks for Read Allowed:
658658
// 0b0 [Interpreted: Yes]
659-
assert_eq!(EXAMPLE.read_partial_blocks(), false);
659+
assert!(!EXAMPLE.read_partial_blocks());
660660

661661
// Write Block Misalignment:
662662
// 0b0 [Interpreted: No]
663-
assert_eq!(EXAMPLE.write_block_misalignment(), false);
663+
assert!(!EXAMPLE.write_block_misalignment());
664664

665665
// Read Block Misalignment:
666666
// 0b0 [Interpreted: No]
667-
assert_eq!(EXAMPLE.read_block_misalignment(), false);
667+
assert!(!EXAMPLE.read_block_misalignment());
668668

669669
// DSR Implemented: indicates configurable driver stage integrated on card
670670
// 0b0 [Interpreted: No]
671-
assert_eq!(EXAMPLE.dsr_implemented(), false);
671+
assert!(!EXAMPLE.dsr_implemented());
672672

673673
// Device Size: to calculate the card capacity excl. security area
674674
// ((device size + 1)* 512kbytes
@@ -677,7 +677,7 @@ mod test {
677677

678678
// Erase Single Block Enabled:
679679
// 0x1 [Interpreted: Yes]
680-
assert_eq!(EXAMPLE.erase_single_block_enabled(), true);
680+
assert!(EXAMPLE.erase_single_block_enabled());
681681

682682
// Erase Sector Size: size of erasable sector in write blocks
683683
// 0x7f [Interpreted: 128 blocks]
@@ -689,7 +689,7 @@ mod test {
689689

690690
// Write Protect Group Enable:
691691
// 0x0 [Interpreted: No]
692-
assert_eq!(EXAMPLE.write_protect_group_enable(), false);
692+
assert!(!EXAMPLE.write_protect_group_enable());
693693

694694
// Write Speed Factor: block program time as multiple of read access time
695695
// 0x2 [Interpreted: x4]
@@ -701,23 +701,23 @@ mod test {
701701

702702
// Partial Blocks for Write Allowed:
703703
// 0x0 [Interpreted: No]
704-
assert_eq!(EXAMPLE.write_partial_blocks(), false);
704+
assert!(!EXAMPLE.write_partial_blocks());
705705

706706
// File Format Group:
707707
// 0b0 [Interpreted: is either Hard Disk with Partition Table/DOS FAT without Partition Table/Universal File Format/Other/Unknown]
708-
assert_eq!(EXAMPLE.file_format_group_set(), false);
708+
assert!(!EXAMPLE.file_format_group_set());
709709

710710
// Copy Flag:
711711
// 0b0 [Interpreted: Original]
712-
assert_eq!(EXAMPLE.copy_flag_set(), false);
712+
assert!(!EXAMPLE.copy_flag_set());
713713

714714
// Permanent Write Protection:
715715
// 0b0 [Interpreted: No]
716-
assert_eq!(EXAMPLE.permanent_write_protection(), false);
716+
assert!(!EXAMPLE.permanent_write_protection());
717717

718718
// Temporary Write Protection:
719719
// 0b0 [Interpreted: No]
720-
assert_eq!(EXAMPLE.temporary_write_protection(), false);
720+
assert!(!EXAMPLE.temporary_write_protection());
721721

722722
// File Format:
723723
// 0x0 [Interpreted: Hard Disk with Partition Table]

tests/open_files.rs

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -109,24 +109,24 @@ fn open_non_raw() {
109109
assert_eq!(len, 258);
110110
assert_eq!(f.length(), 258);
111111
f.seek_from_current(0).unwrap();
112-
assert_eq!(f.is_eof(), true);
112+
assert!(f.is_eof());
113113
assert_eq!(f.offset(), 258);
114114
assert!(matches!(f.seek_from_current(1), Err(Error::InvalidOffset)));
115115
f.seek_from_current(-258).unwrap();
116-
assert_eq!(f.is_eof(), false);
116+
assert!(!f.is_eof());
117117
assert_eq!(f.offset(), 0);
118118
f.seek_from_current(10).unwrap();
119-
assert_eq!(f.is_eof(), false);
119+
assert!(!f.is_eof());
120120
assert_eq!(f.offset(), 10);
121121
f.seek_from_end(0).unwrap();
122-
assert_eq!(f.is_eof(), true);
122+
assert!(f.is_eof());
123123
assert_eq!(f.offset(), 258);
124124
assert!(matches!(
125125
f.seek_from_current(-259),
126126
Err(Error::InvalidOffset)
127127
));
128128
f.seek_from_start(25).unwrap();
129-
assert_eq!(f.is_eof(), false);
129+
assert!(!f.is_eof());
130130
assert_eq!(f.offset(), 25);
131131

132132
drop(f);

tests/utils/mod.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ use embedded_sdmmc::{Block, BlockCount, BlockDevice, BlockIdx};
88
///
99
/// ```console
1010
/// $ fdisk ./disk.img
11-
/// Disk: ./disk.img geometry: 520/32/63 [1048576 sectors]
11+
/// Disk: ./disk.img geometry: 520/32/63 [1048576 sectors]
1212
/// Signature: 0xAA55
1313
/// Starting Ending
1414
/// #: id cyl hd sec - cyl hd sec [ start - size]
@@ -126,7 +126,7 @@ where
126126
fn num_blocks(&self) -> Result<BlockCount, Self::Error> {
127127
let borrow = self.contents.borrow();
128128
let contents: &[u8] = borrow.as_ref();
129-
let len_blocks = contents.len() as usize / embedded_sdmmc::Block::LEN;
129+
let len_blocks = contents.len() / embedded_sdmmc::Block::LEN;
130130
if len_blocks > u32::MAX as usize {
131131
panic!("Test disk too large! Only 2**32 blocks allowed");
132132
}
@@ -155,7 +155,7 @@ pub struct TestTimeSource {
155155

156156
impl embedded_sdmmc::TimeSource for TestTimeSource {
157157
fn get_timestamp(&self) -> embedded_sdmmc::Timestamp {
158-
self.fixed.clone()
158+
self.fixed
159159
}
160160
}
161161

0 commit comments

Comments
 (0)