Skip to content

Commit

Permalink
Begin removing/disabling wildcard imports.
Browse files Browse the repository at this point in the history
This starts with the "core" code in sys, test, and jefe, and works out
from there.

Any package can opt into this at any time by adding this to its
Cargo.toml:

    [lints]
    workspace = true

This will also cause it to pick up any future lints we decide on.
  • Loading branch information
cbiffle committed Apr 17, 2024
1 parent 875a07a commit 422a11b
Show file tree
Hide file tree
Showing 25 changed files with 176 additions and 99 deletions.
3 changes: 3 additions & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -135,3 +135,6 @@ tlvc = { git = "https://github.com/oxidecomputer/tlvc", default-features = false
tlvc-text = { git = "https://github.com/oxidecomputer/tlvc", default-features = false, version = "0.3.0" }
transceiver-messages = { git = "https://github.com/oxidecomputer/transceiver-control/", default-features = false}
vsc7448-pac = { git = "https://github.com/oxidecomputer/vsc7448", default-features = false }

[workspace.lints.clippy]
wildcard_imports = "deny"
3 changes: 3 additions & 0 deletions lib/multitimer/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -8,3 +8,6 @@ enum-map = { workspace = true }

[target.'cfg(target_os = "none")'.dependencies]
userlib = {path = "../../sys/userlib"}

[lints]
workspace = true
9 changes: 5 additions & 4 deletions lib/multitimer/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -213,8 +213,8 @@ mod fakes {
use core::cell::Cell;

thread_local! {
pub static CURRENT_TIME: Cell<u64> = Cell::new(0);
pub static TIMER_SETTING: Cell<(Option<u64>, u32)> = Cell::default();
pub static CURRENT_TIME: Cell<u64> = const { Cell::new(0) };
pub static TIMER_SETTING: Cell<(Option<u64>, u32)> = const { Cell::new((None, 0)) };
}

pub fn sys_set_timer(deadline: Option<u64>, not: u32) {
Expand All @@ -239,11 +239,12 @@ mod fakes {
}
}
#[cfg(not(target_os = "none"))]
use self::fakes::*;
use self::fakes::{sys_get_timer, sys_set_timer};

#[cfg(test)]
mod tests {
use super::*;
use super::fakes::CURRENT_TIME;
use super::{sys_get_timer, EnumMap, Multitimer, Repeat, Timer};

fn change_time(time: u64) {
CURRENT_TIME.with(|t| t.set(time));
Expand Down
3 changes: 3 additions & 0 deletions sys/abi/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -9,3 +9,6 @@ bitflags = { workspace = true }
byteorder = { workspace = true }
serde = { workspace = true }
phash = { path = "../../lib/phash" }

[lints]
workspace = true
3 changes: 3 additions & 0 deletions sys/kern/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -41,3 +41,6 @@ nano = []
test = false
doctest = false
bench = false

[lints]
workspace = true
2 changes: 1 addition & 1 deletion sys/kern/src/startup.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
//! Kernel startup.
use crate::atomic::AtomicExt;
use crate::descs::*;
use crate::descs::{RegionAttributes, RegionDesc, TaskDesc, TaskFlags};
use crate::task::Task;
use core::mem::MaybeUninit;
use core::sync::atomic::{AtomicBool, Ordering};
Expand Down
3 changes: 3 additions & 0 deletions sys/kerncore/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -6,3 +6,6 @@ edition = "2021"
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html

[dependencies]

[lints]
workspace = true
3 changes: 3 additions & 0 deletions sys/num-tasks/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -13,3 +13,6 @@ task-enum = []
test = false
doctest = false
bench = false

[lints]
workspace = true
3 changes: 3 additions & 0 deletions sys/userlib/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -51,3 +51,6 @@ build-util = { path = "../../build/util" }
test = false
doctest = false
bench = false

[lints]
workspace = true
3 changes: 3 additions & 0 deletions task/jefe/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -39,3 +39,6 @@ name = "task-jefe"
test = false
doctest = false
bench = false

[lints]
workspace = true
13 changes: 8 additions & 5 deletions task/jefe/src/dump.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,9 @@
use crate::generated::{DUMP_ADDRESS_MAX, DUMP_ADDRESS_MIN, DUMP_AREAS};
use humpty::{DumpArea, DumpContents};
use ringbuf::*;
use ringbuf::{ringbuf, ringbuf_entry};
use task_jefe_api::DumpAgentError;
use userlib::*;
use userlib::{kipc, TaskDumpRegion, UnwrapLite};

#[cfg(all(
armv8m,
Expand Down Expand Up @@ -182,14 +182,17 @@ fn dump_task_setup(
/// Once a task dump is set up, this function executes it
fn dump_task_run(base: u32, task: usize) -> Result<(), DumpAgentError> {
ringbuf_entry!(Trace::DumpStart { base });
let start = sys_get_timer().now;
let start = userlib::sys_get_timer().now;

//
// The humpty dance is your chance... to do the dump!
//
let r = humpty::dump::<(), 512, { humpty::DUMPER_JEFE }>(
base,
Some(humpty::DumpTask::new(task as u16, sys_get_timer().now)),
Some(humpty::DumpTask::new(
task as u16,
userlib::sys_get_timer().now,
)),
|| Ok(None),
|addr, buf, meta| {
ringbuf_entry!(Trace::DumpReading {
Expand Down Expand Up @@ -232,7 +235,7 @@ fn dump_task_run(base: u32, task: usize) -> Result<(), DumpAgentError> {
ringbuf_entry!(Trace::DumpDone(r));
ringbuf_entry!(Trace::DumpTime {
start,
end: sys_get_timer().now
end: userlib::sys_get_timer().now
});

r.map_err(|_| DumpAgentError::DumpFailed)?;
Expand Down
4 changes: 2 additions & 2 deletions task/jefe/src/external.rs
Original file line number Diff line number Diff line change
Expand Up @@ -50,8 +50,8 @@ use core::sync::atomic::{AtomicU32, Ordering};
#[allow(unused_imports)]
use armv6m_atomic_hack::AtomicU32Ext;

use ringbuf::*;
use userlib::*;
use ringbuf::{ringbuf, ringbuf_entry};
use userlib::{kipc, FromPrimitive};

/// The actual requests that we honor from an external source entity
#[derive(FromPrimitive, Copy, Clone, Debug, Eq, PartialEq)]
Expand Down
12 changes: 6 additions & 6 deletions task/jefe/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ use hubris_num_tasks::NUM_TASKS;
use humpty::DumpArea;
use idol_runtime::RequestError;
use task_jefe_api::{DumpAgentError, ResetReason};
use userlib::*;
use userlib::{kipc, Generation, TaskId};

#[derive(Copy, Clone, Debug, Eq, PartialEq, Default)]
pub enum Disposition {
Expand All @@ -61,7 +61,7 @@ fn main() -> ! {
}

let deadline =
set_timer_relative(TIMER_INTERVAL, notifications::TIMER_MASK);
userlib::set_timer_relative(TIMER_INTERVAL, notifications::TIMER_MASK);

external::set_ready();

Expand Down Expand Up @@ -133,8 +133,8 @@ impl idl::InOrderJefeImpl for ServerImpl<'_> {
for (task, mask) in generated::MAILING_LIST {
let taskid =
TaskId::for_index_and_gen(task as usize, Generation::ZERO);
let taskid = sys_refresh_task_id(taskid);
sys_post(taskid, mask);
let taskid = userlib::sys_refresh_task_id(taskid);
userlib::sys_post(taskid, mask);
}
}
Ok(())
Expand Down Expand Up @@ -293,8 +293,8 @@ impl idol_runtime::NotificationHandler for ServerImpl<'_> {

if bits & notifications::TIMER_MASK != 0 {
// If our timer went off, we need to reestablish it
if sys_get_timer().now >= self.deadline {
self.deadline = set_timer_relative(
if userlib::sys_get_timer().now >= self.deadline {
self.deadline = userlib::set_timer_relative(
TIMER_INTERVAL,
notifications::TIMER_MASK,
);
Expand Down
3 changes: 3 additions & 0 deletions test/test-api/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -17,3 +17,6 @@ build-util = { path = "../../build/util" }
test = false
doctest = false
bench = false

[lints]
workspace = true
2 changes: 1 addition & 1 deletion test/test-api/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

#![no_std]

use userlib::*;
use userlib::FromPrimitive;

/// Operations that are performed by the test-assist
#[derive(FromPrimitive, Debug, Eq, PartialEq)]
Expand Down
3 changes: 3 additions & 0 deletions test/test-assist/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -22,3 +22,6 @@ name = "test-assist"
test = false
doctest = false
bench = false

[lints]
workspace = true
6 changes: 4 additions & 2 deletions test/test-assist/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,10 @@

use core::arch::asm;
use hubris_num_tasks::NUM_TASKS;
use test_api::*;
use userlib::*;
use test_api::AssistOp;
use userlib::{
hl, kipc, sys_refresh_task_id, sys_send, Generation, Lease, TaskId,
};
use zerocopy::AsBytes;

#[inline(never)]
Expand Down
3 changes: 3 additions & 0 deletions test/test-idol-api/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -22,3 +22,6 @@ bench = false

[build-dependencies]
idol = { workspace = true }

[lints]
workspace = true
2 changes: 1 addition & 1 deletion test/test-idol-api/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@

use derive_idol_err::IdolError;
use serde::{Deserialize, Serialize};
use userlib::*;
use userlib::{sys_send, FromPrimitive};

#[derive(
Copy, Clone, Debug, Eq, PartialEq, FromPrimitive, IdolError, counters::Count,
Expand Down
3 changes: 3 additions & 0 deletions test/test-idol-server/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -24,3 +24,6 @@ name = "test-idol-server"
test = false
doctest = false
bench = false

[lints]
workspace = true
5 changes: 3 additions & 2 deletions test/test-idol-server/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@

use idol_runtime::{NotificationHandler, RequestError};
use test_idol_api::{FancyTestType, IdolTestError, SocketName, UdpMetadata};
use userlib::*;
use userlib::RecvMessage;

struct ServerImpl;

Expand Down Expand Up @@ -103,7 +103,8 @@ fn main() -> ! {
}

mod idl {
use super::*;
use super::FancyTestType;
use test_idol_api::{IdolTestError, SocketName, UdpMetadata};

include!(concat!(env!("OUT_DIR"), "/server_stub.rs"));
}
3 changes: 3 additions & 0 deletions test/test-runner/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -25,3 +25,6 @@ name = "test-runner"
test = false
doctest = false
bench = false

[lints]
workspace = true
6 changes: 3 additions & 3 deletions test/test-runner/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -48,9 +48,9 @@
#![no_std]
#![no_main]

use ringbuf::*;
use test_api::*;
use userlib::*;
use ringbuf::{ringbuf, ringbuf_entry};
use test_api::{RunnerOp, TestResult};
use userlib::{hl, kipc, TaskId, TaskState};

/// We are sensitive to all notifications, to catch unexpected ones in test.
const ALL_NOTIFICATIONS: u32 = !0;
Expand Down
3 changes: 3 additions & 0 deletions test/test-suite/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -32,3 +32,6 @@ name = "test-suite"
test = false
doctest = false
bench = false

[lints]
workspace = true
Loading

0 comments on commit 422a11b

Please sign in to comment.