Skip to content

Commit 6a6abb2

Browse files
authored
General Repository Cleanup (#480)
This PR brings some code cleanliness changes and a bugfix: * Make use of the new `addr_of_mut!()`/`addr_of!()` macros where shared mutable statics are used as part of MAC registration. * Convert CStrs into `c""` syntax post-rust 1.77.0 (for non-bindgen code, at least). * Fix up clippy lints which have piled up, most recently the 'redundant import' checks. * Fix an issue where all TCP packets + sizes would be recorded on the 'inbound' stats. * Prevent `derror_macro` from being pulled into Omicron's lockfile. I spent a little time looking into the non-Send+Sync in Arc clippy lints, but those will require a separate PR to assess the safety of `impl Send+Sync` on, e.g., `KStatNamed`.
1 parent 341d423 commit 6a6abb2

File tree

38 files changed

+110
-121
lines changed

38 files changed

+110
-121
lines changed

.github/buildomat/jobs/opte-api.sh

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
#: name = "opte-api"
44
#: variety = "basic"
55
#: target = "helios-2.0"
6-
#: rust_toolchain = "nightly-2024-02-06"
6+
#: rust_toolchain = "nightly-2024-05-12"
77
#: output_rules = []
88
#:
99

@@ -24,7 +24,7 @@ header "check API_VERSION"
2424
./check-api-version.sh
2525

2626
header "check style"
27-
ptime -m cargo +nightly-2024-02-06 fmt -- --check
27+
ptime -m cargo +nightly-2024-05-12 fmt -- --check
2828

2929
header "analyze std"
3030
ptime -m cargo clippy --all-targets

.github/buildomat/jobs/opte-ioctl.sh

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
#: name = "opte-ioctl"
44
#: variety = "basic"
55
#: target = "helios-2.0"
6-
#: rust_toolchain = "nightly-2024-02-06"
6+
#: rust_toolchain = "nightly-2024-05-12"
77
#: output_rules = []
88
#:
99

@@ -21,7 +21,7 @@ rustc --version
2121
cd lib/opte-ioctl
2222

2323
header "check style"
24-
ptime -m cargo +nightly-2024-02-06 fmt -- --check
24+
ptime -m cargo +nightly-2024-05-12 fmt -- --check
2525

2626
header "analyze"
2727
ptime -m cargo clippy --all-targets

.github/buildomat/jobs/opte.sh

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
#: name = "opte"
44
#: variety = "basic"
55
#: target = "helios-2.0"
6-
#: rust_toolchain = "nightly-2024-02-06"
6+
#: rust_toolchain = "nightly-2024-05-12"
77
#: output_rules = []
88
#:
99

@@ -21,7 +21,7 @@ rustc --version
2121
cd lib/opte
2222

2323
header "check style"
24-
ptime -m cargo +nightly-2024-02-06 fmt -- --check
24+
ptime -m cargo +nightly-2024-05-12 fmt -- --check
2525

2626
header "check docs"
2727
#
@@ -30,13 +30,13 @@ header "check docs"
3030
#
3131
# Use nightly which is needed for the `kernel` feature.
3232
RUSTDOCFLAGS="-D warnings" ptime -m \
33-
cargo +nightly-2024-02-06 doc --no-default-features --features=api,std,engine,kernel
33+
cargo +nightly-2024-05-12 doc --no-default-features --features=api,std,engine,kernel
3434

3535
header "analyze std + api"
3636
ptime -m cargo clippy --all-targets
3737

3838
header "analyze no_std + engine + kernel"
39-
ptime -m cargo +nightly-2024-02-06 clippy --no-default-features --features engine,kernel
39+
ptime -m cargo +nightly-2024-05-12 clippy --no-default-features --features engine,kernel
4040

4141
header "test"
4242
ptime -m cargo test

.github/buildomat/jobs/opteadm.sh

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
#: name = "opteadm"
44
#: variety = "basic"
55
#: target = "helios-2.0"
6-
#: rust_toolchain = "nightly-2024-02-06"
6+
#: rust_toolchain = "nightly-2024-05-12"
77
#: output_rules = [
88
#: "=/work/debug/opteadm",
99
#: "=/work/debug/opteadm.debug.sha256",
@@ -26,7 +26,7 @@ rustc --version
2626
pushd bin/opteadm
2727

2828
header "check style"
29-
ptime -m cargo +nightly-2024-02-06 fmt -- --check
29+
ptime -m cargo +nightly-2024-05-12 fmt -- --check
3030

3131
header "analyze"
3232
ptime -m cargo clippy --all-targets

.github/buildomat/jobs/oxide-vpc.sh

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
#: name = "oxide-vpc"
44
#: variety = "basic"
55
#: target = "helios-2.0"
6-
#: rust_toolchain = "nightly-2024-02-06"
6+
#: rust_toolchain = "nightly-2024-05-12"
77
#: output_rules = []
88
#:
99

@@ -21,7 +21,7 @@ rustc --version
2121
cd lib/oxide-vpc
2222

2323
header "check style"
24-
ptime -m cargo +nightly-2024-02-06 fmt -- --check
24+
ptime -m cargo +nightly-2024-05-12 fmt -- --check
2525

2626
header "check docs"
2727
#
@@ -30,13 +30,13 @@ header "check docs"
3030
#
3131
# Use nightly which is needed for the `kernel` feature.
3232
RUSTDOCFLAGS="-D warnings" ptime -m \
33-
cargo +nightly-2024-02-06 doc --no-default-features --features=api,std,engine,kernel
33+
cargo +nightly-2024-05-12 doc --no-default-features --features=api,std,engine,kernel
3434

3535
header "analyze std + api + usdt"
3636
ptime -m cargo clippy --features usdt --all-targets
3737

3838
header "analyze no_std + engine + kernel"
39-
ptime -m cargo +nightly-2024-02-06 clippy --no-default-features --features engine,kernel
39+
ptime -m cargo +nightly-2024-05-12 clippy --no-default-features --features engine,kernel
4040

4141
header "test"
4242
ptime -m cargo test

.github/buildomat/jobs/p5p.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
#: name = "opte-p5p"
44
#: variety = "basic"
55
#: target = "helios-2.0"
6-
#: rust_toolchain = "nightly-2024-02-06"
6+
#: rust_toolchain = "nightly-2024-05-12"
77
#: output_rules = [
88
#: "=/out/opte.p5p",
99
#: "=/out/opte.p5p.sha256",

.github/buildomat/jobs/xde.sh

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
#: name = "opte-xde"
44
#: variety = "basic"
55
#: target = "helios-2.0"
6-
#: rust_toolchain = "nightly-2024-02-06"
6+
#: rust_toolchain = "nightly-2024-05-12"
77
#: output_rules = [
88
#: "=/work/debug/xde.dbg",
99
#: "=/work/debug/xde.dbg.sha256",
@@ -75,7 +75,7 @@ pushd xde
7575
cp xde.conf /work/xde.conf
7676

7777
header "check style"
78-
ptime -m cargo +nightly-2024-02-06 fmt -p xde -p xde-link -- --check
78+
ptime -m cargo +nightly-2024-05-12 fmt -p xde -p xde-link -- --check
7979

8080
header "analyze"
8181
ptime -m cargo clippy -- \
@@ -123,7 +123,7 @@ sha256sum $REL_TGT/xde_link.so > $REL_TGT/xde_link.so.sha256
123123

124124
header "build xde integration tests"
125125
pushd xde-tests
126-
cargo +nightly-2024-02-06 fmt -- --check
126+
cargo +nightly-2024-05-12 fmt -- --check
127127
cargo clippy --all-targets
128128
cargo build --test loopback
129129
loopback_test=$(

bench/Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ rand.workspace = true
2121
opte.workspace = true
2222
opte-test-utils.workspace = true
2323
oxide-vpc.workspace = true
24-
serde = { default_features = true, workspace = true }
24+
serde = { default-features = true, workspace = true }
2525
serde_json.workspace = true
2626

2727
[dev-dependencies]

bin/opteadm/src/bin/opteadm.rs

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -433,6 +433,7 @@ fn opte_pkg_version() -> String {
433433
format!("{MAJOR_VERSION}.{API_VERSION}.{COMMIT_COUNT}")
434434
}
435435

436+
#[allow(clippy::write_literal)]
436437
fn print_port_header(t: &mut impl Write) -> std::io::Result<()> {
437438
writeln!(
438439
t,
@@ -462,7 +463,7 @@ fn print_port(t: &mut impl Write, pi: PortInfo) -> std::io::Result<()> {
462463
t,
463464
"{}\t{}\t{}\t{}\t{}\t{}\t{}\t{}\t{}",
464465
pi.name,
465-
pi.mac_addr.to_string(),
466+
pi.mac_addr,
466467
pi.ip4_addr.map(|x| x.to_string()).unwrap_or_else(|| none.clone()),
467468
pi.ephemeral_ip4_addr
468469
.map(|x| x.to_string())
@@ -492,12 +493,12 @@ fn print_port(t: &mut impl Write, pi: PortInfo) -> std::io::Result<()> {
492493
.as_ref()
493494
.and_then(|vec| vec.get(i))
494495
.map(|x| x.to_string())
495-
.unwrap_or_else(String::new),
496+
.unwrap_or_default(),
496497
pi.floating_ip6_addrs
497498
.as_ref()
498499
.and_then(|vec| vec.get(i))
499500
.map(|x| x.to_string())
500-
.unwrap_or_else(String::new),
501+
.unwrap_or_default(),
501502
)?;
502503
}
503504

@@ -531,7 +532,7 @@ fn main() -> anyhow::Result<()> {
531532
Command::DumpLayer { port, name } => {
532533
let resp = &hdl.get_layer_by_name(&port, &name)?;
533534
print!("Port {port} - ");
534-
print_layer(&resp)?;
535+
print_layer(resp)?;
535536
}
536537

537538
Command::ClearUft { port } => {

crates/derror-macro/src/lib.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,7 @@ pub fn derive_derror(
5959

6060
let parsed_args = match Args::from_derive_input(&derive_input) {
6161
Ok(o) => o,
62-
Err(e) => return TokenStream::from(e.write_errors()).into(),
62+
Err(e) => return e.write_errors().into(),
6363
};
6464

6565
let DeriveInput { ident, data, .. } = derive_input;
@@ -82,7 +82,7 @@ pub fn derive_derror(
8282
let static_name_val =
8383
syn::LitByteStr::new(&var_name_bytes, var_name.span());
8484

85-
// TODO: use c"" from Rust 1.77 onwards, and when syn gets that.
85+
// TODO: use c"" once proc_macro_c_str_literals (https://github.com/rust-lang/rust/issues/119750) stabilised.
8686
cstr_decls.push(quote! {
8787
static #static_name: &CStr = if let Ok(s) = CStr::from_bytes_with_nul(#static_name_val) {
8888
s

0 commit comments

Comments
 (0)