Skip to content

Commit 79e0160

Browse files
Dan Crossorangecms
Dan Cross
authored andcommitted
trivial: fix clippy lints
Signed-off-by: Dan Cross <cross@gajendra.net>
1 parent b646f0f commit 79e0160

File tree

11 files changed

+31
-16
lines changed

11 files changed

+31
-16
lines changed

aarch64/src/devcons.rs

+6-3
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22

33
use crate::param::KZERO;
44
use crate::uartmini::MiniUart;
5+
use core::cell::SyncUnsafeCell;
56
use core::mem::MaybeUninit;
67
use port::devcons::Console;
78
use port::fdt::DeviceTree;
@@ -36,10 +37,12 @@ pub fn init(dt: &DeviceTree) {
3637
let uart = MiniUart::new(dt, KZERO);
3738
uart.init();
3839

39-
static mut UART: MaybeUninit<MiniUart> = MaybeUninit::uninit();
40+
static UART: SyncUnsafeCell<MaybeUninit<MiniUart>> =
41+
SyncUnsafeCell::new(MaybeUninit::uninit());
4042
unsafe {
41-
UART.write(uart);
42-
UART.assume_init_mut()
43+
let cons = &mut *UART.get();
44+
cons.write(uart);
45+
cons.assume_init_mut()
4346
}
4447
});
4548
}

aarch64/src/mailbox.rs

+6-3
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
use crate::io::{read_reg, write_reg};
22
use crate::param::KZERO;
3+
use core::cell::SyncUnsafeCell;
34
use core::mem::MaybeUninit;
45
use port::fdt::DeviceTree;
56
use port::mcslock::{Lock, LockNode};
@@ -21,10 +22,12 @@ pub fn init(dt: &DeviceTree) {
2122
let node = LockNode::new();
2223
let mut mailbox = MAILBOX.lock(&node);
2324
*mailbox = Some({
24-
static mut MAYBE_MAILBOX: MaybeUninit<Mailbox> = MaybeUninit::uninit();
25+
static MAYBE_MAILBOX: SyncUnsafeCell<MaybeUninit<Mailbox>> =
26+
SyncUnsafeCell::new(MaybeUninit::uninit());
2527
unsafe {
26-
MAYBE_MAILBOX.write(Mailbox::new(dt, KZERO));
27-
MAYBE_MAILBOX.assume_init_mut()
28+
let maybe_mailbox = &mut *MAYBE_MAILBOX.get();
29+
maybe_mailbox.write(Mailbox::new(dt, KZERO));
30+
maybe_mailbox.assume_init_mut()
2831
}
2932
});
3033
}

aarch64/src/main.rs

+1
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
#![feature(alloc_error_handler)]
66
#![feature(core_intrinsics)]
77
#![feature(strict_provenance)]
8+
#![feature(sync_unsafe_cell)]
89
#![forbid(unsafe_op_in_unsafe_fn)]
910

1011
mod devcons;

port/src/allocator.rs

+2
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,8 @@
55
// license that can be found in the LICENSE file or at
66
// https://opensource.org/licenses/MIT.
77

8+
#![allow(clippy::too_long_first_doc_paragraph)]
9+
810
use alloc::alloc::{AllocError, Allocator, Layout};
911
use core::ptr::NonNull;
1012
use core::sync::atomic::{AtomicUsize, Ordering};

port/src/fdt.rs

+3-1
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
#![allow(clippy::too_long_first_doc_paragraph)]
2+
13
use core::{
24
ffi::CStr,
35
mem::{self, MaybeUninit},
@@ -173,7 +175,7 @@ impl<'a> DeviceTree<'a> {
173175
}
174176
let (start, end) = (value_i, value_i + 4);
175177
value_i = end;
176-
return self.structs().get(start..end).and_then(bytes_to_u32);
178+
self.structs().get(start..end).and_then(bytes_to_u32)
177179
})
178180
}
179181

riscv64/Cargo.toml

+3
Original file line numberDiff line numberDiff line change
@@ -11,3 +11,6 @@ port = { path = "../port" }
1111

1212
[features]
1313
opensbi = []
14+
15+
[lints.rust]
16+
unexpected_cfgs = { level = "warn", check-cfg = ['cfg(platform, values("nezha"))', 'cfg(platform, values("virt"))'] }

riscv64/src/main.rs

+1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
#![feature(alloc_error_handler)]
2+
#![feature(sync_unsafe_cell)]
23
#![cfg_attr(not(any(test)), no_std)]
34
#![cfg_attr(not(test), no_main)]
45
#![allow(clippy::upper_case_acronyms)]

riscv64/src/platform/virt/devcons.rs

+6-4
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
// Racy to start.
22

3+
use core::cell::SyncUnsafeCell;
34
use core::mem::MaybeUninit;
45

56
use crate::uart16550::Uart16550;
@@ -17,11 +18,12 @@ pub fn init(dt: &DeviceTree) {
1718
let mut uart = Uart16550::new(ns16550a_reg);
1819
uart.init(115_200);
1920

20-
static mut UART: MaybeUninit<Uart16550> = MaybeUninit::uninit();
21-
21+
static CONS: SyncUnsafeCell<MaybeUninit<Uart16550>> =
22+
SyncUnsafeCell::new(MaybeUninit::uninit());
2223
unsafe {
23-
UART.write(uart);
24-
UART.assume_init_mut()
24+
let cons = &mut *CONS.get();
25+
cons.write(uart);
26+
cons.assume_init_mut()
2527
}
2628
});
2729
}

x86_64/src/devcons.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ impl Uart for Uart16550 {
1515

1616
pub fn init() {
1717
Console::new(|| {
18-
static UART: SyncUnsafeCell<Uart16550> = SyncUnsafeCell::new(Uart16550 { port: 0x3f8 });
19-
unsafe { &mut *UART.get() }
18+
static CONS: SyncUnsafeCell<Uart16550> = SyncUnsafeCell::new(Uart16550 { port: 0x3f8 });
19+
unsafe { &mut *CONS.get() }
2020
});
2121
}

x86_64/src/uart16550.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
/// Simple UART driver to get setarted.
1+
//! Simple UART driver to get started.
22
33
pub fn putb(port: u16, b: u8) {
44
unsafe {

xtask/src/config.rs

-2
Original file line numberDiff line numberDiff line change
@@ -46,8 +46,6 @@ pub struct Build {
4646
/// #[cfg(dev_foo = "baz")]
4747
/// pub mod foobaz;
4848
/// ```
49-
50-
/// config section
5149
#[derive(Debug, Serialize, Deserialize)]
5250
pub struct Config {
5351
pub dev: Option<Vec<String>>,

0 commit comments

Comments
 (0)