Skip to content

Commit

Permalink
fix clippy warnings
Browse files Browse the repository at this point in the history
  • Loading branch information
zjp-CN committed Jan 19, 2025
1 parent 91daa80 commit c775820
Show file tree
Hide file tree
Showing 6 changed files with 12 additions and 10 deletions.
2 changes: 1 addition & 1 deletion example/testos/build.rs
Original file line number Diff line number Diff line change
Expand Up @@ -34,4 +34,4 @@ SECTIONS {
/DISCARD/ : {
*(.eh_frame)
}
}";
}";
4 changes: 2 additions & 2 deletions example/testos/src/boot.rs
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ pub fn read_time_ms() -> usize {
}

pub fn read_time_us() -> usize {
read_time() / (VF2_FREQ / 1000_000)
read_time() / (VF2_FREQ / 1_000_000)
}

pub fn sleep_ms(ms: usize) {
Expand All @@ -91,7 +91,7 @@ pub fn sleep_ms_until(ms: usize, mut f: impl FnMut() -> bool) {

pub fn sleep_us(us: usize) {
let start = read_time();
while read_time() - start < us * VF2_FREQ / 1000_000 {
while read_time() - start < us * VF2_FREQ / 1_000_000 {
core::hint::spin_loop();
}
}
2 changes: 1 addition & 1 deletion example/testos/src/config.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
pub const STACK_SIZE: usize = 4096 * CORES;
pub const CORES: usize = 5;
pub const HEAP_SIZE: usize = 4096 * 1024 * 4 * 4;
pub const VF2_FREQ: usize = 4000_000;
pub const VF2_FREQ: usize = 4_000_000;
pub const UART_BASE: usize = 0x1000_0000;
2 changes: 2 additions & 0 deletions example/testos/src/console.rs
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
#![allow(clippy::erasing_op, clippy::identity_op)]

use core::fmt::{Arguments, Write};

use log::{self, Level, LevelFilter, Log, Metadata, Record};
Expand Down
2 changes: 1 addition & 1 deletion example/testos/src/fatfs.rs
Original file line number Diff line number Diff line change
Expand Up @@ -108,7 +108,7 @@ impl Write for BufStream {
self.mmc.read_block(block_id, &mut tmp_buf);
tmp_buf[block_offset..block_offset + copy_len]
.copy_from_slice(&buf[write_len..write_len + copy_len]);
self.mmc.write_block(block_id, &mut tmp_buf);
self.mmc.write_block(block_id, &tmp_buf);
} else {
self.mmc
.write_block(block_id, &buf[write_len..write_len + copy_len]);
Expand Down
10 changes: 5 additions & 5 deletions example/testos/src/static_keys.rs
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
#![allow(clippy::needless_range_loop)]
use crate::boot::{hart_id, read_time, read_time_us};
use crate::println;
use core::arch::asm;
Expand Down Expand Up @@ -138,8 +139,7 @@ impl FlagCache {
}
}

const ARRAY_REPEAT_VALUE: FlagCache = FlagCache::new();
static FLAGS: [FlagCache; 10000] = [ARRAY_REPEAT_VALUE; 10000];
static FLAGS: [FlagCache; 10000] = [const { FlagCache::new() }; 10000];

static TIME_ATOMIC: AtomicUsize = AtomicUsize::new(0);
static TIME_KEYS: AtomicUsize = AtomicUsize::new(0);
Expand All @@ -158,7 +158,7 @@ fn test_mass_static_atomic(cpu: usize) {
let end1 = read_time_us() - now;
println!("test_atomic: {}us", end1);
println!("test_atomic: {}", count);
TIME_ATOMIC.store(end1 as usize, atomic::Ordering::SeqCst);
TIME_ATOMIC.store(end1, atomic::Ordering::SeqCst);
}

fn test_mass_static_keys(cpu: usize) {
Expand All @@ -177,7 +177,7 @@ fn test_mass_static_keys(cpu: usize) {
let end2 = read_time_us() - now;
println!("test_static_keys: {}us", end2);
println!("test_static_keys: {}", count);
TIME_KEYS.store(end2 as usize, atomic::Ordering::SeqCst);
TIME_KEYS.store(end2, atomic::Ordering::SeqCst);
}

#[repr(align(64))]
Expand All @@ -196,7 +196,7 @@ impl DataCache {
pub fn fill(&mut self, val: u8) {
let data = &mut self.data;
for i in 0..data.len() {
data[i] = (data[i] + val as u64);
data[i] += val as u64;
}
}
}
Expand Down

0 comments on commit c775820

Please sign in to comment.