Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

General Repository Cleanup #480

Merged
merged 18 commits into from
May 21, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions .github/buildomat/jobs/opte-api.sh
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
#: name = "opte-api"
#: variety = "basic"
#: target = "helios-2.0"
#: rust_toolchain = "nightly-2024-02-06"
#: rust_toolchain = "nightly-2024-05-12"
#: output_rules = []
#:

Expand All @@ -24,7 +24,7 @@ header "check API_VERSION"
./check-api-version.sh

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

header "analyze std"
ptime -m cargo clippy --all-targets
Expand Down
4 changes: 2 additions & 2 deletions .github/buildomat/jobs/opte-ioctl.sh
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
#: name = "opte-ioctl"
#: variety = "basic"
#: target = "helios-2.0"
#: rust_toolchain = "nightly-2024-02-06"
#: rust_toolchain = "nightly-2024-05-12"
#: output_rules = []
#:

Expand All @@ -21,7 +21,7 @@ rustc --version
cd lib/opte-ioctl

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

header "analyze"
ptime -m cargo clippy --all-targets
8 changes: 4 additions & 4 deletions .github/buildomat/jobs/opte.sh
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
#: name = "opte"
#: variety = "basic"
#: target = "helios-2.0"
#: rust_toolchain = "nightly-2024-02-06"
#: rust_toolchain = "nightly-2024-05-12"
#: output_rules = []
#:

Expand All @@ -21,7 +21,7 @@ rustc --version
cd lib/opte

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

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

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

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

header "test"
ptime -m cargo test
4 changes: 2 additions & 2 deletions .github/buildomat/jobs/opteadm.sh
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
#: name = "opteadm"
#: variety = "basic"
#: target = "helios-2.0"
#: rust_toolchain = "nightly-2024-02-06"
#: rust_toolchain = "nightly-2024-05-12"
#: output_rules = [
#: "=/work/debug/opteadm",
#: "=/work/debug/opteadm.debug.sha256",
Expand All @@ -26,7 +26,7 @@ rustc --version
pushd bin/opteadm

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

header "analyze"
ptime -m cargo clippy --all-targets
Expand Down
8 changes: 4 additions & 4 deletions .github/buildomat/jobs/oxide-vpc.sh
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
#: name = "oxide-vpc"
#: variety = "basic"
#: target = "helios-2.0"
#: rust_toolchain = "nightly-2024-02-06"
#: rust_toolchain = "nightly-2024-05-12"
#: output_rules = []
#:

Expand All @@ -21,7 +21,7 @@ rustc --version
cd lib/oxide-vpc

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

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

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

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

header "test"
ptime -m cargo test
2 changes: 1 addition & 1 deletion .github/buildomat/jobs/p5p.sh
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
#: name = "opte-p5p"
#: variety = "basic"
#: target = "helios-2.0"
#: rust_toolchain = "nightly-2024-02-06"
#: rust_toolchain = "nightly-2024-05-12"
#: output_rules = [
#: "=/out/opte.p5p",
#: "=/out/opte.p5p.sha256",
Expand Down
6 changes: 3 additions & 3 deletions .github/buildomat/jobs/xde.sh
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
#: name = "opte-xde"
#: variety = "basic"
#: target = "helios-2.0"
#: rust_toolchain = "nightly-2024-02-06"
#: rust_toolchain = "nightly-2024-05-12"
#: output_rules = [
#: "=/work/debug/xde.dbg",
#: "=/work/debug/xde.dbg.sha256",
Expand Down Expand Up @@ -75,7 +75,7 @@ pushd xde
cp xde.conf /work/xde.conf

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

header "analyze"
ptime -m cargo clippy -- \
Expand Down Expand Up @@ -123,7 +123,7 @@ sha256sum $REL_TGT/xde_link.so > $REL_TGT/xde_link.so.sha256

header "build xde integration tests"
pushd xde-tests
cargo +nightly-2024-02-06 fmt -- --check
cargo +nightly-2024-05-12 fmt -- --check
cargo clippy --all-targets
cargo build --test loopback
loopback_test=$(
Expand Down
2 changes: 1 addition & 1 deletion bench/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ rand.workspace = true
opte.workspace = true
opte-test-utils.workspace = true
oxide-vpc.workspace = true
serde = { default_features = true, workspace = true }
serde = { default-features = true, workspace = true }
serde_json.workspace = true

[dev-dependencies]
Expand Down
9 changes: 5 additions & 4 deletions bin/opteadm/src/bin/opteadm.rs
Original file line number Diff line number Diff line change
Expand Up @@ -433,6 +433,7 @@ fn opte_pkg_version() -> String {
format!("{MAJOR_VERSION}.{API_VERSION}.{COMMIT_COUNT}")
}

#[allow(clippy::write_literal)]
fn print_port_header(t: &mut impl Write) -> std::io::Result<()> {
writeln!(
t,
Expand Down Expand Up @@ -462,7 +463,7 @@ fn print_port(t: &mut impl Write, pi: PortInfo) -> std::io::Result<()> {
t,
"{}\t{}\t{}\t{}\t{}\t{}\t{}\t{}\t{}",
pi.name,
pi.mac_addr.to_string(),
pi.mac_addr,
pi.ip4_addr.map(|x| x.to_string()).unwrap_or_else(|| none.clone()),
pi.ephemeral_ip4_addr
.map(|x| x.to_string())
Expand Down Expand Up @@ -492,12 +493,12 @@ fn print_port(t: &mut impl Write, pi: PortInfo) -> std::io::Result<()> {
.as_ref()
.and_then(|vec| vec.get(i))
.map(|x| x.to_string())
.unwrap_or_else(String::new),
.unwrap_or_default(),
pi.floating_ip6_addrs
.as_ref()
.and_then(|vec| vec.get(i))
.map(|x| x.to_string())
.unwrap_or_else(String::new),
.unwrap_or_default(),
)?;
}

Expand Down Expand Up @@ -531,7 +532,7 @@ fn main() -> anyhow::Result<()> {
Command::DumpLayer { port, name } => {
let resp = &hdl.get_layer_by_name(&port, &name)?;
print!("Port {port} - ");
print_layer(&resp)?;
print_layer(resp)?;
}

Command::ClearUft { port } => {
Expand Down
4 changes: 2 additions & 2 deletions crates/derror-macro/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ pub fn derive_derror(

let parsed_args = match Args::from_derive_input(&derive_input) {
Ok(o) => o,
Err(e) => return TokenStream::from(e.write_errors()).into(),
Err(e) => return e.write_errors().into(),
};

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

// TODO: use c"" from Rust 1.77 onwards, and when syn gets that.
// TODO: use c"" once proc_macro_c_str_literals (https://github.com/rust-lang/rust/issues/119750) stabilised.
cstr_decls.push(quote! {
static #static_name: &CStr = if let Ok(s) = CStr::from_bytes_with_nul(#static_name_val) {
s
Expand Down
6 changes: 2 additions & 4 deletions crates/illumos-sys-hdrs/src/kernel.rs
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,6 @@ impl ddi_reset_cmd_t {

// TODO Technically this is not a "raw" interface. This should live
// somewhere else.
use core::ptr;
impl kmutex_t {
pub fn new(mtype: kmutex_type_t) -> Self {
let mut kmutex = kmutex_t { _opaque: 0 };
Expand Down Expand Up @@ -376,7 +375,7 @@ pub const DDI_IPL_10: c_int = 10;

pub const DDI_SUCCESS: c_int = 0;
pub const DDI_FAILURE: c_int = -1;
pub const DDI_PSEUDO: *const c_char = b"ddi_pseudo\0".as_ptr() as *const c_char;
pub const DDI_PSEUDO: *const c_char = c"ddi_pseudo".as_ptr();

pub const KM_SLEEP: i32 = 0x0000;
pub const KM_NOSLEEP: i32 = 0x0001;
Expand All @@ -387,8 +386,7 @@ pub const S_IFCHR: c_int = 0x2000;

pub const MAC_VERSION_V1: c_int = 0x1;
pub const MAC_VERSION: c_int = MAC_VERSION_V1;
pub const MAC_PLUGIN_IDENT_ETHER: *const c_char =
b"mac_ether\0".as_ptr() as *const c_char;
pub const MAC_PLUGIN_IDENT_ETHER: *const c_char = c"mac_ether".as_ptr();

pub type periodic_cb = unsafe extern "C" fn(arg: *mut c_void);

Expand Down
1 change: 0 additions & 1 deletion crates/opte-api/src/dns.rs
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@
use alloc::str;
use alloc::string::String;
use alloc::vec::Vec;
use core::convert::TryFrom;
use core::fmt;
use core::str::FromStr;
use serde::Deserialize;
Expand Down
1 change: 0 additions & 1 deletion crates/opte-api/src/ip.rs
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@ use crate::DomainName;
use alloc::string::String;
use alloc::string::ToString;
use alloc::vec::Vec;
use core::convert::AsRef;
use core::fmt;
use core::fmt::Debug;
use core::fmt::Display;
Expand Down
2 changes: 1 addition & 1 deletion crates/opte-api/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ pub use ulp::*;
///
/// We rely on CI and the check-api-version.sh script to verify that
/// this number is incremented anytime the oxide-api code changes.
pub const API_VERSION: u64 = 30;
pub const API_VERSION: u64 = 31;

/// Major version of the OPTE package.
pub const MAJOR_VERSION: u64 = 0;
Expand Down
1 change: 0 additions & 1 deletion crates/opte-api/src/mac.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@
use alloc::str::FromStr;
use alloc::string::String;
use alloc::vec::Vec;
use core::convert::AsRef;
use core::fmt;
use core::fmt::Debug;
use core::fmt::Display;
Expand Down
4 changes: 2 additions & 2 deletions lib/opte/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ repository.workspace = true
[features]
default = ["api", "std"]
api = []
engine = ["api", "dep:crc32fast", "dep:heapless", "dep:itertools", "dep:zerocopy"]
engine = ["api", "dep:crc32fast", "dep:derror-macro", "dep:heapless", "dep:itertools", "dep:zerocopy"]
kernel = ["illumos-sys-hdrs/kernel"]
# This feature indicates that OPTE is being built with std. This is
# mostly useful to consumers of the API, providing convenient methods
Expand All @@ -22,7 +22,7 @@ test-help = []
usdt = ["std", "dep:usdt"]

[dependencies]
derror-macro.workspace = true
derror-macro = { workspace = true, optional = true }
illumos-sys-hdrs.workspace = true
kstat-macro.workspace = true
opte-api.workspace = true
Expand Down
2 changes: 2 additions & 0 deletions lib/opte/build.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
fn main() {
println!("cargo:rerun-if-changed=build.rs");
println!("cargo::rustc-check-cfg=cfg(usdt_stable_asm)");
println!("cargo::rustc-check-cfg=cfg(usdt_stable_asm_sym)");

if version_check::is_min_version("1.59").unwrap_or(false) {
println!("cargo:rustc-cfg=usdt_stable_asm");
Expand Down
Loading