Skip to content

Commit 032bdb4

Browse files
bors[bot]mkroening
andauthored
Merge #399
399: Fix clippy lints r=stlankes a=mkroening See #397. Co-authored-by: Martin Kröning <[email protected]>
2 parents c8c134a + ef94b04 commit 032bdb4

File tree

8 files changed

+22
-23
lines changed

8 files changed

+22
-23
lines changed

src/arch/x86_64/kernel/mmio.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -11,10 +11,10 @@ use crate::synch::spinlock::SpinlockIrqSave;
1111
use alloc::vec::Vec;
1212
use core::str;
1313

14-
pub const MAGIC_VALUE: u32 = 0x74726976 as u32;
14+
pub const MAGIC_VALUE: u32 = 0x74726976;
1515

16-
pub const MMIO_START: usize = 0x00000000c0000000 as usize;
17-
pub const MMIO_END: usize = 0x00000000c0000fff as usize;
16+
pub const MMIO_START: usize = 0x00000000c0000000;
17+
pub const MMIO_END: usize = 0x00000000c0000fff;
1818
const IRQ_NUMBER: u32 = 12;
1919

2020
static mut MMIO_DRIVERS: Vec<MmioDriver> = Vec::new();

src/arch/x86_64/kernel/pci.rs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
use num_derive::{FromPrimitive, ToPrimitive};
2+
13
use crate::arch::x86_64::mm::{PhysAddr, VirtAddr};
24
use crate::collections::irqsave;
35
use crate::drivers::net::rtl8139::{self, RTL8139Driver};

src/arch/x86_64/kernel/vga.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -25,8 +25,8 @@ struct VgaCharacter {
2525
impl VgaCharacter {
2626
const fn new(character: u8, attribute: u8) -> Self {
2727
Self {
28-
character: character,
29-
attribute: attribute,
28+
character,
29+
attribute,
3030
}
3131
}
3232
}

src/drivers/net/rtl8139.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ use crate::arch::kernel::percore::increment_irq_counter;
1212
use crate::arch::mm::paging::virt_to_phys;
1313
use crate::arch::mm::VirtAddr;
1414
use crate::drivers::error::DriverError;
15-
use crate::drivers::net::{netwakeup, network_irqhandler, NetworkInterface};
15+
use crate::drivers::net::{network_irqhandler, NetworkInterface};
1616
use crate::x86::io::*;
1717

1818
/// size of the receive buffer
@@ -351,7 +351,7 @@ impl NetworkInterface for RTL8139Driver {
351351
if ret {
352352
// handle incoming packets
353353
#[cfg(not(feature = "newlib"))]
354-
netwakeup();
354+
crate::drivers::net::netwakeup();
355355
}
356356

357357
unsafe {

src/drivers/net/virtio_mmio.rs

Lines changed: 7 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -58,9 +58,8 @@ impl NetDevCfgRaw {
5858
loop {
5959
let before = read_volatile(&self.config_generation);
6060
_mm_mfence();
61-
for i in 0..6 {
62-
mac[i] = read_volatile(&self.mac[i]);
63-
}
61+
let mut src = self.mac.iter();
62+
mac.fill_with(|| read_volatile(src.next().unwrap()));
6463
_mm_mfence();
6564
let after = read_volatile(&self.config_generation);
6665

@@ -117,17 +116,17 @@ impl VirtioNetDriver {
117116
unsafe { &*(((registers as *const _ as usize) + 0xFC) as *const NetDevCfgRaw) };
118117
let dev_cfg = NetDevCfg {
119118
raw: dev_cfg_raw,
120-
dev_id: dev_id,
119+
dev_id,
121120
features: FeatureSet::new(0),
122121
};
123122
let isr_stat = IsrStatus::new(registers);
124123
let notif_cfg = NotifCfg::new(registers);
125124

126125
Ok(VirtioNetDriver {
127-
dev_cfg: dev_cfg,
126+
dev_cfg,
128127
com_cfg: ComCfg::new(registers, 1),
129-
isr_stat: isr_stat,
130-
notif_cfg: notif_cfg,
128+
isr_stat,
129+
notif_cfg,
131130
ctrl_vq: CtrlQueue::new(None),
132131
recv_vqs: RxQueues::new(
133132
Vec::<Rc<Virtq>>::new(),
@@ -141,7 +140,7 @@ impl VirtioNetDriver {
141140
false,
142141
),
143142
num_vqs: 0,
144-
irq: irq,
143+
irq,
145144
})
146145
}
147146

src/drivers/virtio/transport/mmio.rs

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ use crate::drivers::net::network_irqhandler;
2626
// one MUST adjust the associated From<u32>
2727
// implementation, in order catch all cases correctly,
2828
// as this function uses the catch-all "_" case!
29-
#[allow(non_camel_case_types)]
29+
#[allow(non_camel_case_types, clippy::upper_case_acronyms)]
3030
#[derive(Debug, PartialEq, Eq, PartialOrd, Ord, Clone, Copy)]
3131
#[repr(u32)]
3232
pub enum DevId {
@@ -136,8 +136,8 @@ impl ComCfg {
136136
self.com_cfg.get_max_queue_size(sel)
137137
}
138138

139-
pub fn is_queue_ready(&mut self, sel: u32) -> bool {
140-
self.com_cfg.is_queue_ready(sel)
139+
pub fn get_queue_ready(&mut self, sel: u32) -> bool {
140+
self.com_cfg.get_queue_ready(sel)
141141
}
142142

143143
/// Returns the device status field.
@@ -314,7 +314,7 @@ impl IsrStatus {
314314
let ptr = &mut registers.interrupt_status as *mut _;
315315
let raw: &'static mut IsrStatusRaw = unsafe { &mut *(ptr as *mut IsrStatusRaw) };
316316

317-
IsrStatus { raw: raw }
317+
IsrStatus { raw }
318318
}
319319

320320
pub fn is_interrupt(&self) -> bool {
@@ -508,7 +508,7 @@ impl MmioRegisterLayout {
508508
}
509509
}
510510

511-
pub fn is_queue_ready(&mut self, sel: u32) -> bool {
511+
pub fn get_queue_ready(&mut self, sel: u32) -> bool {
512512
unsafe {
513513
write_volatile(&mut self.queue_sel, sel);
514514
read_volatile(&self.queue_ready) != 0

src/lib.rs

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -46,8 +46,6 @@ extern crate alloc;
4646
extern crate bitflags;
4747
#[macro_use]
4848
extern crate log;
49-
#[macro_use]
50-
extern crate num_derive;
5149
#[cfg(not(any(target_os = "none", target_os = "hermit")))]
5250
#[macro_use]
5351
extern crate std;

src/syscalls/lwip.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ use crate::synch::spinlock::SpinlockIrqSaveGuard;
55

66
/// Enables lwIP's printf to print a whole string without being interrupted by
77
/// a message from the kernel.
8-
static mut CONSOLE_GUARD: Option<SpinlockIrqSaveGuard<console::Console>> = None;
8+
static mut CONSOLE_GUARD: Option<SpinlockIrqSaveGuard<'_, console::Console>> = None;
99

1010
extern "C" fn __sys_lwip_get_errno() -> i32 {
1111
core_scheduler().get_lwip_errno()

0 commit comments

Comments
 (0)