diff --git a/.github/actions/ci-cache/action.yml b/.github/actions/ci-cache/action.yml index f9d689934..0f84acb31 100644 --- a/.github/actions/ci-cache/action.yml +++ b/.github/actions/ci-cache/action.yml @@ -11,7 +11,7 @@ runs: steps: # It would be nice to factorize path and key. - if: inputs.mode == 'restore' - uses: actions/cache/restore@6849a6489940f00c2f30c0fb92c6274307ccb58a # v4.1.2 + uses: actions/cache/restore@1bd1e32a3bdc45362d1e726936510720a7c30a57 # v4.2.0 with: path: | ~/.cargo/bin/ @@ -23,7 +23,7 @@ runs: key: ${{ hashFiles('rust-toolchain.toml', 'scripts/wrapper.sh') }} - if: inputs.mode == 'save' id: cache - uses: actions/cache@6849a6489940f00c2f30c0fb92c6274307ccb58a # v4.1.2 + uses: actions/cache@1bd1e32a3bdc45362d1e726936510720a7c30a57 # v4.2.0 with: path: | ~/.cargo/bin/ diff --git a/.github/actions/ci-checks/action.yml b/.github/actions/ci-checks/action.yml index 36665f73e..800333ff6 100644 --- a/.github/actions/ci-checks/action.yml +++ b/.github/actions/ci-checks/action.yml @@ -38,14 +38,7 @@ runs: run: ./scripts/publish.sh --dry-run shell: bash - if: ${{ contains(fromJSON(inputs.checks), 'markdown') }} - # TODO: Keep only the last command once ubuntu-latest is 24.04. - run: | - set -x - curl -Os http://ftp.de.debian.org/debian/pool/main/r/ruby-mdl/markdownlint_0.13.0-4_all.deb - sudo apt install ruby-kramdown-parser-gfm ruby-mixlib-{cli,config,shellout} - sudo dpkg -i markdownlint_0.13.0-4_all.deb - rm markdownlint_0.13.0-4_all.deb - ./scripts/wrapper.sh mdl -g -s markdownlint.rb . + run: ./scripts/wrapper.sh mdl -g -s markdownlint.rb . shell: bash - if: ${{ contains(fromJSON(inputs.checks), 'taplo') }} run: ./scripts/ci-taplo.sh diff --git a/.github/actions/ci-footprint/action.yml b/.github/actions/ci-footprint/action.yml index 958dd9e5f..3fe8283f1 100644 --- a/.github/actions/ci-footprint/action.yml +++ b/.github/actions/ci-footprint/action.yml @@ -12,7 +12,7 @@ runs: - run: mv footprint.toml footprint-${{ github.event_name }}.toml shell: bash - if: github.event_name == 'push' && inputs.upload == 'true' - uses: actions/upload-artifact@b4b15b8c7c6ac21ea08fcf65892d2ee8f75cf882 # v4.4.3 + uses: actions/upload-artifact@6f51ac03b9356f520e9adb1b1b7802705f340c2b # v4.5.0 with: name: footprint path: footprint-push.toml diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index d4961249d..3263286ff 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -106,7 +106,7 @@ jobs: steps: - uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2 - run: ./scripts/artifacts.sh - - uses: actions/attest-build-provenance@ef244123eb79f2f7a7e75d99086184180e6d0018 # v1.4.4 + - uses: actions/attest-build-provenance@7668571508540a607bdfd90a87a560489fe372eb # v2.1.0 id: attest with: subject-path: 'artifacts/*' diff --git a/.github/workflows/scorecard.yml b/.github/workflows/scorecard.yml index 26ddeeccc..2d1171041 100644 --- a/.github/workflows/scorecard.yml +++ b/.github/workflows/scorecard.yml @@ -26,11 +26,11 @@ jobs: results_file: results.sarif results_format: sarif publish_results: true - - uses: actions/upload-artifact@b4b15b8c7c6ac21ea08fcf65892d2ee8f75cf882 # v4.4.3 + - uses: actions/upload-artifact@6f51ac03b9356f520e9adb1b1b7802705f340c2b # v4.5.0 with: name: SARIF file path: results.sarif retention-days: 5 - - uses: github/codeql-action/upload-sarif@f09c1c0a94de965c15400f5634aa42fac8fb8f88 # v3.27.5 + - uses: github/codeql-action/upload-sarif@48ab28a6f5dbc2a99bf1e0131198dd8f1df78169 # v3.28.0 with: sarif_file: results.sarif diff --git a/book/src/README.md b/book/src/README.md index 167426b71..7a6038ab6 100644 --- a/book/src/README.md +++ b/book/src/README.md @@ -1,6 +1,6 @@ # [Introduction](https://google.github.io/wasefire) -This book is a walk through the _Wasefire_ project. +This book is a walkthrough of the _Wasefire_ project. ## Vision diff --git a/book/src/applet/prelude/usb.md b/book/src/applet/prelude/usb.md index d30310dcb..07a673d76 100644 --- a/book/src/applet/prelude/usb.md +++ b/book/src/applet/prelude/usb.md @@ -43,7 +43,7 @@ We then wait until the player presses Enter. We can read a single byte from the {{#include usb.rs:ready}} ``` -To generate the next question, we use `rng::fill_bytes()` which fills a buffer with random bytes. We +To generate the next question, we use `rng::bytes()` which returns a slice of random bytes. We provide a buffer with the length of the current level. For the string to be printable we truncate the entropy of each byte from 8 to 5 bits and convert it to a `base32` symbol. diff --git a/book/src/applet/prelude/usb.rs b/book/src/applet/prelude/usb.rs index 0b9e43fe0..df4059fea 100644 --- a/book/src/applet/prelude/usb.rs +++ b/book/src/applet/prelude/usb.rs @@ -22,9 +22,9 @@ #![no_std] wasefire::applet!(); +use alloc::format; use alloc::rc::Rc; use alloc::string::String; -use alloc::{format, vec}; use core::cell::Cell; use core::time::Duration; @@ -49,13 +49,12 @@ fn main() { //{ ANCHOR: generate // Generate a question for this level. - let mut question = vec![0; level]; - rng::fill_bytes(&mut question).unwrap(); + let mut question = rng::bytes(level).unwrap(); for byte in &mut question { const BASE32: [u8; 32] = *b"ABCDEFGHIJKLMNOPQRSTUVWXYZ234567"; *byte = BASE32[(*byte & 0x1f) as usize]; } - let mut question = String::from_utf8(question).unwrap(); + let mut question = String::from_utf8(question.into()).unwrap(); //} ANCHOR_END: generate //{ ANCHOR: question diff --git a/crates/api-desc/CHANGELOG.md b/crates/api-desc/CHANGELOG.md index 6f94044ed..604529e0e 100644 --- a/crates/api-desc/CHANGELOG.md +++ b/crates/api-desc/CHANGELOG.md @@ -4,6 +4,8 @@ ### Minor +- Improve safety documentation +- Add `Api::wasm_markdown()` for top-level documentation - Use Rust edition 2024 - Use C-string literals to implement dispatch for native applets - Implement `bytemuck::Pod` for generated `Params` @@ -137,4 +139,4 @@ ## 0.1.0 - + diff --git a/crates/api-desc/Cargo.toml b/crates/api-desc/Cargo.toml index 0ddf84a96..77e16b8f4 100644 --- a/crates/api-desc/Cargo.toml +++ b/crates/api-desc/Cargo.toml @@ -70,8 +70,8 @@ internal-api-store = [] internal-api-usb = [] [lints] +clippy.literal-string-with-formatting-args = "allow" clippy.mod-module-files = "warn" clippy.unit-arg = "allow" rust.unreachable-pub = "warn" -rust.unsafe-op-in-unsafe-fn = "warn" rust.unused-crate-dependencies = "warn" diff --git a/crates/api-desc/crates/update/Cargo.toml b/crates/api-desc/crates/update/Cargo.toml index d0b260f17..b92fbe5c7 100644 --- a/crates/api-desc/crates/update/Cargo.toml +++ b/crates/api-desc/crates/update/Cargo.toml @@ -12,8 +12,8 @@ clap = { version = "4.5.4", default-features = false, features = ["derive", "std wasefire-applet-api-desc = { path = "../.." } [lints] +clippy.literal-string-with-formatting-args = "allow" clippy.mod-module-files = "warn" clippy.unit-arg = "allow" rust.unreachable-pub = "warn" -rust.unsafe-op-in-unsafe-fn = "warn" rust.unused-crate-dependencies = "warn" diff --git a/crates/api-desc/crates/update/src/main.rs b/crates/api-desc/crates/update/src/main.rs index bf41873b2..72e80b800 100644 --- a/crates/api-desc/crates/update/src/main.rs +++ b/crates/api-desc/crates/update/src/main.rs @@ -73,6 +73,15 @@ fn main() -> Result<()> { "#, )?; - Api::default().wasm(&mut output, flags.lang.into())?; + let api = Api::default(); + for line in api.wasm_markdown().lines() { + write!(&mut output, "//")?; + if !line.is_empty() { + write!(&mut output, " ")?; + } + writeln!(&mut output, "{}", line.strip_prefix("##").unwrap_or(line))?; + } + writeln!(&mut output)?; + api.wasm(&mut output, flags.lang.into())?; Ok(()) } diff --git a/crates/api-desc/src/api.md b/crates/api-desc/src/api.md new file mode 100644 index 000000000..35bf716a9 --- /dev/null +++ b/crates/api-desc/src/api.md @@ -0,0 +1,78 @@ +### Applet functions + +An applet must expose 3 functions to the platform: + +- `init: () -> ()` called exactly once before anything else. It cannot call any + platform function except `dp` (aka `debug::println()`). +- `main: () -> ()` called exactly once after `init` returns. It can call all + platform functions. +- `alloc: (size: u32, align: u32) -> (ptr: u32)` may be called during any + platform function after `init` returned. It cannot call any platform function. + A return value of zero indicates an error and will trap the applet. The applet + may assume that `size` is a non-zero multiple of `align` and `align` is either + 1, 2, or 4. + +### Platform functions + +The platform exposes many functions. Each function comes with its own +documentation, which may omit the following general properties. + +#### Parameters and result + +At WebAssembly level, all functions use `u32` (more precisely `i32`) as +parameters and result (WebAssembly permits multiple results, but platform +functions never return more than one value). However, platform functions will be +documented with more specific types to better convey the intent. + +Languages that compile to WebAssembly may use similar specific types when +binding platform functions. Those types should be compatible with `u32` in +WebAssembly. + +#### Applet closures + +Some functions (usually called `register`) may register a closure. There is +usually an associated function (usually called `unregister`) that unregisters +the registered closure. The register function takes `fn { data: *const void, ... +}` (usually called `handler_func`) and a `*const void` (usually called +`handler_data`) as arguments. The unregister function (if it exists) doesn't +have any particular parameters. + +After the closure is registered (the register function is called) and as long as +it stays registered (the unregister function is not called), the platform may +call this closure any time `sw` (aka `scheduling::wait_for_callback()`) is +called. Note that if `main` returns and there are registered closures, the +applet behaves as if `sw` is called indefinitely. + +An applet closure may call any platform function unless explicitly documented by +the register function. + +#### Reading and writing memory + +Some functions take pointers as argument (usually `*const u8` or `*mut u8`). +They either document the expected size or take an associated length argument. + +The platform may read and write (only for `*mut T` pointers) the designated +region of the WebAssembly memory during the function call. Otherwise (and by +default), platform functions don't read or write the WebAssembly memory. + +#### Allocating memory + +Finally, some functions take nested pointers as argument (usually `*mut *mut +u8`). They either return a `usize` or take a `*mut usize` as argument. + +Those functions may call `alloc` (at most once per such nested pointer argument) +with a dynamic size but fixed alignment (usually 1). If they do, they will store +the non-null result in the `*mut *mut u8` argument. Regardless of whether they +allocate or not, they store the size in the `*mut usize` argument (if it exists) +or return it (otherwise). + +Note that `alloc` will not be called with a size of zero. So if the size is zero +after the function returns, this signifies that `alloc` was not called (and the +`*mut *mut u8` not written) and the output is empty (unless otherwise documented +like in the case of an absence of output, in which case the size may not be +written). + +The caller is responsible for managing the allocation after the function returns +and the size is non-zero. To avoid memory leaks, the applet should initialize +the `*mut usize` argument (if it exists) to zero and consider having ownership +of the `*mut *mut u8` pointee if the size is non-zero after the call. diff --git a/crates/api-desc/src/lib.rs b/crates/api-desc/src/lib.rs index 12dfddf0c..2c412d13e 100644 --- a/crates/api-desc/src/lib.rs +++ b/crates/api-desc/src/lib.rs @@ -106,6 +106,10 @@ impl Api { } } + pub fn wasm_markdown(&self) -> &'static str { + include_str!("api.md") + } + pub fn wasm_rust(&self) -> TokenStream { let items: Vec<_> = self.0.iter().map(|x| x.wasm_rust()).collect(); quote!(#(#items)*) @@ -730,7 +734,7 @@ mod tests { #[test] fn link_names_are_unique() { let mut seen = HashSet::new(); - let Api(mut todo) = Api::default(); + let mut todo = Api::default().0; while let Some(item) = todo.pop() { match item { Item::Enum(_) => (), @@ -746,7 +750,7 @@ mod tests { /// This invariant is assumed by unsafe code. #[test] fn enum_values_are_valid() { - let Api(mut todo) = Api::default(); + let mut todo = Api::default().0; while let Some(item) = todo.pop() { match item { Item::Enum(Enum { variants, .. }) => { @@ -773,7 +777,7 @@ mod tests { let name = &field.name; assert!(field.type_.is_param(), "Param {name} of {link:?} is not U32"); } - let Api(mut todo) = Api::default(); + let mut todo = Api::default().0; while let Some(item) = todo.pop() { match item { Item::Enum(_) => (), @@ -786,7 +790,7 @@ mod tests { #[test] fn results_are_valid() { - let Api(mut todo) = Api::default(); + let mut todo = Api::default().0; while let Some(item) = todo.pop() { match item { Item::Enum(_) => (), diff --git a/crates/api-desc/src/platform.rs b/crates/api-desc/src/platform.rs index 3ec5f4760..39bfc147a 100644 --- a/crates/api-desc/src/platform.rs +++ b/crates/api-desc/src/platform.rs @@ -31,31 +31,21 @@ pub(crate) fn new() -> Item { update::new(), #[cfg(feature = "api-platform")] item! { - /// Returns the serial of the platform. + /// Reads the serial of the platform. /// - /// Returns the length of the serial in bytes. The serial is not allocated if the - /// length is zero (and the pointer is not written). + /// This is an [allocating function](crate#allocating-memory) returning the length. fn serial "ps" { /// Where to write the serial. - /// - /// If the returned length is positive, the (inner) pointer will be allocated by the - /// callee and must be freed by the caller. It is thus owned by the caller when the - /// function returns. ptr: *mut *mut u8, } -> usize }, #[cfg(feature = "api-platform")] item! { - /// Returns the version of the platform. + /// Reads the version of the platform. /// - /// Returns the length of the version in bytes. The version is not allocated if the - /// length is zero (and the pointer is not written). + /// This is an [allocating function](crate#allocating-memory) returning the length. fn version "pv" { /// Where to write the version. - /// - /// If the returned length is positive, the (inner) pointer will be allocated by the - /// callee and must be freed by the caller. It is thus owned by the caller when the - /// function returns. ptr: *mut *mut u8, } -> usize }, diff --git a/crates/api-desc/src/platform/protocol.rs b/crates/api-desc/src/platform/protocol.rs index 0f26df688..59817606f 100644 --- a/crates/api-desc/src/platform/protocol.rs +++ b/crates/api-desc/src/platform/protocol.rs @@ -23,12 +23,11 @@ pub(crate) fn new() -> Item { item! { /// Reads the last request, if any. /// - /// Returns whether a request was allocated. + /// Returns whether a request was read. + /// + /// This is an [allocating function](crate#allocating-memory). fn read "ppr" { /// Where to write the request, if any. - /// - /// The (inner) pointer will be allocated by the callee and must be freed by the - /// caller. It is thus owned by the caller when the function returns. ptr: *mut *mut u8, /// Where to write the length of the request, if any. diff --git a/crates/api-desc/src/platform/update.rs b/crates/api-desc/src/platform/update.rs index 23fb50b86..da911febd 100644 --- a/crates/api-desc/src/platform/update.rs +++ b/crates/api-desc/src/platform/update.rs @@ -29,9 +29,12 @@ pub(crate) fn new() -> Item { fn is_supported "pus" {} -> bool }, item! { - /// Returns the metadata of the platform. + /// Reads the metadata of the platform. /// - /// This typically contains the version and side (A or B) of the running platform. + /// The metadata typically contains the version and side (A or B) of the running + /// platform. + /// + /// This is an [allocating function](crate#allocating-memory). fn metadata "pum" { /// Where to write the allocated metadata. ptr: *mut *mut u8, diff --git a/crates/api-desc/src/store.rs b/crates/api-desc/src/store.rs index 50daf3de5..3d4d762cf 100644 --- a/crates/api-desc/src/store.rs +++ b/crates/api-desc/src/store.rs @@ -56,14 +56,13 @@ pub(crate) fn new() -> Item { /// Finds an entry in the store, if any. /// /// Returns whether an entry was found. + /// + /// This is an [allocating function](crate#allocating-memory). fn find "sf" { /// Key of the entry to find. key: usize, /// Where to write the value of the entry, if found. - /// - /// The (inner) pointer will be allocated by the callee and must be freed by the - /// caller. It is thus owned by the caller when the function returns. ptr: *mut *mut u8, /// Where to write the length of the value, if found. @@ -74,13 +73,10 @@ pub(crate) fn new() -> Item { item! { /// Returns the unordered keys of the entries in the store. /// - /// Returns the number of keys, and thus the length of the array. The array is not - /// allocated if the length is zero (and the pointer is not written). + /// This is an [allocating function](crate#allocating-memory) returning the number of + /// keys (thus half the number of allocated bytes). fn keys "sk" { - /// Where to write the keys as an array of u16, if at least one. - /// - /// The (inner) pointer will be allocated by the callee and must be freed by the - /// caller. It is thus owned by the caller when the function returns. + /// Where to write the keys as an array of u16. ptr: *mut *mut u8, } -> usize }, diff --git a/crates/api-desc/src/store/fragment.rs b/crates/api-desc/src/store/fragment.rs index ae9e6a0b5..18fec072d 100644 --- a/crates/api-desc/src/store/fragment.rs +++ b/crates/api-desc/src/store/fragment.rs @@ -57,14 +57,13 @@ pub(crate) fn new() -> Item { /// The entry may be fragmented withen the provided range. /// /// Returns whether an entry was found. + /// + /// This is an [allocating function](crate#allocating-memory). fn find "sff" { /// Range of keys to concatenate as an entry. keys: u32, /// Where to write the value of the entry, if found. - /// - /// The (inner) pointer will be allocated by the callee and must be freed by the - /// caller. It is thus owned by the caller when the function returns. ptr: *mut *mut u8, /// Where to write the length of the value, if found. diff --git a/crates/api-desc/src/timer.rs b/crates/api-desc/src/timer.rs index c17387c8b..4c8f3a242 100644 --- a/crates/api-desc/src/timer.rs +++ b/crates/api-desc/src/timer.rs @@ -32,6 +32,9 @@ pub(crate) fn new() -> Item { }, item! { /// Allocates a timer (initially stopped) and returns its identifier. + /// + /// This is a [register function](crate#applet-closures). The associated unregister + /// function is [`free()`]. fn allocate "ta" { /// Function called when the timer triggers. handler_func: fn { data: *const void }, @@ -63,14 +66,14 @@ pub(crate) fn new() -> Item { /// Note that if the timer triggers while being stopped, the handler may still be /// called. fn stop "tc" { - /// The identifier of the timer to start. + /// The identifier of the timer to stop. id: usize, } -> () }, item! { /// Deallocates a stopped timer given its identifier. fn free "td" { - /// The identifier of the timer to start. + /// The identifier of the timer to free. id: usize, } -> () }, diff --git a/crates/api-macro/CHANGELOG.md b/crates/api-macro/CHANGELOG.md index afdd7cb16..f5e44a842 100644 --- a/crates/api-macro/CHANGELOG.md +++ b/crates/api-macro/CHANGELOG.md @@ -85,4 +85,4 @@ ## 0.1.0 - + diff --git a/crates/api-macro/Cargo.toml b/crates/api-macro/Cargo.toml index 046067df8..70288b924 100644 --- a/crates/api-macro/Cargo.toml +++ b/crates/api-macro/Cargo.toml @@ -39,8 +39,8 @@ api-uart = ["wasefire-applet-api-desc/api-uart"] api-usb-serial = ["wasefire-applet-api-desc/api-usb-serial"] [lints] +clippy.literal-string-with-formatting-args = "allow" clippy.mod-module-files = "warn" clippy.unit-arg = "allow" rust.unreachable-pub = "warn" -rust.unsafe-op-in-unsafe-fn = "warn" rust.unused-crate-dependencies = "warn" diff --git a/crates/api/CHANGELOG.md b/crates/api/CHANGELOG.md index 87e300a0b..4489e8996 100644 --- a/crates/api/CHANGELOG.md +++ b/crates/api/CHANGELOG.md @@ -4,6 +4,7 @@ ### Minor +- Improve safety documentation - Use Rust edition 2024 - Provide `bytemuck::Pod` for `ArrayU32` - Implement `bytemuck::Pod` for `U32` @@ -106,4 +107,4 @@ ## 0.1.0 - + diff --git a/crates/api/Cargo.toml b/crates/api/Cargo.toml index 5a92e3127..41038b916 100644 --- a/crates/api/Cargo.toml +++ b/crates/api/Cargo.toml @@ -87,8 +87,8 @@ native = ["dep:wasefire-logger"] internal-api-crypto-hash = [] [lints] +clippy.literal-string-with-formatting-args = "allow" clippy.mod-module-files = "warn" clippy.unit-arg = "allow" rust.unreachable-pub = "warn" -rust.unsafe-op-in-unsafe-fn = "warn" rust.unused-crate-dependencies = "warn" diff --git a/crates/api/src/api.md b/crates/api/src/api.md new file mode 120000 index 000000000..888e6efc8 --- /dev/null +++ b/crates/api/src/api.md @@ -0,0 +1 @@ +../../api-desc/src/api.md \ No newline at end of file diff --git a/crates/api/src/lib.rs b/crates/api/src/lib.rs index 0444a1fd4..468ffdd2e 100644 --- a/crates/api/src/lib.rs +++ b/crates/api/src/lib.rs @@ -14,6 +14,8 @@ #![cfg_attr(feature = "host", doc = "Platform-side of the applet API.")] #![cfg_attr(feature = "wasm", doc = include_str!("wasm.md"))] +#![cfg_attr(feature = "wasm", doc = "\n## WebAssembly-level documentation\n")] +#![cfg_attr(feature = "wasm", doc = include_str!("api.md"))] #![no_std] #![cfg_attr(all(feature = "wasm", feature = "native"), feature(linkage))] #![cfg_attr(feature = "host", feature(never_type))] diff --git a/crates/board/CHANGELOG.md b/crates/board/CHANGELOG.md index ccdf9fde2..ca4fd2015 100644 --- a/crates/board/CHANGELOG.md +++ b/crates/board/CHANGELOG.md @@ -171,4 +171,4 @@ ## 0.1.0 - + diff --git a/crates/board/Cargo.toml b/crates/board/Cargo.toml index 60c56ff22..a9bb9987c 100644 --- a/crates/board/Cargo.toml +++ b/crates/board/Cargo.toml @@ -153,10 +153,10 @@ internal-software-crypto-ecc = [ internal-software-crypto-hmac = ["dep:hmac"] [lints] +clippy.literal-string-with-formatting-args = "allow" clippy.mod-module-files = "warn" clippy.unit-arg = "allow" rust.missing-docs = "warn" rust.unexpected_cfgs = { level = "allow", check-cfg = ["cfg(target_arch, values(\"spirv\"))"] } rust.unreachable-pub = "warn" -rust.unsafe-op-in-unsafe-fn = "warn" rust.unused-crate-dependencies = "warn" diff --git a/crates/cli-tools/CHANGELOG.md b/crates/cli-tools/CHANGELOG.md index 1add1a1ad..1ddaa43b9 100644 --- a/crates/cli-tools/CHANGELOG.md +++ b/crates/cli-tools/CHANGELOG.md @@ -62,4 +62,4 @@ ## 0.1.0 - + diff --git a/crates/cli-tools/Cargo.toml b/crates/cli-tools/Cargo.toml index 99c2a1713..2b59624b3 100644 --- a/crates/cli-tools/Cargo.toml +++ b/crates/cli-tools/Cargo.toml @@ -77,8 +77,8 @@ cargo = ["dep:cargo_metadata"] changelog = ["cargo", "dep:clap", "dep:semver"] [lints] +clippy.literal-string-with-formatting-args = "allow" clippy.mod-module-files = "warn" clippy.unit-arg = "allow" rust.unreachable-pub = "warn" -rust.unsafe-op-in-unsafe-fn = "warn" rust.unused-crate-dependencies = "warn" diff --git a/crates/cli/CHANGELOG.md b/crates/cli/CHANGELOG.md index bd81e2f65..4989e3d1d 100644 --- a/crates/cli/CHANGELOG.md +++ b/crates/cli/CHANGELOG.md @@ -61,4 +61,4 @@ ## 0.1.0 - + diff --git a/crates/cli/Cargo.toml b/crates/cli/Cargo.toml index 735d54bd8..0ab041585 100644 --- a/crates/cli/Cargo.toml +++ b/crates/cli/Cargo.toml @@ -33,8 +33,8 @@ _dev = [] _prod = [] [lints] +clippy.literal-string-with-formatting-args = "allow" clippy.mod-module-files = "warn" clippy.unit-arg = "allow" rust.unreachable-pub = "warn" -rust.unsafe-op-in-unsafe-fn = "warn" rust.unused-crate-dependencies = "warn" diff --git a/crates/error/CHANGELOG.md b/crates/error/CHANGELOG.md index 8adb10f3f..6155f7070 100644 --- a/crates/error/CHANGELOG.md +++ b/crates/error/CHANGELOG.md @@ -8,6 +8,7 @@ ### Patch +- Fix clippy lints - Add clippy lint ## 0.1.2 @@ -35,4 +36,4 @@ ## 0.1.0 - + diff --git a/crates/error/Cargo.toml b/crates/error/Cargo.toml index b9fadad0a..9f607079a 100644 --- a/crates/error/Cargo.toml +++ b/crates/error/Cargo.toml @@ -20,8 +20,8 @@ defmt = ["dep:defmt"] std = [] [lints] +clippy.literal-string-with-formatting-args = "allow" clippy.mod-module-files = "warn" clippy.unit-arg = "allow" rust.unreachable-pub = "warn" -rust.unsafe-op-in-unsafe-fn = "warn" rust.unused-crate-dependencies = "warn" diff --git a/crates/error/src/lib.rs b/crates/error/src/lib.rs index 0ef8de0e8..077e4d25e 100644 --- a/crates/error/src/lib.rs +++ b/crates/error/src/lib.rs @@ -42,7 +42,7 @@ impl Error { /// Creates a new error at compile-time. pub const fn new_const(space: u8, code: u16) -> Self { - Error((space as u32) << 16 | code as u32) + Error(((space as u32) << 16) | code as u32) } /// Returns the error space. diff --git a/crates/interpreter/CHANGELOG.md b/crates/interpreter/CHANGELOG.md index 73da6e5b0..0b6ee016b 100644 --- a/crates/interpreter/CHANGELOG.md +++ b/crates/interpreter/CHANGELOG.md @@ -94,4 +94,4 @@ ## 0.1.0 - + diff --git a/crates/interpreter/Cargo.lock b/crates/interpreter/Cargo.lock index a988bb70a..13a3fe820 100644 --- a/crates/interpreter/Cargo.lock +++ b/crates/interpreter/Cargo.lock @@ -48,9 +48,9 @@ checksum = "1e087f84d4f86bf4b218b927129862374b72199ae7d8657835f1e89000eea4fb" [[package]] name = "indexmap" -version = "2.6.0" +version = "2.7.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "707907fe3c25f5424cce2cb7e1cbcafee6bdbe735ca90ef77c29e84591e5b9da" +checksum = "62f822373a4fe84d4bb149bf54e584a7f4abec90e072ed49cda0edea5b95471f" dependencies = [ "equivalent", "hashbrown", @@ -182,9 +182,9 @@ dependencies = [ [[package]] name = "wasm-encoder" -version = "0.221.2" +version = "0.223.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c17a3bd88f2155da63a1f2fcb8a56377a24f0b6dfed12733bb5f544e86f690c5" +checksum = "7e636076193fa68103e937ac951b5f2f587624097017d764b8984d9c0f149464" dependencies = [ "leb128", "wasmparser", @@ -192,9 +192,9 @@ dependencies = [ [[package]] name = "wasmparser" -version = "0.221.2" +version = "0.223.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9845c470a2e10b61dd42c385839cdd6496363ed63b5c9e420b5488b77bd22083" +checksum = "d5a99faceb1a5a84dd6084ec4bfa4b2ab153b5793b43fd8f58b89232634afc35" dependencies = [ "bitflags", "indexmap", @@ -203,9 +203,9 @@ dependencies = [ [[package]] name = "wast" -version = "221.0.2" +version = "223.0.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "fcc4470b9de917ba199157d1f0ae104f2ae362be728c43e68c571c7715bd629e" +checksum = "d59b2ba8a2ff9f06194b7be9524f92e45e70149f4dacc0d0c7ad92b59ac875e4" dependencies = [ "bumpalo", "leb128", diff --git a/crates/interpreter/Cargo.toml b/crates/interpreter/Cargo.toml index c10de3008..269ee68b2 100644 --- a/crates/interpreter/Cargo.toml +++ b/crates/interpreter/Cargo.toml @@ -21,7 +21,7 @@ wasefire-error = { version = "0.1.3-git", path = "../error" } [dev-dependencies] lazy_static = "1.4.0" -wast = "221.0.2" +wast = "223.0.0" [features] # Enable debugging features (only works for targets with std). @@ -33,7 +33,7 @@ float-types = ["dep:libm"] vector-types = [] [lints] +clippy.literal-string-with-formatting-args = "allow" clippy.mod-module-files = "warn" clippy.unit-arg = "allow" -rust.unsafe-op-in-unsafe-fn = "warn" rust.unused-crate-dependencies = "warn" diff --git a/crates/interpreter/src/exec.rs b/crates/interpreter/src/exec.rs index c93853269..7ee4c5baf 100644 --- a/crates/interpreter/src/exec.rs +++ b/crates/interpreter/src/exec.rs @@ -393,7 +393,7 @@ impl Ptr { let inst = inst.into_repr() as u32; assert_eq!(inst & !Self::INST_MASK, 0); assert_eq!(idx & !Self::INDEX_MASK, 0); - Self(inst << Self::INDEX_BITS | idx) + Self((inst << Self::INDEX_BITS) | idx) } fn instance(self) -> Side { diff --git a/crates/interpreter/src/module.rs b/crates/interpreter/src/module.rs index e9541c593..8c76f6f10 100644 --- a/crates/interpreter/src/module.rs +++ b/crates/interpreter/src/module.rs @@ -28,9 +28,8 @@ use crate::*; pub struct Module<'m> { binary: &'m [u8], types: Vec>, - // TODO(dev/fast-interp): Flatten it to 1D array when making it persistent in - // flash. - side_tables: &'m [Vec], + // TODO(dev/fast-interp): Use a shallow (unstructured) view in the flash. + side_table: &'m [MetadataEntry], } impl<'m> Import<'m> { @@ -53,10 +52,10 @@ impl ImportDesc { impl<'m> Module<'m> { /// Validates a WASM module in binary format. pub fn new(binary: &'m [u8]) -> Result { - let side_tables = validate(binary)?; + let side_table = validate(binary)?; let mut module = unsafe { Self::new_unchecked(binary) }; // TODO(dev/fast-interp): We should take a buffer as argument to write to. - module.side_tables = Box::leak(Box::new(side_tables)); + module.side_table = Box::leak(Box::new(side_table)); Ok(module) } @@ -117,14 +116,7 @@ impl<'m> Module<'m> { } pub(crate) fn func_type(&self, x: FuncIdx) -> FuncType<'m> { - let mut parser = self.section(SectionId::Function).unwrap(); - for i in 0 .. parser.parse_vec().into_ok() { - let y = parser.parse_typeidx().into_ok(); - if i == x as usize { - return self.types[y as usize]; - } - } - unreachable!() + self.types[self.side_table[x as usize].type_idx] } pub(crate) fn table_type(&self, x: TableIdx) -> TableType { @@ -184,17 +176,14 @@ impl<'m> Module<'m> { unreachable!() } - // TODO(dev/fast-interp): Improve the performance of such accessor functions from O(n) to O(1). pub(crate) fn func(&self, x: FuncIdx) -> (Parser<'m>, &'m [BranchTableEntry]) { - let mut parser = self.section(SectionId::Code).unwrap(); - for i in 0 .. parser.parse_vec().into_ok() { - let size = parser.parse_u32().into_ok() as usize; - let parser = parser.split_at(size).into_ok(); - if i == x as usize { - return (parser, &self.side_tables[i]); - } + let mut parser = unsafe { Parser::new(self.binary) }; + let entry = &self.side_table[x as usize]; + let range = &entry.parser_range; + unsafe { + parser.restore(&parser.save()[range.start .. range.end]); } - unreachable!() + (parser, &entry.branch_table) } pub(crate) fn data(&self, x: DataIdx) -> Parser<'m> { diff --git a/crates/interpreter/src/parser.rs b/crates/interpreter/src/parser.rs index 730f11d1b..bd15b659f 100644 --- a/crates/interpreter/src/parser.rs +++ b/crates/interpreter/src/parser.rs @@ -79,7 +79,7 @@ impl<'m, M: Mode> Parser<'m, M> { loop { let mut byte = self.parse_byte()? as u64; if byte & 0x80 == 0 { - if signed && byte & 1 << core::cmp::min(len - 1, 6) != 0 { + if signed && byte & (1 << core::cmp::min(len - 1, 6)) != 0 { if let Some(len) = len.checked_sub(7) { val |= ((1 << len) - 1) << (bits - len); } else { diff --git a/crates/interpreter/src/side_table.rs b/crates/interpreter/src/side_table.rs index b2cd7a0a1..add95c5fb 100644 --- a/crates/interpreter/src/side_table.rs +++ b/crates/interpreter/src/side_table.rs @@ -12,6 +12,9 @@ // See the License for the specific language governing permissions and // limitations under the License. +use alloc::vec::Vec; +use core::ops::Range; + use crate::error::*; use crate::module::Parser; @@ -40,19 +43,32 @@ impl<'m> Metadata<'m> { self.0[0] as usize } + pub fn code_start(&self) -> usize { + self.combine_two_u16s(1) + } + pub fn parser(&self, code: &'m [u8]) -> Parser<'m> { - unsafe { Parser::new(&code[self.parser_pos(1) .. self.parser_pos(3)]) } + unsafe { Parser::new(&code[self.combine_two_u16s(3) .. self.combine_two_u16s(5)]) } } pub fn branch_table(&self) -> &[BranchTableEntry] { - bytemuck::cast_slice(&self.0[5 ..]) + bytemuck::cast_slice(&self.0[7 ..]) } - fn parser_pos(&self, idx: usize) -> usize { + fn combine_two_u16s(&self, idx: usize) -> usize { bytemuck::pod_read_unaligned::(bytemuck::cast_slice(&self.0[idx .. idx + 2])) as usize } } +#[derive(Default, Debug)] +pub struct MetadataEntry { + pub type_idx: usize, + #[allow(dead_code)] + pub code_start: usize, + pub parser_range: Range, + pub branch_table: Vec, +} + #[derive(Copy, Clone, Debug, bytemuck::AnyBitPattern)] #[repr(transparent)] pub struct BranchTableEntry([u16; 3]); @@ -77,7 +93,7 @@ impl BranchTableEntry { Ok(BranchTableEntry([ view.delta_ip as u16, view.delta_stp as u16, - (view.pop_cnt << 4 | view.val_cnt) as u16, + ((view.pop_cnt << 4) | view.val_cnt) as u16, ])) } diff --git a/crates/interpreter/src/valid.rs b/crates/interpreter/src/valid.rs index 3b7e5641e..275085937 100644 --- a/crates/interpreter/src/valid.rs +++ b/crates/interpreter/src/valid.rs @@ -16,6 +16,7 @@ use alloc::collections::BTreeSet; use alloc::vec; use alloc::vec::Vec; use core::cmp::Ordering; +use core::ops::Range; use crate::error::*; use crate::side_table::*; @@ -25,7 +26,7 @@ use crate::util::*; use crate::*; /// Checks whether a WASM module in binary format is valid. -pub fn validate(binary: &[u8]) -> Result>, Error> { +pub fn validate(binary: &[u8]) -> Result, Error> { Context::default().check_module(&mut Parser::new(binary)) } @@ -44,9 +45,8 @@ struct Context<'m> { } impl<'m> Context<'m> { - fn check_module( - &mut self, parser: &mut Parser<'m>, - ) -> MResult>, Check> { + fn check_module(&mut self, parser: &mut Parser<'m>) -> MResult, Check> { + let parser_origin = parser.save().as_ptr() as usize; check(parser.parse_bytes(8)? == b"\0asm\x01\0\0\0")?; if let Some(mut parser) = self.check_section(parser, SectionId::Type)? { let n = parser.parse_vec()?; @@ -128,14 +128,23 @@ impl<'m> Context<'m> { } let mut side_tables = vec![]; if let Some(mut parser) = self.check_section(parser, SectionId::Code)? { + let code_start = parser.save().as_ptr() as usize - parser_origin; check(self.funcs.len() == imported_funcs + parser.parse_vec()?)?; for x in imported_funcs .. self.funcs.len() { let size = parser.parse_u32()? as usize; let mut parser = parser.split_at(size)?; + let parser_start = parser.save().as_ptr() as usize - parser_origin; + let parser_end = parser_start + size; let t = self.functype(x as FuncIdx).unwrap(); let mut locals = t.params.to_vec(); parser.parse_locals(&mut locals)?; - side_tables.push(Expr::check_body(self, &mut parser, &refs, locals, t.results)?); + let branch_table = Expr::check_body(self, &mut parser, &refs, locals, t.results)?; + side_tables.push(MetadataEntry { + type_idx: self.funcs[x] as usize, + code_start, + parser_range: Range { start: parser_start, end: parser_end }, + branch_table, + }); check(parser.is_empty())?; } check(parser.is_empty())?; @@ -409,34 +418,32 @@ struct Expr<'a, 'm> { is_body: bool, locals: Vec, labels: Vec>, - side_table: SideTable, + branch_table: BranchTable, } #[derive(Default)] -struct SideTable { - entries: Vec, -} +struct BranchTable(Vec); -impl SideTable { +impl BranchTable { fn save(&self) -> usize { - self.entries.len() + self.0.len() } fn branch(&mut self) { - self.entries.push(BranchTableEntry::invalid()); + self.0.push(BranchTableEntry::invalid()); } fn stitch(&mut self, source: SideTableBranch, target: SideTableBranch) -> CheckResult { let delta_ip = Self::delta(source, target, |x| x.parser.as_ptr() as isize)?; - let delta_stp = Self::delta(source, target, |x| x.side_table as isize)?; + let delta_stp = Self::delta(source, target, |x| x.branch_table as isize)?; let val_cnt = u32::try_from(target.result).map_err(|_| { #[cfg(feature = "debug")] eprintln!("side-table val_cnt overflow {0}", target.result); unsupported(if_debug!(Unsupported::SideTable)) })?; let pop_cnt = Self::pop_cnt(source, target)?; - debug_assert!(self.entries[source.side_table].is_invalid()); - self.entries[source.side_table] = + debug_assert!(self.0[source.branch_table].is_invalid()); + self.0[source.branch_table] = BranchTableEntry::new(BranchTableEntryView { delta_ip, delta_stp, val_cnt, pop_cnt })?; Ok(()) } @@ -477,15 +484,15 @@ impl SideTable { } fn persist(self) -> MResult, Check> { - debug_assert!(self.entries.iter().all(|x| !x.is_invalid())); - Ok(self.entries) + debug_assert!(self.0.iter().all(|x| !x.is_invalid())); + Ok(self.0) } } #[derive(Debug, Copy, Clone)] struct SideTableBranch<'m> { parser: &'m [u8], - side_table: usize, + branch_table: usize, stack: usize, result: usize, // unused (zero) for source branches } @@ -524,7 +531,7 @@ impl<'a, 'm> Expr<'a, 'm> { is_body: false, locals: vec![], labels: vec![Label::default()], - side_table: SideTable::default(), + branch_table: BranchTable::default(), } } @@ -547,7 +554,7 @@ impl<'a, 'm> Expr<'a, 'm> { expr.locals = locals; expr.label().type_.results = results; expr.check()?; - expr.side_table.persist() + expr.branch_table.persist() } fn check(&mut self) -> CheckResult { @@ -602,8 +609,8 @@ impl<'a, 'm> Expr<'a, 'm> { LabelKind::If(source) => { let result = self.label().type_.results.len(); let mut target = self.branch_target(result); - target.side_table += 1; - self.side_table.stitch(source, target)? + target.branch_table += 1; + self.branch_table.stitch(source, target)? } _ => Err(invalid())?, } @@ -858,14 +865,14 @@ impl<'a, 'm> Expr<'a, 'm> { let results_len = self.label().type_.results.len(); let mut target = self.branch_target(results_len); for source in core::mem::take(&mut self.label().branches) { - self.side_table.stitch(source, target)?; + self.branch_table.stitch(source, target)?; } let label = self.label(); if let LabelKind::If(source) = label.kind { check(label.type_.params == label.type_.results)?; // SAFETY: This function is only called after parsing an End instruction. target.parser = offset_front(target.parser, -1); - self.side_table.stitch(source, target)?; + self.branch_table.stitch(source, target)?; } let results = self.label().type_.results; self.pops(results)?; @@ -888,7 +895,7 @@ impl<'a, 'm> Expr<'a, 'm> { label.type_.results } LabelKind::Loop(target) => { - self.side_table.stitch(source, target)?; + self.branch_table.stitch(source, target)?; label.type_.params } }) @@ -897,7 +904,7 @@ impl<'a, 'm> Expr<'a, 'm> { fn branch_source(&mut self) -> SideTableBranch<'m> { let mut branch = self.branch(); branch.stack += self.stack().len(); - self.side_table.branch(); + self.branch_table.branch(); branch } @@ -911,7 +918,7 @@ impl<'a, 'm> Expr<'a, 'm> { fn branch(&self) -> SideTableBranch<'m> { SideTableBranch { parser: self.parser.save(), - side_table: self.side_table.save(), + branch_table: self.branch_table.save(), stack: self.immutable_label().prev_stack, result: 0, } diff --git a/crates/logger/CHANGELOG.md b/crates/logger/CHANGELOG.md index b68643d31..95a443a67 100644 --- a/crates/logger/CHANGELOG.md +++ b/crates/logger/CHANGELOG.md @@ -57,4 +57,4 @@ ## 0.1.0 - + diff --git a/crates/logger/Cargo.toml b/crates/logger/Cargo.toml index 9f0eb5655..2d15d7169 100644 --- a/crates/logger/Cargo.toml +++ b/crates/logger/Cargo.toml @@ -20,8 +20,8 @@ defmt = ["dep:defmt"] log = ["dep:log"] [lints] +clippy.literal-string-with-formatting-args = "allow" clippy.mod-module-files = "warn" clippy.unit-arg = "allow" rust.unreachable-pub = "warn" -rust.unsafe-op-in-unsafe-fn = "warn" rust.unused-crate-dependencies = "warn" diff --git a/crates/one-of/CHANGELOG.md b/crates/one-of/CHANGELOG.md index b7995b7e8..8ddb3f005 100644 --- a/crates/one-of/CHANGELOG.md +++ b/crates/one-of/CHANGELOG.md @@ -12,4 +12,4 @@ ## 0.1.0 - + diff --git a/crates/one-of/Cargo.toml b/crates/one-of/Cargo.toml index 7d6968749..7a8ed7080 100644 --- a/crates/one-of/Cargo.toml +++ b/crates/one-of/Cargo.toml @@ -12,9 +12,9 @@ keywords = ["macro", "no-std"] categories = ["no-std"] [lints] +clippy.literal-string-with-formatting-args = "allow" clippy.mod-module-files = "warn" clippy.unit-arg = "allow" rust.missing-docs = "warn" rust.unreachable-pub = "warn" -rust.unsafe-op-in-unsafe-fn = "warn" rust.unused-crate-dependencies = "warn" diff --git a/crates/prelude/CHANGELOG.md b/crates/prelude/CHANGELOG.md index 78f2c0f8c..a471cb46d 100644 --- a/crates/prelude/CHANGELOG.md +++ b/crates/prelude/CHANGELOG.md @@ -1,13 +1,20 @@ # Changelog -## 0.7.1-git +## 0.8.0-git + +### Major + +- Make `syscall()` unsafe to call ### Minor +- Support the new behavior of the scheduler (not allocating if the size is zero) +- Add `rng::bytes{,_array}()` as safer alternatives to `rng::fill_bytes()` - Use Rust edition 2024 ### Patch +- Fix clippy lints - Update dependencies ## 0.7.0 @@ -185,4 +192,4 @@ ## 0.1.0 - + diff --git a/crates/prelude/Cargo.lock b/crates/prelude/Cargo.lock index 43480d428..92af364d5 100644 --- a/crates/prelude/Cargo.lock +++ b/crates/prelude/Cargo.lock @@ -255,7 +255,7 @@ checksum = "49874b5167b65d7193b8aba1567f5c7d93d001cafc34600cee003eda787e483f" [[package]] name = "wasefire" -version = "0.7.1-git" +version = "0.8.0-git" dependencies = [ "aead", "bytemuck", diff --git a/crates/prelude/Cargo.toml b/crates/prelude/Cargo.toml index 9a4b29bf9..8a19fd3d9 100644 --- a/crates/prelude/Cargo.toml +++ b/crates/prelude/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "wasefire" -version = "0.7.1-git" +version = "0.8.0-git" authors = ["Julien Cretin "] license = "Apache-2.0" publish = true @@ -103,9 +103,9 @@ internal-rpc = ["dep:sealed"] internal-serial = ["dep:sealed"] [lints] +clippy.literal-string-with-formatting-args = "allow" clippy.mod-module-files = "warn" clippy.unit-arg = "allow" rust.missing-docs = "warn" rust.unreachable-pub = "warn" -rust.unsafe-op-in-unsafe-fn = "warn" rust.unused-crate-dependencies = "warn" diff --git a/crates/prelude/src/allocator/wasm.rs b/crates/prelude/src/allocator/wasm.rs index d9a0e417f..47588d2e0 100644 --- a/crates/prelude/src/allocator/wasm.rs +++ b/crates/prelude/src/allocator/wasm.rs @@ -38,10 +38,11 @@ extern "C" fn init() { #[unsafe(no_mangle)] extern "C" fn alloc(size: u32, align: u32) -> u32 { - let layout = match Layout::from_size_align(size as usize, align as usize) { - Ok(x) => x, - Err(_) => return 0, - }; + let Ok(layout) = Layout::from_size_align(size as usize, align as usize) else { return 0 }; + if size == 0 { + return 0; // this is not checked by Layout::from_size_align() + } + // SAFETY: Layout has non-zero size. unsafe { ALLOCATOR.alloc(layout) as u32 } } diff --git a/crates/prelude/src/button.rs b/crates/prelude/src/button.rs index b6b21a175..c2dae750c 100644 --- a/crates/prelude/src/button.rs +++ b/crates/prelude/src/button.rs @@ -50,6 +50,8 @@ impl Handler for F { #[must_use] pub struct Listener { button: usize, + // Safety: This is a `Box` we own and lend the platform as a shared borrow `&'a H` where + // `'a` starts at `api::register()` and ends at `api::unregister()`. handler: *const H, } @@ -93,6 +95,8 @@ impl Listener { } extern "C" fn call(data: *const u8, state: usize) { + // SAFETY: `data` is the `&H` we lent the platform (see `Listener::handler`). We are + // borrowing it back for the duration of this call. let handler = unsafe { &*(data as *const H) }; let state = state.into(); handler.event(state); @@ -103,6 +107,8 @@ impl Drop for Listener { fn drop(&mut self) { let params = api::unregister::Params { button: self.button }; convert_unit(unsafe { api::unregister(params) }).unwrap(); + // SAFETY: `self.handler` is a `Box` we own back, now that the lifetime of the platform + // borrow is over (see `Listener::handler`). drop(unsafe { Box::from_raw(self.handler as *mut H) }); } } diff --git a/crates/prelude/src/crypto/gcm.rs b/crates/prelude/src/crypto/gcm.rs index 76d036338..b72095594 100644 --- a/crates/prelude/src/crypto/gcm.rs +++ b/crates/prelude/src/crypto/gcm.rs @@ -51,8 +51,8 @@ pub fn is_supported() -> bool { pub fn support() -> Support { let support = convert(unsafe { api::support() }).unwrap(); Support { - no_copy: (support & 1 << api::Support::NoCopy as u32) != 0, - in_place_no_copy: (support & 1 << api::Support::InPlaceNoCopy as u32) != 0, + no_copy: (support & (1 << api::Support::NoCopy as u32)) != 0, + in_place_no_copy: (support & (1 << api::Support::InPlaceNoCopy as u32)) != 0, } } diff --git a/crates/prelude/src/lib.rs b/crates/prelude/src/lib.rs index 0a172f21b..f5df9b12d 100644 --- a/crates/prelude/src/lib.rs +++ b/crates/prelude/src/lib.rs @@ -30,6 +30,8 @@ #![feature(alloc_error_handler)] #![feature(doc_auto_cfg)] #![feature(macro_metavar_expr)] +#![feature(maybe_uninit_array_assume_init)] +#![feature(maybe_uninit_uninit_array)] #![feature(negative_impls)] #![feature(never_type)] #![feature(vec_into_raw_parts)] @@ -83,7 +85,13 @@ at_most_one_of!["native", "test", "wasm"]; /// Board-specific syscalls. /// /// Those calls are directly forwarded to the board by the scheduler. -pub fn syscall(x1: usize, x2: usize, x3: usize, x4: usize) -> Result { +/// +/// # Safety +/// +/// For the syscalls they support, boards must either provide safe libraries or safety documentation +/// (these requirements are not exclusive). If no safety documentation is provided, it must be +/// assumed that this function cannot be called (regardless of its arguments). +pub unsafe fn syscall(x1: usize, x2: usize, x3: usize, x4: usize) -> Result { let params = api::syscall::Params { x1, x2, x3, x4 }; convert(unsafe { api::syscall(params) }) } diff --git a/crates/prelude/src/platform.rs b/crates/prelude/src/platform.rs index 6a248e773..d0ea1091e 100644 --- a/crates/prelude/src/platform.rs +++ b/crates/prelude/src/platform.rs @@ -14,9 +14,6 @@ //! Provides API to interact with the platform. -#[cfg(feature = "api-platform")] -use alloc::boxed::Box; - #[cfg(feature = "api-platform")] use wasefire_applet_api::platform as api; #[cfg(feature = "api-platform")] @@ -33,26 +30,30 @@ pub mod update; /// Returns the serial of the platform. #[cfg(feature = "api-platform")] pub fn serial() -> &'static [u8] { - fn init() -> Box<[u8]> { + fn init() -> &'static [u8] { let mut ptr = core::ptr::null_mut(); let params = api::serial::Params { ptr: &mut ptr }; let len = convert(unsafe { api::serial(params) }).unwrap(); - unsafe { Box::from_raw(core::slice::from_raw_parts_mut(ptr, len)) } + // SAFETY: If `len` is non-zero then `ptr` is the non-null result of `alloc(len, 1)`. The + // scheduler traps the applet if `alloc()` returns null. The slice was fully initialized by + // the scheduler. + if len == 0 { &[] } else { unsafe { core::slice::from_raw_parts(ptr, len) } } } - static SERIAL: Lazy> = Lazy::new(init); + static SERIAL: Lazy<&'static [u8]> = Lazy::new(init); &SERIAL } /// Returns the version of the platform. #[cfg(feature = "api-platform")] pub fn version() -> &'static [u8] { - fn init() -> Box<[u8]> { + fn init() -> &'static [u8] { let mut ptr = core::ptr::null_mut(); let params = api::version::Params { ptr: &mut ptr }; let len = convert(unsafe { api::version(params) }).unwrap(); - unsafe { Box::from_raw(core::slice::from_raw_parts_mut(ptr, len)) } + // SAFETY: Similar as in `serial()` above. + if len == 0 { &[] } else { unsafe { core::slice::from_raw_parts(ptr, len) } } } - static VERSION: Lazy> = Lazy::new(init); + static VERSION: Lazy<&'static [u8]> = Lazy::new(init); &VERSION } diff --git a/crates/prelude/src/platform/protocol.rs b/crates/prelude/src/platform/protocol.rs index f730f5c88..5a02cce5a 100644 --- a/crates/prelude/src/platform/protocol.rs +++ b/crates/prelude/src/platform/protocol.rs @@ -34,7 +34,9 @@ impl crate::rpc::Rpc for RpcProtocol { if !convert_bool(unsafe { api::read(params) })? { return Ok(None); } - Ok(Some(unsafe { Vec::from_raw_parts(ptr, len, len) })) + // SAFETY: If `api::read()` returns true and `len` is non-zero then it allocated. The rest + // is similar as in `crate::platform::serial()`. + Ok(Some(if len == 0 { Vec::new() } else { unsafe { Vec::from_raw_parts(ptr, len, len) } })) } fn write(&self, response: &[u8]) -> Result<(), Error> { diff --git a/crates/prelude/src/platform/update.rs b/crates/prelude/src/platform/update.rs index b0888fc17..bfdff910c 100644 --- a/crates/prelude/src/platform/update.rs +++ b/crates/prelude/src/platform/update.rs @@ -33,8 +33,10 @@ pub fn metadata() -> Result, Error> { let mut len = 0; let params = api::metadata::Params { ptr: &mut ptr, len: &mut len }; convert_unit(unsafe { api::metadata(params) })?; - let ptr = unsafe { core::slice::from_raw_parts_mut(ptr, len) }; - Ok(unsafe { Box::from_raw(ptr) }) + let ptr = core::ptr::slice_from_raw_parts_mut(ptr, len); + // SAFETY: If `len` is non-zero then `api::metadata()` allocated. The rest is similar as in + // `crate::platform::serial()`. + Ok(if len == 0 { Box::new([]) } else { unsafe { Box::from_raw(ptr) } }) } /// Starts a platform update process. diff --git a/crates/prelude/src/rng.rs b/crates/prelude/src/rng.rs index b3f4c97eb..496598401 100644 --- a/crates/prelude/src/rng.rs +++ b/crates/prelude/src/rng.rs @@ -14,12 +14,41 @@ //! Provides API for random number generation. +use alloc::boxed::Box; +use core::mem::MaybeUninit; + use wasefire_applet_api::rng as api; use crate::{Error, convert_unit}; +/// Returns a slice of random bytes. +pub fn bytes(len: usize) -> Result, Error> { + let mut buf = Box::new_uninit_slice(len); + fill_uninit_bytes(&mut buf)?; + // SAFETY: `fill_uninit_bytes()` only succeeds if all bytes are initialized. + Ok(unsafe { buf.assume_init() }) +} + +/// Returns an array of random bytes. +pub fn bytes_array() -> Result<[u8; N], Error> { + let mut buf = MaybeUninit::uninit_array(); + fill_uninit_bytes(&mut buf)?; + // SAFETY: `fill_uninit_bytes()` only succeeds if all bytes are initialized. + Ok(unsafe { MaybeUninit::array_assume_init(buf) }) +} + /// Fills a slice with random bytes. +/// +/// Prefer [`bytes()`] if you don't already have an allocation. pub fn fill_bytes(buf: &mut [u8]) -> Result<(), Error> { - let params = api::fill_bytes::Params { ptr: buf.as_mut_ptr(), len: buf.len() }; + // SAFETY: `fill_uninit_bytes()` only writes initialized bytes. + let buf = unsafe { + core::slice::from_raw_parts_mut(buf.as_mut_ptr() as *mut MaybeUninit, buf.len()) + }; + fill_uninit_bytes(buf) +} + +fn fill_uninit_bytes(buf: &mut [MaybeUninit]) -> Result<(), Error> { + let params = api::fill_bytes::Params { ptr: buf.as_mut_ptr() as *mut u8, len: buf.len() }; convert_unit(unsafe { api::fill_bytes(params) }) } diff --git a/crates/prelude/src/rpc.rs b/crates/prelude/src/rpc.rs index 413e6be29..5c72541c8 100644 --- a/crates/prelude/src/rpc.rs +++ b/crates/prelude/src/rpc.rs @@ -65,6 +65,8 @@ impl) -> Vec + 'static> Service for F { /// Listens on RPC requests processing them according to a service. #[must_use] pub struct Listener<'a, T: Rpc, S: Service> { + // Safety: This is a `Box>` we own and lend the platform as a shared borrow + // with a lifetime starting at `Rpc::register()` and ending at `Rpc::unregister()`. state: *const State<'a, T, S>, } @@ -87,8 +89,9 @@ impl<'a, T: Rpc, S: Service> Listener<'a, T, S> { /// Listener::new(&platform::protocol::RpcProtocol, |request| Response::from(request)) /// ``` pub fn new(rpc: &'a T, service: S) -> Self { - let state = Box::leak(Box::new(State { rpc, handler: RefCell::new(service) })); - unsafe { rpc.register(Self::call, state as *mut _ as *const u8) }.unwrap(); + let state = Box::into_raw(Box::new(State { rpc, handler: RefCell::new(service) })); + // SAFETY: The `state` lifetime ends after unregister (see field invariant). + unsafe { rpc.register(Self::call, state as *const u8) }.unwrap(); Listener { state } } @@ -109,6 +112,8 @@ impl<'a, T: Rpc, S: Service> Listener<'a, T, S> { } extern "C" fn call(state: *const u8) { + // SAFETY: `state` is the shared borrow we lent the platform (see field invariant). We are + // borrowing it back for the duration of this call. let state = unsafe { &*(state as *const State<'a, T, S>) }; let request = match state.rpc.read().unwrap() { Some(x) => x, @@ -125,6 +130,8 @@ impl<'a, T: Rpc, S: Service> Drop for Listener<'a, T, S> { fn drop(&mut self) { let state = unsafe { &*self.state }; state.rpc.unregister().unwrap(); + // SAFETY: `self.state` is a `Box>` we own back, now that the lifetime of + // the platform borrow is over (see field invariant). drop(unsafe { Box::from_raw(self.state as *mut State<'a, T, S>) }); } } diff --git a/crates/prelude/src/serial.rs b/crates/prelude/src/serial.rs index e083f14f4..770878f82 100644 --- a/crates/prelude/src/serial.rs +++ b/crates/prelude/src/serial.rs @@ -138,25 +138,31 @@ pub fn flush(serial: &T) -> Result<(), Error> { pub struct Listener<'a, T: Serial> { serial: &'a T, event: Event, - notified: &'static Cell, + // Safety: This is a `Box>` we own and lend the platform as a shared borrow with a + // lifetime starting at `Serial::register()` and ending at `Serial::unregister()`. + notified: *const Cell, } impl<'a, T: Serial> Listener<'a, T> { /// Starts listening for the provided event until dropped. pub fn new(serial: &'a T, event: Event) -> Self { - let notified = Box::leak(Box::new(Cell::new(true))); + let notified = Box::into_raw(Box::new(Cell::new(true))); let func = Self::call; - let data = notified as *mut _ as *const u8; + let data = notified as *const u8; unsafe { serial.register(event, func, data) }.unwrap(); Listener { serial, event, notified } } /// Returns whether the event triggered since the last call. pub fn is_notified(&mut self) -> bool { - self.notified.replace(false) + // SAFETY: `self.notified` is a `Box> we share with the platform (see field + // invariant). We create a shared borrow for the duration of this call. + unsafe { &*self.notified }.replace(false) } extern "C" fn call(data: *const u8) { + // SAFETY: `data` is the shared borrow we lent the platform (see field invariant). We are + // borrowing it back for the duration of this call. let notified = unsafe { &*(data as *const Cell) }; notified.set(true); } @@ -165,7 +171,9 @@ impl<'a, T: Serial> Listener<'a, T> { impl Drop for Listener<'_, T> { fn drop(&mut self) { self.serial.unregister(self.event).unwrap(); - drop(unsafe { Box::from_raw(self.notified.as_ptr()) }); + // SAFETY: `self.notified` is a `Box>` we own back, now that the lifetime of the + // platform borrow is over (see field invariant). + drop(unsafe { Box::from_raw(self.notified as *mut Cell) }); } } diff --git a/crates/prelude/src/store.rs b/crates/prelude/src/store.rs index 8c8e9a11a..484ddbdde 100644 --- a/crates/prelude/src/store.rs +++ b/crates/prelude/src/store.rs @@ -56,8 +56,10 @@ pub fn find(key: usize) -> Result>, Error> { let mut len = 0; let params = api::find::Params { key, ptr: &mut ptr, len: &mut len }; if convert_bool(unsafe { api::find(params) })? { - let ptr = unsafe { core::slice::from_raw_parts_mut(ptr, len) }; - Ok(Some(unsafe { Box::from_raw(ptr) })) + // SAFETY: If `api::find()` returns true and `len` is non-zero then it allocated. The rest + // is similar as in `crate::platform::serial()`. + let ptr = core::ptr::slice_from_raw_parts_mut(ptr, len); + Ok(Some(if len == 0 { Box::new([]) } else { unsafe { Box::from_raw(ptr) } })) } else { Ok(None) } @@ -69,11 +71,10 @@ pub fn keys() -> Result, Error> { let mut ptr = core::ptr::null_mut(); let params = api::keys::Params { ptr: &mut ptr }; let len = convert(unsafe { api::keys(params) })?; - if len == 0 { - Ok(Vec::new()) - } else { - Ok(unsafe { Vec::from_raw_parts(ptr as *mut u16, len, len) }) - } + let ptr = ptr as *mut u16; + // SAFETY: If `len` is non-zero then `api::keys()` allocated. The rest is similar as in + // `crate::platform::serial()`. + Ok(if len == 0 { Vec::new() } else { unsafe { Vec::from_raw_parts(ptr, len, len) } }) } /// Clears the store, removing all entries. diff --git a/crates/prelude/src/store/fragment.rs b/crates/prelude/src/store/fragment.rs index 53dffffa3..68b492339 100644 --- a/crates/prelude/src/store/fragment.rs +++ b/crates/prelude/src/store/fragment.rs @@ -53,8 +53,10 @@ pub fn find(keys: Range) -> Result>, Error> { let mut len = 0; let params = api::find::Params { keys: encode_keys(keys)?, ptr: &mut ptr, len: &mut len }; if convert_bool(unsafe { api::find(params) })? { - let ptr = unsafe { core::slice::from_raw_parts_mut(ptr, len) }; - Ok(Some(unsafe { Box::from_raw(ptr) })) + // SAFETY: If `api::find()` returns true and `len` is non-zero then it allocated. The rest + // is similar as in `crate::platform::serial()`. + let ptr = core::ptr::slice_from_raw_parts_mut(ptr, len); + Ok(Some(if len == 0 { Box::new([]) } else { unsafe { Box::from_raw(ptr) } })) } else { Ok(None) } @@ -63,5 +65,5 @@ pub fn find(keys: Range) -> Result>, Error> { fn encode_keys(keys: Range) -> Result { let start = u16::try_from(keys.start).map_err(|_| Error::user(0))? as u32; let end = u16::try_from(keys.end).map_err(|_| Error::user(0))? as u32; - Ok(end << 16 | start) + Ok((end << 16) | start) } diff --git a/crates/protocol-tokio/CHANGELOG.md b/crates/protocol-tokio/CHANGELOG.md index 133144e65..2ec14f719 100644 --- a/crates/protocol-tokio/CHANGELOG.md +++ b/crates/protocol-tokio/CHANGELOG.md @@ -4,6 +4,7 @@ ### Minor +- Add error context to `Pipe::new_{unix,tcp}()` for `device` - Use Rust edition 2024 ### Patch @@ -12,4 +13,4 @@ ## 0.1.0 - + diff --git a/crates/protocol-tokio/Cargo.toml b/crates/protocol-tokio/Cargo.toml index 9209ce772..ce8539dfe 100644 --- a/crates/protocol-tokio/Cargo.toml +++ b/crates/protocol-tokio/Cargo.toml @@ -44,8 +44,8 @@ device = ["dep:wasefire-board-api", "dep:wasefire-error", "dep:wasefire-logger"] host = ["dep:wasefire-protocol"] [lints] +clippy.literal-string-with-formatting-args = "allow" clippy.mod-module-files = "warn" clippy.unit-arg = "allow" rust.unreachable-pub = "warn" -rust.unsafe-op-in-unsafe-fn = "warn" rust.unused-crate-dependencies = "warn" diff --git a/crates/protocol-tokio/src/device.rs b/crates/protocol-tokio/src/device.rs index e36f15890..3a69c2bba 100644 --- a/crates/protocol-tokio/src/device.rs +++ b/crates/protocol-tokio/src/device.rs @@ -20,7 +20,7 @@ use std::net::SocketAddr; use std::path::Path; use std::sync::{Arc, Mutex}; -use anyhow::Result; +use anyhow::{Context, Result}; use tokio::io::{AsyncRead, AsyncWrite, AsyncWriteExt}; use tokio::net::{TcpListener, TcpStream, UnixListener, UnixStream}; use tokio::select; @@ -62,11 +62,12 @@ impl Drop for Pipe { impl Pipe { pub async fn new_unix(path: &Path, push: P) -> Result { - Self::new::(path, push).await + let name = path.display(); + Self::new::(path, push).await.with_context(|| format!("binding to {name}")) } pub async fn new_tcp(addr: SocketAddr, push: P) -> Result { - Self::new::(addr, push).await + Self::new::(addr, push).await.with_context(|| format!("binding to {addr}")) } pub fn read(&mut self) -> Result>, Error> { diff --git a/crates/protocol-usb/CHANGELOG.md b/crates/protocol-usb/CHANGELOG.md index a9c3a79e3..ef6d4d367 100644 --- a/crates/protocol-usb/CHANGELOG.md +++ b/crates/protocol-usb/CHANGELOG.md @@ -8,6 +8,7 @@ ### Patch +- Fix clippy lints - Update dependencies ## 0.2.0 @@ -33,4 +34,4 @@ ## 0.1.0 - + diff --git a/crates/protocol-usb/Cargo.toml b/crates/protocol-usb/Cargo.toml index 1937cd7e6..bd65a0c92 100644 --- a/crates/protocol-usb/Cargo.toml +++ b/crates/protocol-usb/Cargo.toml @@ -43,8 +43,8 @@ device = ["dep:usb-device", "dep:wasefire-board-api", "dep:wasefire-error"] host = ["dep:anyhow", "dep:rusb", "dep:wasefire-protocol", "std"] [lints] +clippy.literal-string-with-formatting-args = "allow" clippy.mod-module-files = "warn" clippy.unit-arg = "allow" rust.unreachable-pub = "warn" -rust.unsafe-op-in-unsafe-fn = "warn" rust.unused-crate-dependencies = "warn" diff --git a/crates/protocol-usb/src/device.rs b/crates/protocol-usb/src/device.rs index bd8f5e899..de9bed612 100644 --- a/crates/protocol-usb/src/device.rs +++ b/crates/protocol-usb/src/device.rs @@ -140,7 +140,7 @@ impl State { if !matches!(self, WaitResponse) { return Err(Error::user(Code::InvalidState)); } - let packets: VecDeque<_> = Encoder::new(response).map(Into::into).collect(); + let packets: VecDeque<_> = Encoder::new(response).collect(); log::debug!("Sending a message of {} bytes in {} packets.", response.len(), packets.len()); *self = SendResponse { packets }; self.send(ep); diff --git a/crates/protocol/CHANGELOG.md b/crates/protocol/CHANGELOG.md index 6653c024c..c04fea52b 100644 --- a/crates/protocol/CHANGELOG.md +++ b/crates/protocol/CHANGELOG.md @@ -34,4 +34,4 @@ ## 0.1.0 - + diff --git a/crates/protocol/Cargo.toml b/crates/protocol/Cargo.toml index 2580e9bb0..433279d9b 100644 --- a/crates/protocol/Cargo.toml +++ b/crates/protocol/Cargo.toml @@ -28,8 +28,8 @@ host = ["dep:anyhow", "wasefire-error/std"] serde = ["dep:serde"] [lints] +clippy.literal-string-with-formatting-args = "allow" clippy.mod-module-files = "warn" clippy.unit-arg = "allow" rust.unreachable-pub = "warn" -rust.unsafe-op-in-unsafe-fn = "warn" rust.unused-crate-dependencies = "warn" diff --git a/crates/protocol/crates/schema/Cargo.toml b/crates/protocol/crates/schema/Cargo.toml index 058ad8160..ba3b1b74c 100644 --- a/crates/protocol/crates/schema/Cargo.toml +++ b/crates/protocol/crates/schema/Cargo.toml @@ -19,8 +19,8 @@ device = ["wasefire-protocol/device"] host = ["wasefire-protocol/host"] [lints] +clippy.literal-string-with-formatting-args = "allow" clippy.mod-module-files = "warn" clippy.unit-arg = "allow" rust.unreachable-pub = "warn" -rust.unsafe-op-in-unsafe-fn = "warn" rust.unused-crate-dependencies = "warn" diff --git a/crates/runner-host/Cargo.lock b/crates/runner-host/Cargo.lock index 5218518e2..ff939caac 100644 --- a/crates/runner-host/Cargo.lock +++ b/crates/runner-host/Cargo.lock @@ -2448,7 +2448,7 @@ dependencies = [ [[package]] name = "wasefire-scheduler" -version = "0.4.1-git" +version = "0.5.0-git" dependencies = [ "bytemuck", "derive-where", diff --git a/crates/runner-host/Cargo.toml b/crates/runner-host/Cargo.toml index 11e512e11..7fe65dc61 100644 --- a/crates/runner-host/Cargo.toml +++ b/crates/runner-host/Cargo.toml @@ -67,7 +67,7 @@ native = ["wasefire-scheduler/native"] wasm = ["dep:wasefire-interpreter", "wasefire-scheduler/wasm"] [lints] +clippy.literal-string-with-formatting-args = "allow" clippy.mod-module-files = "warn" clippy.unit-arg = "allow" -rust.unsafe-op-in-unsafe-fn = "warn" rust.unused-crate-dependencies = "warn" diff --git a/crates/runner-host/crates/web-client/Cargo.toml b/crates/runner-host/crates/web-client/Cargo.toml index 2b3b23395..6b40ee117 100644 --- a/crates/runner-host/crates/web-client/Cargo.toml +++ b/crates/runner-host/crates/web-client/Cargo.toml @@ -18,7 +18,7 @@ yew = { version = "0.21", features = ["csr"] } yew-hooks = "0.3.2" [lints] +clippy.literal-string-with-formatting-args = "allow" clippy.mod-module-files = "warn" clippy.unit-arg = "allow" -rust.unsafe-op-in-unsafe-fn = "warn" rust.unused-crate-dependencies = "warn" diff --git a/crates/runner-host/crates/web-common/Cargo.toml b/crates/runner-host/crates/web-common/Cargo.toml index ac3ffa193..cc2ba86c1 100644 --- a/crates/runner-host/crates/web-common/Cargo.toml +++ b/crates/runner-host/crates/web-common/Cargo.toml @@ -11,7 +11,7 @@ serde = { version = "1.0.202", features = ["derive"] } wasefire-protocol = { path = "../../../protocol", features = ["serde"] } [lints] +clippy.literal-string-with-formatting-args = "allow" clippy.mod-module-files = "warn" clippy.unit-arg = "allow" -rust.unsafe-op-in-unsafe-fn = "warn" rust.unused-crate-dependencies = "warn" diff --git a/crates/runner-host/crates/web-server/Cargo.toml b/crates/runner-host/crates/web-server/Cargo.toml index cb1b42505..fc1d26e34 100644 --- a/crates/runner-host/crates/web-server/Cargo.toml +++ b/crates/runner-host/crates/web-server/Cargo.toml @@ -22,7 +22,7 @@ web-common = { path = "../web-common" } log = ["dep:log", "wasefire-logger/log"] [lints] +clippy.literal-string-with-formatting-args = "allow" clippy.mod-module-files = "warn" clippy.unit-arg = "allow" -rust.unsafe-op-in-unsafe-fn = "warn" rust.unused-crate-dependencies = "warn" diff --git a/crates/runner-host/src/main.rs b/crates/runner-host/src/main.rs index 5e53b196b..cd85ded06 100644 --- a/crates/runner-host/src/main.rs +++ b/crates/runner-host/src/main.rs @@ -150,9 +150,9 @@ async fn main() -> Result<()> { move |event: Event| drop(sender.try_send(event.into())) }; let protocol = match FLAGS.protocol { - Protocol::Tcp => ProtocolState::Pipe(Pipe::new_tcp(FLAGS.tcp_addr, push).await.unwrap()), + Protocol::Tcp => ProtocolState::Pipe(Pipe::new_tcp(FLAGS.tcp_addr, push).await?), Protocol::Unix => { - let pipe = Pipe::new_unix(&FLAGS.unix_path, push).await.unwrap(); + let pipe = Pipe::new_unix(&FLAGS.unix_path, push).await?; cleanup::push(Box::new(move || drop(std::fs::remove_file(&FLAGS.unix_path)))); ProtocolState::Pipe(pipe) } diff --git a/crates/runner-nordic/Cargo.lock b/crates/runner-nordic/Cargo.lock index aafe8ad24..46c99d7a9 100644 --- a/crates/runner-nordic/Cargo.lock +++ b/crates/runner-nordic/Cargo.lock @@ -1233,7 +1233,7 @@ dependencies = [ [[package]] name = "wasefire-scheduler" -version = "0.4.1-git" +version = "0.5.0-git" dependencies = [ "bytemuck", "defmt", diff --git a/crates/runner-nordic/Cargo.toml b/crates/runner-nordic/Cargo.toml index 62cbd2476..9bb880be9 100644 --- a/crates/runner-nordic/Cargo.toml +++ b/crates/runner-nordic/Cargo.toml @@ -84,7 +84,7 @@ wasm = ["dep:wasefire-interpreter", "wasefire-scheduler/wasm"] _software-crypto = ["software-crypto-aes256-gcm", "software-crypto-p256", "software-crypto-sha256"] [lints] +clippy.literal-string-with-formatting-args = "allow" clippy.mod-module-files = "warn" clippy.unit-arg = "allow" -rust.unsafe-op-in-unsafe-fn = "warn" rust.unused-crate-dependencies = "warn" diff --git a/crates/runner-nordic/crates/bootloader/Cargo.toml b/crates/runner-nordic/crates/bootloader/Cargo.toml index 5a084595a..2fab04037 100644 --- a/crates/runner-nordic/crates/bootloader/Cargo.toml +++ b/crates/runner-nordic/crates/bootloader/Cargo.toml @@ -20,7 +20,7 @@ lto = true panic = "abort" [lints] +clippy.literal-string-with-formatting-args = "allow" clippy.mod-module-files = "warn" clippy.unit-arg = "allow" -rust.unsafe-op-in-unsafe-fn = "warn" rust.unused-crate-dependencies = "warn" diff --git a/crates/runner-nordic/crates/header/Cargo.toml b/crates/runner-nordic/crates/header/Cargo.toml index db1906186..76666cdf3 100644 --- a/crates/runner-nordic/crates/header/Cargo.toml +++ b/crates/runner-nordic/crates/header/Cargo.toml @@ -11,7 +11,7 @@ edition = "2024" alloc = [] [lints] +clippy.literal-string-with-formatting-args = "allow" clippy.mod-module-files = "warn" clippy.unit-arg = "allow" -rust.unsafe-op-in-unsafe-fn = "warn" rust.unused-crate-dependencies = "warn" diff --git a/crates/scheduler/CHANGELOG.md b/crates/scheduler/CHANGELOG.md index c1a006664..d5362698f 100644 --- a/crates/scheduler/CHANGELOG.md +++ b/crates/scheduler/CHANGELOG.md @@ -1,6 +1,10 @@ # Changelog -## 0.4.1-git +## 0.5.0-git + +### Major + +- Do not allocate if the size is zero for the applet API ### Minor @@ -8,6 +12,7 @@ ### Patch +- Fix clippy lints - Update dependencies ## 0.4.0 @@ -181,4 +186,4 @@ ## 0.1.0 - + diff --git a/crates/scheduler/Cargo.lock b/crates/scheduler/Cargo.lock index 4f28b7cc2..289251562 100644 --- a/crates/scheduler/Cargo.lock +++ b/crates/scheduler/Cargo.lock @@ -808,7 +808,7 @@ dependencies = [ [[package]] name = "wasefire-scheduler" -version = "0.4.1-git" +version = "0.5.0-git" dependencies = [ "bytemuck", "defmt", diff --git a/crates/scheduler/Cargo.toml b/crates/scheduler/Cargo.toml index a61f792eb..9b34352e0 100644 --- a/crates/scheduler/Cargo.toml +++ b/crates/scheduler/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "wasefire-scheduler" -version = "0.4.1-git" +version = "0.5.0-git" authors = ["Julien Cretin "] license = "Apache-2.0" publish = true @@ -226,7 +226,7 @@ internal-debug = [] internal-hash-context = [] [lints] +clippy.literal-string-with-formatting-args = "allow" clippy.mod-module-files = "warn" clippy.unit-arg = "allow" -rust.unsafe-op-in-unsafe-fn = "warn" rust.unused-crate-dependencies = "warn" diff --git a/crates/scheduler/src/applet/store.rs b/crates/scheduler/src/applet/store.rs index 87f7840b7..30478b75b 100644 --- a/crates/scheduler/src/applet/store.rs +++ b/crates/scheduler/src/applet/store.rs @@ -61,14 +61,16 @@ pub trait MemoryApi { Ok(bytemuck::from_bytes_mut(self.get_mut(ptr, core::mem::size_of::() as u32)?)) } - fn alloc_copy(&mut self, ptr_ptr: u32, len_ptr: Option, data: &[u8]) -> Result<(), Trap> { + fn alloc_copy(&mut self, ptr_ptr: u32, len_ptr: Option, data: &[u8]) -> Result { let len = data.len() as u32; - let ptr = self.alloc(len, 1)?; - self.get_mut(ptr, len)?.copy_from_slice(data); - self.get_mut(ptr_ptr, 4)?.copy_from_slice(&ptr.to_le_bytes()); + if 0 < len { + let ptr = self.alloc(len, 1)?; + self.get_mut(ptr, len)?.copy_from_slice(data); + self.get_mut(ptr_ptr, 4)?.copy_from_slice(&ptr.to_le_bytes()); + } if let Some(len_ptr) = len_ptr { self.get_mut(len_ptr, 4)?.copy_from_slice(&len.to_le_bytes()); } - Ok(()) + Ok(len) } } diff --git a/crates/scheduler/src/call/crypto/gcm.rs b/crates/scheduler/src/call/crypto/gcm.rs index c054fa2eb..58b9a933c 100644 --- a/crates/scheduler/src/call/crypto/gcm.rs +++ b/crates/scheduler/src/call/crypto/gcm.rs @@ -40,8 +40,8 @@ fn support(call: SchedulerCall) { let support = { use wasefire_applet_api::crypto::gcm::Support; let support = board::crypto::Aes256Gcm::::SUPPORT; - (support.no_copy as u32) << Support::NoCopy as u32 - | (support.in_place_no_copy as u32) << Support::InPlaceNoCopy as u32 + ((support.no_copy as u32) << Support::NoCopy as u32) + | ((support.in_place_no_copy as u32) << Support::InPlaceNoCopy as u32) }; #[cfg(not(feature = "board-api-crypto-aes256-gcm"))] let support = 0; diff --git a/crates/scheduler/src/call/platform.rs b/crates/scheduler/src/call/platform.rs index 22a82c348..4869ea77a 100644 --- a/crates/scheduler/src/call/platform.rs +++ b/crates/scheduler/src/call/platform.rs @@ -23,9 +23,9 @@ use wasefire_board_api::platform::Api as _; use crate::DispatchSchedulerCall; #[cfg(feature = "applet-api-platform")] -use crate::applet::store::MemoryApi; +use crate::SchedulerCall; #[cfg(feature = "applet-api-platform")] -use crate::{Applet, Failure, SchedulerCall}; +use crate::applet::store::MemoryApi; #[cfg(feature = "applet-api-platform-protocol")] mod protocol; @@ -50,14 +50,14 @@ pub fn process(call: Api>) { #[cfg(feature = "applet-api-platform")] fn serial(mut call: SchedulerCall) { let api::serial::Params { ptr } = call.read(); - let result = alloc_bytes(call.applet(), *ptr, &board::Platform::::serial()); + let result = try { call.memory().alloc_copy(*ptr, None, &board::Platform::::serial())? }; call.reply(result); } #[cfg(feature = "applet-api-platform")] fn version(mut call: SchedulerCall) { let api::version::Params { ptr } = call.read(); - let result = alloc_bytes(call.applet(), *ptr, &board::Platform::::version()); + let result = try { call.memory().alloc_copy(*ptr, None, &board::Platform::::version())? }; call.reply(result); } @@ -66,15 +66,3 @@ fn reboot(call: SchedulerCall) { let api::reboot::Params {} = call.read(); call.reply(board::Platform::::reboot().map_err(|x| x.into())); } - -#[cfg(feature = "applet-api-platform")] -fn alloc_bytes( - applet: &mut Applet, ptr_ptr: u32, data: &[u8], -) -> Result { - if data.is_empty() { - return Ok(0); - } - let mut memory = applet.memory(); - memory.alloc_copy(ptr_ptr, None, data)?; - Ok(data.len() as u32) -} diff --git a/crates/scheduler/src/call/platform/protocol.rs b/crates/scheduler/src/call/platform/protocol.rs index ce9515aed..05af8f2da 100644 --- a/crates/scheduler/src/call/platform/protocol.rs +++ b/crates/scheduler/src/call/platform/protocol.rs @@ -37,8 +37,7 @@ fn read(mut call: SchedulerCall) { match applet.get_request()? { None => false, Some(value) => { - let mut memory = applet.memory(); - memory.alloc_copy(*ptr_ptr, Some(*len_ptr), &value)?; + applet.memory().alloc_copy(*ptr_ptr, Some(*len_ptr), &value)?; true } } diff --git a/crates/scheduler/src/call/platform/update.rs b/crates/scheduler/src/call/platform/update.rs index 83d5bdedb..0d91d6fcd 100644 --- a/crates/scheduler/src/call/platform/update.rs +++ b/crates/scheduler/src/call/platform/update.rs @@ -37,11 +37,9 @@ fn is_supported(call: SchedulerCall) { fn metadata(mut call: SchedulerCall) { let api::metadata::Params { ptr: ptr_ptr, len: len_ptr } = call.read(); - let applet = call.applet(); - let mut memory = applet.memory(); let result = try { let metadata = board::platform::Update::::metadata()?; - memory.alloc_copy(*ptr_ptr, Some(*len_ptr), &metadata)?; + call.memory().alloc_copy(*ptr_ptr, Some(*len_ptr), &metadata)?; }; call.reply(result); } diff --git a/crates/store/CHANGELOG.md b/crates/store/CHANGELOG.md index 24b70d94f..5f8746ed4 100644 --- a/crates/store/CHANGELOG.md +++ b/crates/store/CHANGELOG.md @@ -74,4 +74,4 @@ ## 0.1.0 - + diff --git a/crates/store/Cargo.toml b/crates/store/Cargo.toml index 7844cad88..41bdf89b6 100644 --- a/crates/store/Cargo.toml +++ b/crates/store/Cargo.toml @@ -24,8 +24,8 @@ tempfile = "3.10.1" std = ["wasefire-error/std"] [lints] +clippy.literal-string-with-formatting-args = "allow" clippy.mod-module-files = "warn" clippy.unit-arg = "allow" rust.unreachable-pub = "warn" -rust.unsafe-op-in-unsafe-fn = "warn" rust.unused-crate-dependencies = "warn" diff --git a/crates/store/fuzz/Cargo.toml b/crates/store/fuzz/Cargo.toml index b89abfeb5..c3411c726 100644 --- a/crates/store/fuzz/Cargo.toml +++ b/crates/store/fuzz/Cargo.toml @@ -21,6 +21,6 @@ name = "store" path = "fuzz_targets/store.rs" [lints] +clippy.literal-string-with-formatting-args = "allow" clippy.mod-module-files = "warn" clippy.unit-arg = "allow" -rust.unsafe-op-in-unsafe-fn = "warn" diff --git a/crates/store/fuzz/src/lib.rs b/crates/store/fuzz/src/lib.rs index aaac833da..f94b178b9 100644 --- a/crates/store/fuzz/src/lib.rs +++ b/crates/store/fuzz/src/lib.rs @@ -89,7 +89,7 @@ impl Entropy<'_> { } let b = self.bit; self.bit += 1; - self.data[b / 8] & 1 << (b % 8) != 0 + self.data[b / 8] & (1 << (b % 8)) != 0 } /// Reads a number with a given bit-width. diff --git a/crates/stub/CHANGELOG.md b/crates/stub/CHANGELOG.md index 36ae9564d..575340e80 100644 --- a/crates/stub/CHANGELOG.md +++ b/crates/stub/CHANGELOG.md @@ -54,4 +54,4 @@ ## 0.1.0 - + diff --git a/crates/stub/Cargo.toml b/crates/stub/Cargo.toml index b0986f732..1b07b8d30 100644 --- a/crates/stub/Cargo.toml +++ b/crates/stub/Cargo.toml @@ -32,8 +32,8 @@ version = "0.7.1-git" path = "../api" [lints] +clippy.literal-string-with-formatting-args = "allow" clippy.mod-module-files = "warn" clippy.unit-arg = "allow" rust.unreachable-pub = "warn" -rust.unsafe-op-in-unsafe-fn = "warn" rust.unused-crate-dependencies = "warn" diff --git a/crates/sync/CHANGELOG.md b/crates/sync/CHANGELOG.md index aea73d79f..49d8f13e3 100644 --- a/crates/sync/CHANGELOG.md +++ b/crates/sync/CHANGELOG.md @@ -24,4 +24,4 @@ ## 0.1.0 - + diff --git a/crates/sync/Cargo.toml b/crates/sync/Cargo.toml index cf1fcb050..d3709275e 100644 --- a/crates/sync/Cargo.toml +++ b/crates/sync/Cargo.toml @@ -23,8 +23,8 @@ features = ["lazy", "portable_atomic", "spin_mutex"] unsafe-assume-single-core = ["portable-atomic/unsafe-assume-single-core"] [lints] +clippy.literal-string-with-formatting-args = "allow" clippy.mod-module-files = "warn" clippy.unit-arg = "allow" rust.unreachable-pub = "warn" -rust.unsafe-op-in-unsafe-fn = "warn" rust.unused-crate-dependencies = "warn" diff --git a/crates/wasm-bench/Cargo.lock b/crates/wasm-bench/Cargo.lock index 17dbfdd5c..4dbd09de6 100644 --- a/crates/wasm-bench/Cargo.lock +++ b/crates/wasm-bench/Cargo.lock @@ -23,6 +23,12 @@ dependencies = [ "memchr", ] +[[package]] +name = "allocator-api2" +version = "0.2.21" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "683d7910e743518b0e34f1186f92494becacb047c7b6bf616c96772180fef923" + [[package]] name = "ansi_term" version = "0.12.1" @@ -34,9 +40,9 @@ dependencies = [ [[package]] name = "anyhow" -version = "1.0.86" +version = "1.0.95" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b3d1d046238990b9cf5bcde22a3fb3584ee5cf65fb2765f454ed428c7a0063da" +checksum = "34ac096ce696dc2fcabef30516bb13c0a68a11d30131d3df6f04711467681b04" [[package]] name = "arbitrary" @@ -128,6 +134,9 @@ name = "bumpalo" version = "3.16.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "79296716171880943b8470b5f8d03aa55eb2e645a4874bdbb28adb49162e012c" +dependencies = [ + "allocator-api2", +] [[package]] name = "bytemuck" @@ -146,7 +155,7 @@ checksum = "3fa76293b4f7bb636ab88fd78228235b5248b4d05cc589aed610f954af5d7c7a" dependencies = [ "proc-macro2", "quote", - "syn 2.0.68", + "syn 2.0.96", ] [[package]] @@ -255,18 +264,18 @@ dependencies = [ [[package]] name = "cranelift-bforest" -version = "0.114.0" +version = "0.115.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2ba4f80548f22dc9c43911907b5e322c5555544ee85f785115701e6a28c9abe1" +checksum = "ac89549be94911dd0e839b4a7db99e9ed29c17517e1c026f61066884c168aa3c" dependencies = [ "cranelift-entity", ] [[package]] name = "cranelift-bitset" -version = "0.114.0" +version = "0.115.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "005884e3649c3e5ff2dc79e8a94b138f11569cc08a91244a292714d2a86e9156" +checksum = "b9bd49369f76c77e34e641af85d0956869237832c118964d08bf5f51f210875a" dependencies = [ "serde", "serde_derive", @@ -274,9 +283,9 @@ dependencies = [ [[package]] name = "cranelift-codegen" -version = "0.114.0" +version = "0.115.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "fe4036255ec33ce9a37495dfbcfc4e1118fd34e693eff9a1e106336b7cd16a9b" +checksum = "fd96ce9cf8efebd7f5ab8ced5a0ce44250280bbae9f593d74a6d7effc3582a35" dependencies = [ "bumpalo", "cranelift-bforest", @@ -287,7 +296,7 @@ dependencies = [ "cranelift-entity", "cranelift-isle", "gimli", - "hashbrown", + "hashbrown 0.14.5", "log", "regalloc2", "rustc-hash 2.0.0", @@ -298,33 +307,33 @@ dependencies = [ [[package]] name = "cranelift-codegen-meta" -version = "0.114.0" +version = "0.115.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f7ca74f4b68319da11d39e894437cb6e20ec7c2e11fbbda823c3bf207beedff7" +checksum = "5a68e358827afe4bfb6239fcbf6fbd5ac56206ece8a99c8f5f9bbd518773281a" dependencies = [ "cranelift-codegen-shared", ] [[package]] name = "cranelift-codegen-shared" -version = "0.114.0" +version = "0.115.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "897e54f433a0269c4187871aa06d452214d5515d228d5bdc22219585e9eef895" +checksum = "e184c9767afbe73d50c55ec29abcf4c32f9baf0d9d22b86d58c4d55e06dee181" [[package]] name = "cranelift-control" -version = "0.114.0" +version = "0.115.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "29cb4018f5bf59fb53f515fa9d80e6f8c5ce19f198dc538984ebd23ecf8965ec" +checksum = "5cc7664f2a66f053e33f149e952bb5971d138e3af637f5097727ed6dc0ed95dd" dependencies = [ "arbitrary", ] [[package]] name = "cranelift-entity" -version = "0.114.0" +version = "0.115.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "305399fd781a2953ac78c1396f02ff53144f39c33eb7fc7789cf4e8936d13a96" +checksum = "118597e3a9cf86c3556fa579a7a23b955fa18231651a52a77a2475d305a9cf84" dependencies = [ "cranelift-bitset", "serde", @@ -333,9 +342,9 @@ dependencies = [ [[package]] name = "cranelift-frontend" -version = "0.114.0" +version = "0.115.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9230b460a128d53653456137751d27baf567947a3ab8c0c4d6e31fd08036d81e" +checksum = "7638ea1efb069a0aa18d8ee67401b6b0d19f6bfe5de5e9ede348bfc80bb0d8c7" dependencies = [ "cranelift-codegen", "log", @@ -345,15 +354,15 @@ dependencies = [ [[package]] name = "cranelift-isle" -version = "0.114.0" +version = "0.115.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b961e24ae3ec9813a24a15ae64bbd2a42e4de4d79a7f3225a412e3b94e78d1c8" +checksum = "15c53e1152a0b01c4ed2b1e0535602b8e86458777dd9d18b28732b16325c7dc0" [[package]] name = "cranelift-native" -version = "0.114.0" +version = "0.115.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4d5bd76df6c9151188dfa428c863b33da5b34561b67f43c0cf3f24a794f9fa1f" +checksum = "7b7d8f895444fa52dd7bdd0bed11bf007a7fb43af65a6deac8fcc4094c6372f7" dependencies = [ "cranelift-codegen", "libc", @@ -501,6 +510,12 @@ dependencies = [ "typenum", ] +[[package]] +name = "foldhash" +version = "0.1.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a0d2fde1f7b3d48b8395d5f2de76c18a528bd6a9cdde438df747bfcba3e05d6f" + [[package]] name = "gimli" version = "0.31.1" @@ -544,6 +559,15 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "e5274423e17b7c9fc20b6e7e208532f9b19825d82dfd615708b70edd83df41f1" dependencies = [ "ahash", +] + +[[package]] +name = "hashbrown" +version = "0.15.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "bf151400ff0baff5465007dd2f3e717f3fe502074ca563069ce3a6629d07b289" +dependencies = [ + "foldhash", "serde", ] @@ -600,7 +624,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "168fb715dda47215e360912c096649d23d58bf392ac62f73919e831745e40f26" dependencies = [ "equivalent", - "hashbrown", + "hashbrown 0.14.5", "serde", ] @@ -810,17 +834,17 @@ checksum = "681030a937600a36906c185595136d26abfebb4aa9c65701cefcaf8578bb982b" dependencies = [ "proc-macro2", "quote", - "syn 2.0.68", + "syn 2.0.96", ] [[package]] name = "object" -version = "0.36.1" +version = "0.36.7" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "081b846d1d56ddfc18fdf1a922e4f6e07a11768ea1b92dec44e42b72712ccfce" +checksum = "62948e14d923ea95ea2c7c86c71013138b66525b86bdc08d2dcc262bdb497b87" dependencies = [ "crc32fast", - "hashbrown", + "hashbrown 0.15.2", "indexmap", "memchr", ] @@ -876,9 +900,9 @@ dependencies = [ [[package]] name = "proc-macro2" -version = "1.0.86" +version = "1.0.93" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5e719e8df665df0d1c8fbfd238015744736151d4445ec0836b8e628aae103b77" +checksum = "60946a68e5f9d28b0dc1c21bb8a97ee7d018a8b322fa57838ba31cc878e22d99" dependencies = [ "unicode-ident", ] @@ -894,9 +918,9 @@ dependencies = [ [[package]] name = "pulley-interpreter" -version = "27.0.0" +version = "28.0.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a3b8d81cf799e20564931e9867ca32de545188c6ee4c2e0f6e41d32f0c7dc6fb" +checksum = "403a1a95f4c18a45c86c7bff13df00347afd0abcbf2e54af273c837339ffcf77" dependencies = [ "cranelift-bitset", "log", @@ -920,14 +944,15 @@ checksum = "ec0be4795e2f6a28069bec0b5ff3e2ac9bafc99e6a9a7dc3547996c5c816922c" [[package]] name = "regalloc2" -version = "0.10.2" +version = "0.11.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "12908dbeb234370af84d0579b9f68258a0f67e201412dd9a2814e6f45b2fc0f0" +checksum = "145c1c267e14f20fb0f88aa76a1c5ffec42d592c1d28b3cd9148ae35916158d3" dependencies = [ - "hashbrown", + "allocator-api2", + "bumpalo", + "hashbrown 0.15.2", "log", "rustc-hash 2.0.0", - "slice-group-by", "smallvec", ] @@ -981,7 +1006,7 @@ checksum = "f265be5d634272320a7de94cea15c22a3bfdd4eb42eb43edc528415f066a1f25" dependencies = [ "proc-macro2", "quote", - "syn 2.0.68", + "syn 2.0.96", ] [[package]] @@ -1009,7 +1034,7 @@ checksum = "30f19a85fe107b65031e0ba8ec60c34c2494069fe910d6c297f5e7cb5a6f76d0" dependencies = [ "proc-macro2", "quote", - "syn 2.0.68", + "syn 2.0.96", ] [[package]] @@ -1098,22 +1123,22 @@ checksum = "388a1df253eca08550bef6c72392cfe7c30914bf41df5269b68cbd6ff8f570a3" [[package]] name = "serde" -version = "1.0.204" +version = "1.0.217" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "bc76f558e0cbb2a839d37354c575f1dc3fdc6546b5be373ba43d95f231bf7c12" +checksum = "02fc4265df13d6fa1d00ecff087228cc0a2b5f3c0e87e258d8b94a156e984c70" dependencies = [ "serde_derive", ] [[package]] name = "serde_derive" -version = "1.0.204" +version = "1.0.217" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e0cd7e117be63d3c3678776753929474f3b04a43a080c744d6b0ae2a8c28e222" +checksum = "5a9bf7cf98d04a2b28aead066b7496853d4779c9cc183c440dbac457641e19a0" dependencies = [ "proc-macro2", "quote", - "syn 2.0.68", + "syn 2.0.96", ] [[package]] @@ -1139,12 +1164,6 @@ version = "1.3.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "0fda2ff0d084019ba4d7c6f371c95d8fd75ce3524c3cb8fb653a3023f6323e64" -[[package]] -name = "slice-group-by" -version = "0.3.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "826167069c09b99d56f31e9ae5c99049e932a98c9dc2dac47645b08dbbf76ba7" - [[package]] name = "smallvec" version = "1.13.2" @@ -1204,9 +1223,9 @@ dependencies = [ [[package]] name = "syn" -version = "2.0.68" +version = "2.0.96" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "901fa70d88b9d6c98022e23b4136f9f3e54e4662c3bc1bd1d84a42a9a0f0c1e9" +checksum = "d5d0adab1ae378d7f53bdebc67a39f1f151407ef230f0ce2883572f5d8985c80" dependencies = [ "proc-macro2", "quote", @@ -1254,7 +1273,7 @@ checksum = "46c3384250002a6d5af4d114f2845d37b57521033f30d5c3f46c4d70e1197533" dependencies = [ "proc-macro2", "quote", - "syn 2.0.68", + "syn 2.0.96", ] [[package]] @@ -1370,12 +1389,12 @@ dependencies = [ [[package]] name = "wasm-encoder" -version = "0.219.1" +version = "0.221.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "29cbbd772edcb8e7d524a82ee8cef8dd046fc14033796a754c3ad246d019fa54" +checksum = "c17a3bd88f2155da63a1f2fcb8a56377a24f0b6dfed12733bb5f544e86f690c5" dependencies = [ "leb128", - "wasmparser 0.219.1", + "wasmparser", ] [[package]] @@ -1411,7 +1430,7 @@ dependencies = [ "wasmi_collections", "wasmi_core", "wasmi_ir", - "wasmparser 0.221.2", + "wasmparser", ] [[package]] @@ -1441,50 +1460,40 @@ dependencies = [ [[package]] name = "wasmparser" -version = "0.219.1" +version = "0.221.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5c771866898879073c53b565a6c7b49953795159836714ac56a5befb581227c5" +checksum = "9845c470a2e10b61dd42c385839cdd6496363ed63b5c9e420b5488b77bd22083" dependencies = [ - "ahash", "bitflags 2.6.0", - "hashbrown", + "hashbrown 0.15.2", "indexmap", "semver 1.0.23", "serde", ] -[[package]] -name = "wasmparser" -version = "0.221.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9845c470a2e10b61dd42c385839cdd6496363ed63b5c9e420b5488b77bd22083" -dependencies = [ - "bitflags 2.6.0", -] - [[package]] name = "wasmprinter" -version = "0.219.1" +version = "0.221.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "228cdc1f30c27816da225d239ce4231f28941147d34713dee8f1fff7cb330e54" +checksum = "a80742ff1b9e6d8c231ac7c7247782c6fc5bce503af760bca071811e5fc9ee56" dependencies = [ "anyhow", "termcolor", - "wasmparser 0.219.1", + "wasmparser", ] [[package]] name = "wasmtime" -version = "27.0.0" +version = "28.0.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5b79302e3e084713249cc5622e8608e7410afdeeea8c8026d04f491d1fab0b4b" +checksum = "f639ecae347b9a2227e453a7b7671e84370a0b61f47a15e0390fe9b7725e47b3" dependencies = [ "anyhow", "bitflags 2.6.0", "bumpalo", "cc", "cfg-if", - "hashbrown", + "hashbrown 0.14.5", "indexmap", "libc", "libm", @@ -1503,11 +1512,12 @@ dependencies = [ "smallvec", "sptr", "target-lexicon", - "wasmparser 0.219.1", + "wasmparser", "wasmtime-asm-macros", "wasmtime-component-macro", "wasmtime-cranelift", "wasmtime-environ", + "wasmtime-fiber", "wasmtime-jit-icache-coherence", "wasmtime-slab", "wasmtime-versioned-export-macros", @@ -1516,23 +1526,23 @@ dependencies = [ [[package]] name = "wasmtime-asm-macros" -version = "27.0.0" +version = "28.0.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "fe53a24e7016a5222875d8ca3ad6024b464465985693c42098cd0bb710002c28" +checksum = "882a18800471cfc063c8b3ccf75723784acc3fd534009ac09421f2fac2fcdcec" dependencies = [ "cfg-if", ] [[package]] name = "wasmtime-component-macro" -version = "27.0.0" +version = "28.0.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e118acbd2bc09b32ad8606bc7cef793bf5019c1b107772e64dc6c76b5055d40b" +checksum = "eb5c0a77c9e1927c3d471f53cc13767c3d3438e5d5ffd394e3eb31c86445fd60" dependencies = [ "anyhow", "proc-macro2", "quote", - "syn 2.0.68", + "syn 2.0.96", "wasmtime-component-util", "wasmtime-wit-bindgen", "wit-parser", @@ -1540,15 +1550,15 @@ dependencies = [ [[package]] name = "wasmtime-component-util" -version = "27.0.0" +version = "28.0.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4a6db4f3ee18c699629eabb9c64e77efe5a93a5137f098db7cab295037ba41c2" +checksum = "43702ca98bf5162eca0573db691ed9ecd36d716f8c6688410fe26ec16b6f9bcb" [[package]] name = "wasmtime-cranelift" -version = "27.0.0" +version = "28.0.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8b87e6c78f562b50aff1afd87ff32a57e241424c846c1c8f3c5fd352d2d62906" +checksum = "20070aa5b75080a8932ec328419faf841df2bc6ceb16b55b0df2b952098392a2" dependencies = [ "anyhow", "cfg-if", @@ -1564,16 +1574,16 @@ dependencies = [ "smallvec", "target-lexicon", "thiserror", - "wasmparser 0.219.1", + "wasmparser", "wasmtime-environ", "wasmtime-versioned-export-macros", ] [[package]] name = "wasmtime-environ" -version = "27.0.0" +version = "28.0.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c25bfeaa16432d59a0706e2463d315ef4c9ebcfaf5605670b99d46373bdf9f27" +checksum = "2604ddb24879d4dc1dedcb7081d7a8e017259bce916fdae097a97db52cbaab80" dependencies = [ "anyhow", "cranelift-bitset", @@ -1588,15 +1598,30 @@ dependencies = [ "smallvec", "target-lexicon", "wasm-encoder", - "wasmparser 0.219.1", + "wasmparser", "wasmprinter", ] +[[package]] +name = "wasmtime-fiber" +version = "28.0.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "98593412d2b167ebe2b59d4a17a184978a72f976b53b3a0ec05629451079ac1d" +dependencies = [ + "anyhow", + "cc", + "cfg-if", + "rustix", + "wasmtime-asm-macros", + "wasmtime-versioned-export-macros", + "windows-sys 0.59.0", +] + [[package]] name = "wasmtime-jit-icache-coherence" -version = "27.0.0" +version = "28.0.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "91b218a92866f74f35162f5d03a4e0f62cd0e1cc624285b1014275e5d4575fad" +checksum = "d40d7722b9e1fbeae135715710a8a2570b1e6cf72b74dd653962d89831c6c70d" dependencies = [ "anyhow", "cfg-if", @@ -1606,26 +1631,26 @@ dependencies = [ [[package]] name = "wasmtime-slab" -version = "27.0.0" +version = "28.0.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4d5f8acf677ee6b3b8ba400dd9753ea4769e56a95c4b30b045ac6d2d54b2f8ea" +checksum = "8579c335220b4ece9aa490a0e8b46de78cd342b195ab21ff981d095e14b52383" [[package]] name = "wasmtime-versioned-export-macros" -version = "27.0.0" +version = "28.0.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "df09be00c38f49172ca9936998938476e3f2df782673a39ae2ef9fb0838341b6" +checksum = "d7de0a56fb0a69b185968f2d7a9ba54750920a806470dff7ad8de91ac06d277e" dependencies = [ "proc-macro2", "quote", - "syn 2.0.68", + "syn 2.0.96", ] [[package]] name = "wasmtime-wit-bindgen" -version = "27.0.0" +version = "28.0.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "bf3963c9c29df91564d8bd181eb00d0dbaeafa1b2a01e15952bb7391166b704e" +checksum = "969f83022dac3435d6469edb582ceed04cfe32aa44dc3ef16e5cb55574633df8" dependencies = [ "anyhow", "heck", @@ -1760,9 +1785,9 @@ checksum = "589f6da84c646204747d1270a2a5661ea66ed1cced2631d546fdfb155959f9ec" [[package]] name = "wit-parser" -version = "0.219.1" +version = "0.221.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4a86f669283257e8e424b9a4fc3518e3ade0b95deb9fbc0f93a1876be3eda598" +checksum = "fbe1538eea6ea5ddbe5defd0dc82539ad7ba751e1631e9185d24a931f0a5adc8" dependencies = [ "anyhow", "id-arena", @@ -1773,7 +1798,7 @@ dependencies = [ "serde_derive", "serde_json", "unicode-xid", - "wasmparser 0.219.1", + "wasmparser", ] [[package]] @@ -1793,5 +1818,5 @@ checksum = "fa4f8080344d4671fb4e831a13ad1e68092748387dfc4f55e356242fae12ce3e" dependencies = [ "proc-macro2", "quote", - "syn 2.0.68", + "syn 2.0.96", ] diff --git a/crates/wasm-bench/Cargo.toml b/crates/wasm-bench/Cargo.toml index 015a3ec49..6a2ec082e 100644 --- a/crates/wasm-bench/Cargo.toml +++ b/crates/wasm-bench/Cargo.toml @@ -31,7 +31,7 @@ features = ["build-bindgen", "use-32bit-slots"] optional = true [dependencies.wasmtime] -version = "27.0.0" +version = "28.0.0" default-features = false features = ["cranelift", "runtime"] optional = true @@ -58,8 +58,8 @@ lto = true panic = "abort" [lints] +clippy.literal-string-with-formatting-args = "allow" clippy.mod-module-files = "warn" clippy.unit-arg = "allow" rust.unreachable-pub = "warn" -rust.unsafe-op-in-unsafe-fn = "warn" rust.unused-crate-dependencies = "warn" diff --git a/crates/wire-derive/CHANGELOG.md b/crates/wire-derive/CHANGELOG.md index ecfa6995d..14c662add 100644 --- a/crates/wire-derive/CHANGELOG.md +++ b/crates/wire-derive/CHANGELOG.md @@ -19,4 +19,4 @@ ## 0.1.0 - + diff --git a/crates/wire-derive/Cargo.toml b/crates/wire-derive/Cargo.toml index 3f98ebd6d..73ed475f3 100644 --- a/crates/wire-derive/Cargo.toml +++ b/crates/wire-derive/Cargo.toml @@ -41,8 +41,8 @@ _dev = [] schema = [] [lints] +clippy.literal-string-with-formatting-args = "allow" clippy.mod-module-files = "warn" clippy.unit-arg = "allow" rust.unreachable-pub = "warn" -rust.unsafe-op-in-unsafe-fn = "warn" rust.unused-crate-dependencies = "warn" diff --git a/crates/wire/CHANGELOG.md b/crates/wire/CHANGELOG.md index b58ded355..a09a65431 100644 --- a/crates/wire/CHANGELOG.md +++ b/crates/wire/CHANGELOG.md @@ -23,4 +23,4 @@ ## 0.1.0 - + diff --git a/crates/wire/Cargo.toml b/crates/wire/Cargo.toml index 8665f192f..fc9957f33 100644 --- a/crates/wire/Cargo.toml +++ b/crates/wire/Cargo.toml @@ -23,8 +23,8 @@ schema = ["std", "wasefire-wire-derive/schema"] std = [] [lints] +clippy.literal-string-with-formatting-args = "allow" clippy.mod-module-files = "warn" clippy.unit-arg = "allow" rust.unreachable-pub = "warn" -rust.unsafe-op-in-unsafe-fn = "warn" rust.unused-crate-dependencies = "warn" diff --git a/crates/wire/fuzz/Cargo.toml b/crates/wire/fuzz/Cargo.toml index 9ee3e4b28..a6740879c 100644 --- a/crates/wire/fuzz/Cargo.toml +++ b/crates/wire/fuzz/Cargo.toml @@ -19,6 +19,6 @@ name = "correct" path = "fuzz_targets/correct.rs" [lints] +clippy.literal-string-with-formatting-args = "allow" clippy.mod-module-files = "warn" clippy.unit-arg = "allow" -rust.unsafe-op-in-unsafe-fn = "warn" diff --git a/crates/xtask/Cargo.lock b/crates/xtask/Cargo.lock index 8dc787270..4e7f908cd 100644 --- a/crates/xtask/Cargo.lock +++ b/crates/xtask/Cargo.lock @@ -8,7 +8,7 @@ version = "0.22.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "6e4503c46a5c0c7844e948c9a4d6acd9f50cccb4de1c48eb9e291ea17470c678" dependencies = [ - "gimli", + "gimli 0.29.0", ] [[package]] @@ -140,7 +140,7 @@ dependencies = [ "cfg-if", "libc", "miniz_oxide 0.7.3", - "object 0.36.4", + "object", "rustc-demangle", ] @@ -161,9 +161,15 @@ dependencies = [ [[package]] name = "bitfield" -version = "0.15.0" +version = "0.17.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f798d2d157e547aa99aab0967df39edd0b70307312b6f8bd2848e6abe40896e0" + +[[package]] +name = "bitflags" +version = "1.3.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c821a6e124197eb56d907ccc2188eab1038fb919c914f47976e64dd8dbc855d1" +checksum = "bef38d45163c2f1dde094a7dfd33ccf595c92905c8f8f4fdc18d06fb1037718a" [[package]] name = "bitflags" @@ -274,6 +280,16 @@ version = "1.0.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "baf1de4339761588bc0619e3cbc0120ee582ebb74b53b4efbf79117bd2da40fd" +[[package]] +name = "chrono" +version = "0.4.39" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7e36cc9d416881d2e24f9a963be5fb1cd90966419ac844274161d10488b3e825" +dependencies = [ + "num-traits", + "serde", +] + [[package]] name = "clap" version = "4.5.4" @@ -351,11 +367,21 @@ dependencies = [ "libc", ] +[[package]] +name = "core-foundation" +version = "0.10.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b55271e5c8c478ad3f38ad24ef34923091e0548492a266d19b3c0b4d82574c63" +dependencies = [ + "core-foundation-sys", + "libc", +] + [[package]] name = "core-foundation-sys" -version = "0.8.6" +version = "0.8.7" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "06ea2b9bc92be3c2baa9334a323ebca2d6f074ff852cd1d7b11064035cd3868f" +checksum = "773648b94d0e5d620f64f280777445740e61fe701025087ec8b57f45c791888b" [[package]] name = "cpufeatures" @@ -476,6 +502,15 @@ dependencies = [ "syn 1.0.109", ] +[[package]] +name = "deranged" +version = "0.3.11" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b42b6fa04a440b495c8b04d0e71b707c585f83cb9cb28cf8cd0d976c315e31b4" +dependencies = [ + "powerfmt", +] + [[package]] name = "derive-where" version = "1.2.7" @@ -731,10 +766,7 @@ version = "2.3.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "52527eb5074e35e9339c6b4e8d12600c7128b68fb25dcb9fa9dec18f7c25f3a5" dependencies = [ - "fastrand", "futures-core", - "futures-io", - "parking", "pin-project-lite", ] @@ -788,6 +820,12 @@ name = "gimli" version = "0.29.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "40ecd4077b5ae9fd2e9e169b102c6c330d0605168eb0e8bf79952b256dbefffd" + +[[package]] +name = "gimli" +version = "0.31.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "07e28edb80900c19c28f1072f2e8aeca7fa06b23cd4169cefe1af5aa3260783f" dependencies = [ "fallible-iterator", "stable_deref_trait", @@ -856,6 +894,12 @@ version = "0.3.9" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "d231dfb89cfffdbc30e7fc41579ed6066ad03abda9e567ccafae602b97ec5024" +[[package]] +name = "hex" +version = "0.4.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7f24254aa9a54b5c858eaee2f5bccdb46aaf0e486a595ed5fd8f86ba55232a70" + [[package]] name = "hidapi" version = "2.6.1" @@ -865,7 +909,7 @@ dependencies = [ "cc", "cfg-if", "libc", - "nix", + "nix 0.27.1", "pkg-config", "udev", "windows-sys 0.48.0", @@ -1019,6 +1063,7 @@ checksum = "168fb715dda47215e360912c096649d23d58bf392ac62f73919e831745e40f26" dependencies = [ "equivalent", "hashbrown", + "serde", ] [[package]] @@ -1077,9 +1122,9 @@ checksum = "f8478577c03552c21db0e2724ffb8986a5ce7af88107e6be5d2ee6e158c12800" [[package]] name = "itertools" -version = "0.12.1" +version = "0.13.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ba291022dbbd398a455acf126c1e341954079855bc60dfdda641363bd6922569" +checksum = "413ee7dfc52ee1a4949ceeb7dbc8a33f2d6c088194d9f922fb8318faf1f01186" dependencies = [ "either", ] @@ -1132,7 +1177,7 @@ version = "0.1.3" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "c0ff37bd590ca25063e35af745c343cb7a0271906fb7b37e4813e8f79f00268d" dependencies = [ - "bitflags", + "bitflags 2.5.0", "libc", "redox_syscall", ] @@ -1288,17 +1333,34 @@ dependencies = [ "tempfile", ] +[[package]] +name = "nix" +version = "0.26.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "598beaf3cc6fdd9a5dfb1630c2800c7acd31df7aaf0f565796fba2b53ca1af1b" +dependencies = [ + "bitflags 1.3.2", + "cfg-if", + "libc", +] + [[package]] name = "nix" version = "0.27.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "2eb04e9c688eff1c89d72b407f168cf79bb9e867a9d3323ed6c01519eb9cc053" dependencies = [ - "bitflags", + "bitflags 2.5.0", "cfg-if", "libc", ] +[[package]] +name = "num-conv" +version = "0.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "51d515d32fb182ee37cda2ccdcb92950d6a3c2893aa280e540671c2cd0f3b1d9" + [[package]] name = "num-traits" version = "0.2.19" @@ -1336,14 +1398,16 @@ checksum = "830b246a0e5f20af87141b25c173cd1b609bd7779a4617d6ec582abaf90870f3" [[package]] name = "nusb" -version = "0.1.9" +version = "0.1.12" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "66354494bb95f979c053fd988dfeb7c9f1cc8c91544139bce2b3d1765be9571a" +checksum = "e4e1996397b9a2af6390bb9ef0386c429de1a81da246fa7ae31dc922be4b670b" dependencies = [ "atomic-waker", - "core-foundation", + "core-foundation 0.9.4", "core-foundation-sys", + "futures-core", "io-kit-sys", + "libc", "log", "once_cell", "rustix", @@ -1351,15 +1415,6 @@ dependencies = [ "windows-sys 0.48.0", ] -[[package]] -name = "object" -version = "0.35.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b8ec7ab813848ba4522158d5517a6093db1ded27575b070f4177b8d12b41db5e" -dependencies = [ - "memchr", -] - [[package]] name = "object" version = "0.36.4" @@ -1381,7 +1436,7 @@ version = "0.10.68" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "6174bc48f102d208783c2c84bf931bb75927a617866870de8a4ea85597f871f5" dependencies = [ - "bitflags", + "bitflags 2.5.0", "cfg-if", "foreign-types", "libc", @@ -1508,58 +1563,62 @@ version = "1.8.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "d30538d42559de6b034bc76fd6dd4c38961b1ee5c6c56e3808c50128fdbc22ce" +[[package]] +name = "powerfmt" +version = "0.2.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "439ee305def115ba05938db6eb1644ff94165c5ab5e9420d1c1bcedbba909391" + [[package]] name = "probe-rs" -version = "0.24.0" +version = "0.25.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "779bcdfcfdbf3dc88ed7622671b4368ddd2019dabe948fbea34df3eb6dc07109" +checksum = "d8f883e25404f0606f5d70b200bd767222c236c83bb883dab763fdcea972c956" dependencies = [ "anyhow", "async-io", "bincode", "bitfield", - "bitflags", "bitvec", "docsplay", "dunce", "espflash", + "flate2", "futures-lite", - "gimli", + "gimli 0.31.1", "hidapi", "ihex", "itertools", "jep106", - "miniz_oxide 0.7.3", "nusb", - "object 0.35.0", - "once_cell", + "object", "parking_lot", "parse_int", - "paste", "probe-rs-target", "rmp-serde", "scroll", "serde", "serde_yaml", - "static_assertions", + "serialport", "svg", "thiserror 1.0.61", "tracing", "typed-path", "uf2-decode", "zerocopy", - "zerocopy-derive", ] [[package]] name = "probe-rs-target" -version = "0.24.0" +version = "0.25.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0665a9ccb3943aa476c583d6bb273da71cb99598113198d641c648c39629f694" +checksum = "eb4ed7e835072b8c7c2dd084e5c6cb78adc4a80544d6dda35a91db22355bc26b" dependencies = [ "base64", + "indexmap", "jep106", "serde", + "serde_with", "url", ] @@ -1603,7 +1662,7 @@ version = "0.5.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "469052894dcb553421e483e4209ee581a45100d31b4018de03e5a7ad86374a7e" dependencies = [ - "bitflags", + "bitflags 2.5.0", ] [[package]] @@ -1735,7 +1794,7 @@ version = "0.38.34" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "70dc5ec042f7a43c4a73241207cecc9873a06d45debb38b329f8541d85c2730f" dependencies = [ - "bitflags", + "bitflags 2.5.0", "errno", "libc", "linux-raw-sys", @@ -1820,8 +1879,8 @@ version = "2.11.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "c627723fd09706bacdb5cf41499e95098555af3c3c29d014dc3c458ef6be11c0" dependencies = [ - "bitflags", - "core-foundation", + "bitflags 2.5.0", + "core-foundation 0.9.4", "core-foundation-sys", "libc", "security-framework-sys", @@ -1907,6 +1966,22 @@ dependencies = [ "serde", ] +[[package]] +name = "serde_with" +version = "3.12.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d6b6f7f2fcb69f747921f79f3926bd1e203fce4fef62c268dd3abfb6d86029aa" +dependencies = [ + "base64", + "chrono", + "hex", + "indexmap", + "serde", + "serde_derive", + "serde_json", + "time", +] + [[package]] name = "serde_yaml" version = "0.9.34+deprecated" @@ -1920,6 +1995,24 @@ dependencies = [ "unsafe-libyaml", ] +[[package]] +name = "serialport" +version = "4.6.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "779e2977f0cc2ff39708fef48f96f3768ac8ddd8c6caaaab82e83bd240ef99b2" +dependencies = [ + "bitflags 2.5.0", + "cfg-if", + "core-foundation 0.10.0", + "core-foundation-sys", + "io-kit-sys", + "mach2", + "nix 0.26.4", + "scopeguard", + "unescaper", + "winapi", +] + [[package]] name = "sha2" version = "0.10.8" @@ -1989,12 +2082,6 @@ dependencies = [ "xmas-elf 0.6.2", ] -[[package]] -name = "static_assertions" -version = "1.1.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a2eb9349b6444b326872e140eb1cf5e7c522154d69e7a0ffb0fb81c06b37543f" - [[package]] name = "strsim" version = "0.10.0" @@ -2037,9 +2124,9 @@ checksum = "13c2bddecc57b384dee18652358fb23172facb8a2c51ccc10d74c157bdea3292" [[package]] name = "svg" -version = "0.17.0" +version = "0.18.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "700efb40f3f559c23c18b446e8ed62b08b56b2bb3197b36d57e0470b4102779e" +checksum = "94afda9cd163c04f6bee8b4bf2501c91548deae308373c436f36aeff3cf3c4a3" [[package]] name = "syn" @@ -2141,6 +2228,25 @@ dependencies = [ "syn 2.0.90", ] +[[package]] +name = "time" +version = "0.3.37" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "35e7868883861bd0e56d9ac6efcaaca0d6d5d82a2a7ec8209ff492c07cf37b21" +dependencies = [ + "deranged", + "num-conv", + "powerfmt", + "serde", + "time-core", +] + +[[package]] +name = "time-core" +version = "0.1.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ef927ca75afb808a4d64dd374f00a2adf8d0fcff8e7b184af886c3c87ec4a3f3" + [[package]] name = "tinyvec" version = "1.6.0" @@ -2276,7 +2382,6 @@ version = "0.1.40" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "c3523ab5a71916ccf420eebdf5521fcef02141234bbc0b8a49f2fdc4544364ef" dependencies = [ - "log", "pin-project-lite", "tracing-attributes", "tracing-core", @@ -2310,9 +2415,9 @@ checksum = "e421abadd41a4225275504ea4d6566923418b7f05506fbc9c0fe86ba7396114b" [[package]] name = "typed-path" -version = "0.8.0" +version = "0.10.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6069e2cc1d241fd4ff5fa067e8882996fcfce20986d078696e05abccbcf27b43" +checksum = "41713888c5ccfd99979fcd1afd47b71652e331b3d4a0e19d30769e80fec76cce" [[package]] name = "typenum" @@ -2338,6 +2443,15 @@ version = "0.2.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "ca77d41ab27e3fa45df42043f96c79b80c6d8632eed906b54681d8d47ab00623" +[[package]] +name = "unescaper" +version = "0.1.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c878a167baa8afd137494101a688ef8c67125089ff2249284bd2b5f9bfedb815" +dependencies = [ + "thiserror 1.0.61", +] + [[package]] name = "unicode-bidi" version = "0.3.15" @@ -2610,6 +2724,28 @@ dependencies = [ "wasm-bindgen", ] +[[package]] +name = "winapi" +version = "0.3.9" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5c839a674fcd7a98952e593242ea400abe93992746761e38641405d28b00f419" +dependencies = [ + "winapi-i686-pc-windows-gnu", + "winapi-x86_64-pc-windows-gnu", +] + +[[package]] +name = "winapi-i686-pc-windows-gnu" +version = "0.4.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ac3b87c63620426dd9b991e5ce0329eff545bccbbb34f3be09ff6fb6ab51b7b6" + +[[package]] +name = "winapi-x86_64-pc-windows-gnu" +version = "0.4.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "712e227841d057c1ee1cd2fb22fa7e5a5461ae8e48fa2ca79ec42cfc1931183f" + [[package]] name = "windows-registry" version = "0.2.0" @@ -2858,19 +2994,18 @@ checksum = "2fe21bcc34ca7fe6dd56cc2cb1261ea59d6b93620215aefb5ea6032265527784" [[package]] name = "zerocopy" -version = "0.7.34" +version = "0.8.14" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ae87e3fcd617500e5d106f0380cf7b77f3c6092aae37191433159dda23cfb087" +checksum = "a367f292d93d4eab890745e75a778da40909cab4d6ff8173693812f79c4a2468" dependencies = [ - "byteorder", "zerocopy-derive", ] [[package]] name = "zerocopy-derive" -version = "0.7.34" +version = "0.8.14" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "15e934569e47891f7d9411f1a451d947a60e000ab3bd24fbb970f000387d1b3b" +checksum = "d3931cb58c62c13adec22e38686b559c86a30565e16ad6e8510a337cedc611e1" dependencies = [ "proc-macro2", "quote", diff --git a/crates/xtask/Cargo.toml b/crates/xtask/Cargo.toml index c903d0ed2..6349b70fa 100644 --- a/crates/xtask/Cargo.toml +++ b/crates/xtask/Cargo.toml @@ -11,7 +11,7 @@ anyhow = "1.0.86" clap = { version = "4.5.4", features = ["derive"] } env_logger = "0.11.3" log = "0.4.21" -probe-rs = "0.24.0" +probe-rs = "0.25.0" rustc-demangle = "0.1.24" serde = { version = "1.0.202", features = ["derive"] } stack-sizes = "0.5.0" @@ -20,7 +20,7 @@ wasefire-cli-tools = { path = "../cli-tools", features = ["action", "changelog"] wasefire-error = { version = "0.1.3-git", path = "../error", features = ["std"] } [lints] +clippy.literal-string-with-formatting-args = "allow" clippy.mod-module-files = "warn" clippy.unit-arg = "allow" -rust.unsafe-op-in-unsafe-fn = "warn" rust.unused-crate-dependencies = "warn" diff --git a/crates/xtask/src/main.rs b/crates/xtask/src/main.rs index b8045cc97..73a114d9d 100644 --- a/crates/xtask/src/main.rs +++ b/crates/xtask/src/main.rs @@ -638,7 +638,10 @@ impl RunnerOptions { let session = session.clone(); move || { let mut session = session.lock().unwrap(); - anyhow::Ok(flashing::erase_all(session.get()?, None)?) + anyhow::Ok(flashing::erase_all( + session.get()?, + flashing::FlashProgress::empty(), + )?) } }) .await??; diff --git a/examples/assemblyscript/api.ts b/examples/assemblyscript/api.ts index ab319ebd2..4eac4ea80 100644 --- a/examples/assemblyscript/api.ts +++ b/examples/assemblyscript/api.ts @@ -12,6 +12,85 @@ // See the License for the specific language governing permissions and // limitations under the License. +// # Applet functions +// +// An applet must expose 3 functions to the platform: +// +// - `init: () -> ()` called exactly once before anything else. It cannot call any +// platform function except `dp` (aka `debug::println()`). +// - `main: () -> ()` called exactly once after `init` returns. It can call all +// platform functions. +// - `alloc: (size: u32, align: u32) -> (ptr: u32)` may be called during any +// platform function after `init` returned. It cannot call any platform function. +// A return value of zero indicates an error and will trap the applet. The applet +// may assume that `size` is a non-zero multiple of `align` and `align` is either +// 1, 2, or 4. +// +// # Platform functions +// +// The platform exposes many functions. Each function comes with its own +// documentation, which may omit the following general properties. +// +// ## Parameters and result +// +// At WebAssembly level, all functions use `u32` (more precisely `i32`) as +// parameters and result (WebAssembly permits multiple results, but platform +// functions never return more than one value). However, platform functions will be +// documented with more specific types to better convey the intent. +// +// Languages that compile to WebAssembly may use similar specific types when +// binding platform functions. Those types should be compatible with `u32` in +// WebAssembly. +// +// ## Applet closures +// +// Some functions (usually called `register`) may register a closure. There is +// usually an associated function (usually called `unregister`) that unregisters +// the registered closure. The register function takes `fn { data: *const void, ... +// }` (usually called `handler_func`) and a `*const void` (usually called +// `handler_data`) as arguments. The unregister function (if it exists) doesn't +// have any particular parameters. +// +// After the closure is registered (the register function is called) and as long as +// it stays registered (the unregister function is not called), the platform may +// call this closure any time `sw` (aka `scheduling::wait_for_callback()`) is +// called. Note that if `main` returns and there are registered closures, the +// applet behaves as if `sw` is called indefinitely. +// +// An applet closure may call any platform function unless explicitly documented by +// the register function. +// +// ## Reading and writing memory +// +// Some functions take pointers as argument (usually `*const u8` or `*mut u8`). +// They either document the expected size or take an associated length argument. +// +// The platform may read and write (only for `*mut T` pointers) the designated +// region of the WebAssembly memory during the function call. Otherwise (and by +// default), platform functions don't read or write the WebAssembly memory. +// +// ## Allocating memory +// +// Finally, some functions take nested pointers as argument (usually `*mut *mut +// u8`). They either return a `usize` or take a `*mut usize` as argument. +// +// Those functions may call `alloc` (at most once per such nested pointer argument) +// with a dynamic size but fixed alignment (usually 1). If they do, they will store +// the non-null result in the `*mut *mut u8` argument. Regardless of whether they +// allocate or not, they store the size in the `*mut usize` argument (if it exists) +// or return it (otherwise). +// +// Note that `alloc` will not be called with a size of zero. So if the size is zero +// after the function returns, this signifies that `alloc` was not called (and the +// `*mut *mut u8` not written) and the output is empty (unless otherwise documented +// like in the case of an absence of output, in which case the size may not be +// written). +// +// The caller is responsible for managing the allocation after the function returns +// and the size is non-zero. To avoid memory leaks, the applet should initialize +// the `*mut usize` argument (if it exists) to zero and consider having ownership +// of the `*mut *mut u8` pointee if the size is non-zero after the call. + // START OF MODULE button // Button and touch operations. // Describes the state of a button. @@ -671,13 +750,12 @@ // Platform protocol. // Reads the last request, if any. // - // Returns whether a request was allocated. + // Returns whether a request was read. + // + // This is an [allocating function](crate#allocating-memory). @external("env", "ppr") export declare function platform_protocol_read( // Where to write the request, if any. - // - // The (inner) pointer will be allocated by the callee and must be freed by the - // caller. It is thus owned by the caller when the function returns. ptr: usize, // Where to write the length of the request, if any. @@ -719,9 +797,12 @@ export declare function platform_update_is_supported( ): i32 - // Returns the metadata of the platform. + // Reads the metadata of the platform. + // + // The metadata typically contains the version and side (A or B) of the running + // platform. // - // This typically contains the version and side (A or B) of the running platform. + // This is an [allocating function](crate#allocating-memory). @external("env", "pum") export declare function platform_update_metadata( // Where to write the allocated metadata. @@ -760,31 +841,21 @@ ): i32 // END OF MODULE platform_update - // Returns the serial of the platform. + // Reads the serial of the platform. // - // Returns the length of the serial in bytes. The serial is not allocated if the - // length is zero (and the pointer is not written). + // This is an [allocating function](crate#allocating-memory) returning the length. @external("env", "ps") export declare function platform_serial( // Where to write the serial. - // - // If the returned length is positive, the (inner) pointer will be allocated by the - // callee and must be freed by the caller. It is thus owned by the caller when the - // function returns. ptr: usize, ): i32 - // Returns the version of the platform. + // Reads the version of the platform. // - // Returns the length of the version in bytes. The version is not allocated if the - // length is zero (and the pointer is not written). + // This is an [allocating function](crate#allocating-memory) returning the length. @external("env", "pv") export declare function platform_version( // Where to write the version. - // - // If the returned length is positive, the (inner) pointer will be allocated by the - // callee and must be freed by the caller. It is thus owned by the caller when the - // function returns. ptr: usize, ): i32 @@ -926,15 +997,14 @@ // Finds an entry in the store, if any. // // Returns whether an entry was found. + // + // This is an [allocating function](crate#allocating-memory). @external("env", "sf") export declare function store_find( // Key of the entry to find. key: usize, // Where to write the value of the entry, if found. - // - // The (inner) pointer will be allocated by the callee and must be freed by the - // caller. It is thus owned by the caller when the function returns. ptr: usize, // Where to write the length of the value, if found. @@ -943,14 +1013,11 @@ // Returns the unordered keys of the entries in the store. // - // Returns the number of keys, and thus the length of the array. The array is not - // allocated if the length is zero (and the pointer is not written). + // This is an [allocating function](crate#allocating-memory) returning the number of + // keys (thus half the number of allocated bytes). @external("env", "sk") export declare function store_keys( - // Where to write the keys as an array of u16, if at least one. - // - // The (inner) pointer will be allocated by the callee and must be freed by the - // caller. It is thus owned by the caller when the function returns. + // Where to write the keys as an array of u16. ptr: usize, ): i32 @@ -997,15 +1064,14 @@ // The entry may be fragmented withen the provided range. // // Returns whether an entry was found. + // + // This is an [allocating function](crate#allocating-memory). @external("env", "sff") export declare function store_fragment_find( // Range of keys to concatenate as an entry. keys: u32, // Where to write the value of the entry, if found. - // - // The (inner) pointer will be allocated by the callee and must be freed by the - // caller. It is thus owned by the caller when the function returns. ptr: usize, // Where to write the length of the value, if found. @@ -1026,6 +1092,9 @@ } // Allocates a timer (initially stopped) and returns its identifier. + // + // This is a [register function](crate#applet-closures). The associated unregister + // function is [`free()`]. @external("env", "ta") export declare function timer_allocate( // Function called when the timer triggers. @@ -1058,14 +1127,14 @@ // called. @external("env", "tc") export declare function timer_stop( - // The identifier of the timer to start. + // The identifier of the timer to stop. id: usize, ): i32 // Deallocates a stopped timer given its identifier. @external("env", "td") export declare function timer_free( - // The identifier of the timer to start. + // The identifier of the timer to free. id: usize, ): i32 // END OF MODULE timer diff --git a/examples/rust/blink/Cargo.lock b/examples/rust/blink/Cargo.lock index 5a506c237..0679a7229 100644 --- a/examples/rust/blink/Cargo.lock +++ b/examples/rust/blink/Cargo.lock @@ -181,7 +181,7 @@ checksum = "49874b5167b65d7193b8aba1567f5c7d93d001cafc34600cee003eda787e483f" [[package]] name = "wasefire" -version = "0.7.1-git" +version = "0.8.0-git" dependencies = [ "bytemuck", "crypto-common", diff --git a/examples/rust/blink_periodic/Cargo.lock b/examples/rust/blink_periodic/Cargo.lock index 4117d273d..b7995f3bb 100644 --- a/examples/rust/blink_periodic/Cargo.lock +++ b/examples/rust/blink_periodic/Cargo.lock @@ -181,7 +181,7 @@ checksum = "49874b5167b65d7193b8aba1567f5c7d93d001cafc34600cee003eda787e483f" [[package]] name = "wasefire" -version = "0.7.1-git" +version = "0.8.0-git" dependencies = [ "bytemuck", "crypto-common", diff --git a/examples/rust/button/Cargo.lock b/examples/rust/button/Cargo.lock index adba4b630..948b1ef44 100644 --- a/examples/rust/button/Cargo.lock +++ b/examples/rust/button/Cargo.lock @@ -181,7 +181,7 @@ checksum = "49874b5167b65d7193b8aba1567f5c7d93d001cafc34600cee003eda787e483f" [[package]] name = "wasefire" -version = "0.7.1-git" +version = "0.8.0-git" dependencies = [ "bytemuck", "crypto-common", diff --git a/examples/rust/button_abort/Cargo.lock b/examples/rust/button_abort/Cargo.lock index da8eab316..e4c08a329 100644 --- a/examples/rust/button_abort/Cargo.lock +++ b/examples/rust/button_abort/Cargo.lock @@ -181,7 +181,7 @@ checksum = "49874b5167b65d7193b8aba1567f5c7d93d001cafc34600cee003eda787e483f" [[package]] name = "wasefire" -version = "0.7.1-git" +version = "0.8.0-git" dependencies = [ "bytemuck", "crypto-common", diff --git a/examples/rust/ccm/Cargo.lock b/examples/rust/ccm/Cargo.lock index c1b04af8d..60aeb89dc 100644 --- a/examples/rust/ccm/Cargo.lock +++ b/examples/rust/ccm/Cargo.lock @@ -181,7 +181,7 @@ checksum = "49874b5167b65d7193b8aba1567f5c7d93d001cafc34600cee003eda787e483f" [[package]] name = "wasefire" -version = "0.7.1-git" +version = "0.8.0-git" dependencies = [ "bytemuck", "crypto-common", diff --git a/examples/rust/ctap/Cargo.lock b/examples/rust/ctap/Cargo.lock index 43a43b8e4..a943c54dc 100644 --- a/examples/rust/ctap/Cargo.lock +++ b/examples/rust/ctap/Cargo.lock @@ -181,7 +181,7 @@ checksum = "49874b5167b65d7193b8aba1567f5c7d93d001cafc34600cee003eda787e483f" [[package]] name = "wasefire" -version = "0.7.1-git" +version = "0.8.0-git" dependencies = [ "bytemuck", "crypto-common", diff --git a/examples/rust/ec_test/Cargo.lock b/examples/rust/ec_test/Cargo.lock index 86ce908f4..3d59dcf28 100644 --- a/examples/rust/ec_test/Cargo.lock +++ b/examples/rust/ec_test/Cargo.lock @@ -459,7 +459,7 @@ checksum = "49874b5167b65d7193b8aba1567f5c7d93d001cafc34600cee003eda787e483f" [[package]] name = "wasefire" -version = "0.7.1-git" +version = "0.8.0-git" dependencies = [ "bytemuck", "crypto-common", diff --git a/examples/rust/ec_test/src/lib.rs b/examples/rust/ec_test/src/lib.rs index 893f12334..6814d31bf 100644 --- a/examples/rust/ec_test/src/lib.rs +++ b/examples/rust/ec_test/src/lib.rs @@ -17,7 +17,6 @@ #![no_std] wasefire::applet!(); -use alloc::vec; use alloc::vec::Vec; use wasefire::crypto::ec::{ @@ -103,8 +102,7 @@ fn test_ecdsa_random(name: &str) { let mut rs = Vec::new(); for _ in 0 .. 5 { let d = EcdsaPrivate::::random().unwrap(); - let mut m = vec![0; 257]; - rng::fill_bytes(&mut m).unwrap(); + let mut m = rng::bytes(257).unwrap().into_vec(); m.truncate(m[256] as usize); let s = d.sign(&m).unwrap(); debug!("- {:02x?}{:02x?} ({} bytes message)", &s.r()[.. 4], &s.s()[.. 4], m.len()); diff --git a/examples/rust/echo/Cargo.lock b/examples/rust/echo/Cargo.lock index e167d26ab..6ae1393f2 100644 --- a/examples/rust/echo/Cargo.lock +++ b/examples/rust/echo/Cargo.lock @@ -181,7 +181,7 @@ checksum = "49874b5167b65d7193b8aba1567f5c7d93d001cafc34600cee003eda787e483f" [[package]] name = "wasefire" -version = "0.7.1-git" +version = "0.8.0-git" dependencies = [ "bytemuck", "crypto-common", diff --git a/examples/rust/exercises/client/Cargo.lock b/examples/rust/exercises/client/Cargo.lock index 2cf3c490b..0bcffdb8b 100644 --- a/examples/rust/exercises/client/Cargo.lock +++ b/examples/rust/exercises/client/Cargo.lock @@ -824,7 +824,7 @@ checksum = "49874b5167b65d7193b8aba1567f5c7d93d001cafc34600cee003eda787e483f" [[package]] name = "wasefire" -version = "0.7.1-git" +version = "0.8.0-git" dependencies = [ "bytemuck", "crypto-common", diff --git a/examples/rust/exercises/interface/Cargo.lock b/examples/rust/exercises/interface/Cargo.lock index 064d31d82..162898921 100644 --- a/examples/rust/exercises/interface/Cargo.lock +++ b/examples/rust/exercises/interface/Cargo.lock @@ -226,7 +226,7 @@ checksum = "49874b5167b65d7193b8aba1567f5c7d93d001cafc34600cee003eda787e483f" [[package]] name = "wasefire" -version = "0.7.1-git" +version = "0.8.0-git" dependencies = [ "bytemuck", "crypto-common", diff --git a/examples/rust/exercises/part-1-sol/Cargo.lock b/examples/rust/exercises/part-1-sol/Cargo.lock index a4f29b6e0..67193cd73 100644 --- a/examples/rust/exercises/part-1-sol/Cargo.lock +++ b/examples/rust/exercises/part-1-sol/Cargo.lock @@ -181,7 +181,7 @@ checksum = "49874b5167b65d7193b8aba1567f5c7d93d001cafc34600cee003eda787e483f" [[package]] name = "wasefire" -version = "0.7.1-git" +version = "0.8.0-git" dependencies = [ "bytemuck", "crypto-common", diff --git a/examples/rust/exercises/part-1/Cargo.lock b/examples/rust/exercises/part-1/Cargo.lock index e13881450..2bc42c479 100644 --- a/examples/rust/exercises/part-1/Cargo.lock +++ b/examples/rust/exercises/part-1/Cargo.lock @@ -181,7 +181,7 @@ checksum = "49874b5167b65d7193b8aba1567f5c7d93d001cafc34600cee003eda787e483f" [[package]] name = "wasefire" -version = "0.7.1-git" +version = "0.8.0-git" dependencies = [ "bytemuck", "crypto-common", diff --git a/examples/rust/exercises/part-2-sol/Cargo.lock b/examples/rust/exercises/part-2-sol/Cargo.lock index 5c6a5e814..4745afb20 100644 --- a/examples/rust/exercises/part-2-sol/Cargo.lock +++ b/examples/rust/exercises/part-2-sol/Cargo.lock @@ -234,7 +234,7 @@ checksum = "49874b5167b65d7193b8aba1567f5c7d93d001cafc34600cee003eda787e483f" [[package]] name = "wasefire" -version = "0.7.1-git" +version = "0.8.0-git" dependencies = [ "bytemuck", "crypto-common", diff --git a/examples/rust/exercises/part-2/Cargo.lock b/examples/rust/exercises/part-2/Cargo.lock index 35571e0b7..bbbfcff69 100644 --- a/examples/rust/exercises/part-2/Cargo.lock +++ b/examples/rust/exercises/part-2/Cargo.lock @@ -234,7 +234,7 @@ checksum = "49874b5167b65d7193b8aba1567f5c7d93d001cafc34600cee003eda787e483f" [[package]] name = "wasefire" -version = "0.7.1-git" +version = "0.8.0-git" dependencies = [ "bytemuck", "crypto-common", diff --git a/examples/rust/exercises/part-3-sol/Cargo.lock b/examples/rust/exercises/part-3-sol/Cargo.lock index 1a1f30b2e..05e67943f 100644 --- a/examples/rust/exercises/part-3-sol/Cargo.lock +++ b/examples/rust/exercises/part-3-sol/Cargo.lock @@ -234,7 +234,7 @@ checksum = "49874b5167b65d7193b8aba1567f5c7d93d001cafc34600cee003eda787e483f" [[package]] name = "wasefire" -version = "0.7.1-git" +version = "0.8.0-git" dependencies = [ "bytemuck", "crypto-common", diff --git a/examples/rust/exercises/part-3/Cargo.lock b/examples/rust/exercises/part-3/Cargo.lock index 55aa0cf47..46b7bbbea 100644 --- a/examples/rust/exercises/part-3/Cargo.lock +++ b/examples/rust/exercises/part-3/Cargo.lock @@ -234,7 +234,7 @@ checksum = "49874b5167b65d7193b8aba1567f5c7d93d001cafc34600cee003eda787e483f" [[package]] name = "wasefire" -version = "0.7.1-git" +version = "0.8.0-git" dependencies = [ "bytemuck", "crypto-common", diff --git a/examples/rust/exercises/part-4-sol/Cargo.lock b/examples/rust/exercises/part-4-sol/Cargo.lock index ca22cc772..f938495d4 100644 --- a/examples/rust/exercises/part-4-sol/Cargo.lock +++ b/examples/rust/exercises/part-4-sol/Cargo.lock @@ -234,7 +234,7 @@ checksum = "49874b5167b65d7193b8aba1567f5c7d93d001cafc34600cee003eda787e483f" [[package]] name = "wasefire" -version = "0.7.1-git" +version = "0.8.0-git" dependencies = [ "bytemuck", "crypto-common", diff --git a/examples/rust/exercises/part-4/Cargo.lock b/examples/rust/exercises/part-4/Cargo.lock index c60ea833d..bcacdbf11 100644 --- a/examples/rust/exercises/part-4/Cargo.lock +++ b/examples/rust/exercises/part-4/Cargo.lock @@ -234,7 +234,7 @@ checksum = "49874b5167b65d7193b8aba1567f5c7d93d001cafc34600cee003eda787e483f" [[package]] name = "wasefire" -version = "0.7.1-git" +version = "0.8.0-git" dependencies = [ "bytemuck", "crypto-common", diff --git a/examples/rust/exercises/part-5-sol/Cargo.lock b/examples/rust/exercises/part-5-sol/Cargo.lock index 8537166f0..83fba7dcd 100644 --- a/examples/rust/exercises/part-5-sol/Cargo.lock +++ b/examples/rust/exercises/part-5-sol/Cargo.lock @@ -234,7 +234,7 @@ checksum = "49874b5167b65d7193b8aba1567f5c7d93d001cafc34600cee003eda787e483f" [[package]] name = "wasefire" -version = "0.7.1-git" +version = "0.8.0-git" dependencies = [ "bytemuck", "crypto-common", diff --git a/examples/rust/exercises/part-5/Cargo.lock b/examples/rust/exercises/part-5/Cargo.lock index d0c052009..6c5c6f3c4 100644 --- a/examples/rust/exercises/part-5/Cargo.lock +++ b/examples/rust/exercises/part-5/Cargo.lock @@ -234,7 +234,7 @@ checksum = "49874b5167b65d7193b8aba1567f5c7d93d001cafc34600cee003eda787e483f" [[package]] name = "wasefire" -version = "0.7.1-git" +version = "0.8.0-git" dependencies = [ "bytemuck", "crypto-common", diff --git a/examples/rust/exercises/part-6-sol/Cargo.lock b/examples/rust/exercises/part-6-sol/Cargo.lock index 39c15aa2a..cb0f53402 100644 --- a/examples/rust/exercises/part-6-sol/Cargo.lock +++ b/examples/rust/exercises/part-6-sol/Cargo.lock @@ -234,7 +234,7 @@ checksum = "49874b5167b65d7193b8aba1567f5c7d93d001cafc34600cee003eda787e483f" [[package]] name = "wasefire" -version = "0.7.1-git" +version = "0.8.0-git" dependencies = [ "bytemuck", "crypto-common", diff --git a/examples/rust/exercises/part-6/Cargo.lock b/examples/rust/exercises/part-6/Cargo.lock index 36ffaab46..0baaf82a1 100644 --- a/examples/rust/exercises/part-6/Cargo.lock +++ b/examples/rust/exercises/part-6/Cargo.lock @@ -234,7 +234,7 @@ checksum = "49874b5167b65d7193b8aba1567f5c7d93d001cafc34600cee003eda787e483f" [[package]] name = "wasefire" -version = "0.7.1-git" +version = "0.8.0-git" dependencies = [ "bytemuck", "crypto-common", diff --git a/examples/rust/exercises/part-7-sol/Cargo.lock b/examples/rust/exercises/part-7-sol/Cargo.lock index 42a47f0c4..c1ca8bb85 100644 --- a/examples/rust/exercises/part-7-sol/Cargo.lock +++ b/examples/rust/exercises/part-7-sol/Cargo.lock @@ -234,7 +234,7 @@ checksum = "49874b5167b65d7193b8aba1567f5c7d93d001cafc34600cee003eda787e483f" [[package]] name = "wasefire" -version = "0.7.1-git" +version = "0.8.0-git" dependencies = [ "bytemuck", "crypto-common", diff --git a/examples/rust/exercises/part-7/Cargo.lock b/examples/rust/exercises/part-7/Cargo.lock index fa32d3c72..335fb4643 100644 --- a/examples/rust/exercises/part-7/Cargo.lock +++ b/examples/rust/exercises/part-7/Cargo.lock @@ -234,7 +234,7 @@ checksum = "49874b5167b65d7193b8aba1567f5c7d93d001cafc34600cee003eda787e483f" [[package]] name = "wasefire" -version = "0.7.1-git" +version = "0.8.0-git" dependencies = [ "bytemuck", "crypto-common", diff --git a/examples/rust/exercises/test.sh b/examples/rust/exercises/test.sh index 99f78958c..015b1961d 100755 --- a/examples/rust/exercises/test.sh +++ b/examples/rust/exercises/test.sh @@ -20,7 +20,7 @@ set -ex for part in part-*; do ( cd $part # This is only to update the Cargo.lock file. - cargo check --target=wasm32-unknown-unknown 2>/dev/null + RUSTFLAGS=--allow=warnings cargo check --target=wasm32-unknown-unknown # We check the usual for solutions though. [ ${part%-sol} = $part ] && exit cargo fmt -- --check diff --git a/examples/rust/gcm_test/Cargo.lock b/examples/rust/gcm_test/Cargo.lock index 826200354..5093cd477 100644 --- a/examples/rust/gcm_test/Cargo.lock +++ b/examples/rust/gcm_test/Cargo.lock @@ -208,7 +208,7 @@ checksum = "49874b5167b65d7193b8aba1567f5c7d93d001cafc34600cee003eda787e483f" [[package]] name = "wasefire" -version = "0.7.1-git" +version = "0.8.0-git" dependencies = [ "aead", "bytemuck", diff --git a/examples/rust/gpio_test/Cargo.lock b/examples/rust/gpio_test/Cargo.lock index 7fe90352d..4409c183d 100644 --- a/examples/rust/gpio_test/Cargo.lock +++ b/examples/rust/gpio_test/Cargo.lock @@ -181,7 +181,7 @@ checksum = "49874b5167b65d7193b8aba1567f5c7d93d001cafc34600cee003eda787e483f" [[package]] name = "wasefire" -version = "0.7.1-git" +version = "0.8.0-git" dependencies = [ "bytemuck", "crypto-common", diff --git a/examples/rust/hash_test/Cargo.lock b/examples/rust/hash_test/Cargo.lock index ad752d971..7a487b364 100644 --- a/examples/rust/hash_test/Cargo.lock +++ b/examples/rust/hash_test/Cargo.lock @@ -470,7 +470,7 @@ checksum = "49874b5167b65d7193b8aba1567f5c7d93d001cafc34600cee003eda787e483f" [[package]] name = "wasefire" -version = "0.7.1-git" +version = "0.8.0-git" dependencies = [ "aead", "bytemuck", diff --git a/examples/rust/hello/Cargo.lock b/examples/rust/hello/Cargo.lock index 422dcdc21..cc8cd6c58 100644 --- a/examples/rust/hello/Cargo.lock +++ b/examples/rust/hello/Cargo.lock @@ -181,7 +181,7 @@ checksum = "49874b5167b65d7193b8aba1567f5c7d93d001cafc34600cee003eda787e483f" [[package]] name = "wasefire" -version = "0.7.1-git" +version = "0.8.0-git" dependencies = [ "bytemuck", "crypto-common", diff --git a/examples/rust/hsm/Cargo.lock b/examples/rust/hsm/Cargo.lock index bad62589a..998ab68fe 100644 --- a/examples/rust/hsm/Cargo.lock +++ b/examples/rust/hsm/Cargo.lock @@ -189,7 +189,7 @@ checksum = "49874b5167b65d7193b8aba1567f5c7d93d001cafc34600cee003eda787e483f" [[package]] name = "wasefire" -version = "0.7.1-git" +version = "0.8.0-git" dependencies = [ "bytemuck", "crypto-common", diff --git a/examples/rust/hsm/common/Cargo.lock b/examples/rust/hsm/common/Cargo.lock index 28878a264..e98776ca4 100644 --- a/examples/rust/hsm/common/Cargo.lock +++ b/examples/rust/hsm/common/Cargo.lock @@ -202,7 +202,7 @@ checksum = "49874b5167b65d7193b8aba1567f5c7d93d001cafc34600cee003eda787e483f" [[package]] name = "wasefire" -version = "0.7.1-git" +version = "0.8.0-git" dependencies = [ "bytemuck", "crypto-common", diff --git a/examples/rust/hsm/src/lib.rs b/examples/rust/hsm/src/lib.rs index df73ec358..16b2c7ab1 100644 --- a/examples/rust/hsm/src/lib.rs +++ b/examples/rust/hsm/src/lib.rs @@ -33,8 +33,7 @@ fn main() { fn process(request: Request) -> Result { match request { Request::GenerateKey { key } => { - let mut secret = [0; 16]; - rng::fill_bytes(&mut secret).map_err(|_| Error::RngError)?; + let secret = rng::bytes_array::<16>().map_err(|_| Error::RngError)?; store::insert(key, &secret).map_err(|_| Error::StoreError)?; Ok(Response::GenerateKey) } diff --git a/examples/rust/led/Cargo.lock b/examples/rust/led/Cargo.lock index 165b90b69..b777b0388 100644 --- a/examples/rust/led/Cargo.lock +++ b/examples/rust/led/Cargo.lock @@ -181,7 +181,7 @@ checksum = "49874b5167b65d7193b8aba1567f5c7d93d001cafc34600cee003eda787e483f" [[package]] name = "wasefire" -version = "0.7.1-git" +version = "0.8.0-git" dependencies = [ "bytemuck", "crypto-common", diff --git a/examples/rust/link_test/Cargo.lock b/examples/rust/link_test/Cargo.lock index bd78b43d6..ba38fc926 100644 --- a/examples/rust/link_test/Cargo.lock +++ b/examples/rust/link_test/Cargo.lock @@ -182,7 +182,7 @@ checksum = "49874b5167b65d7193b8aba1567f5c7d93d001cafc34600cee003eda787e483f" [[package]] name = "wasefire" -version = "0.7.1-git" +version = "0.8.0-git" dependencies = [ "bytemuck", "crypto-common", diff --git a/examples/rust/memory_game/Cargo.lock b/examples/rust/memory_game/Cargo.lock index 7ae615f72..d860e46f2 100644 --- a/examples/rust/memory_game/Cargo.lock +++ b/examples/rust/memory_game/Cargo.lock @@ -181,7 +181,7 @@ checksum = "49874b5167b65d7193b8aba1567f5c7d93d001cafc34600cee003eda787e483f" [[package]] name = "wasefire" -version = "0.7.1-git" +version = "0.8.0-git" dependencies = [ "bytemuck", "crypto-common", diff --git a/examples/rust/memory_game/src/lib.rs b/examples/rust/memory_game/src/lib.rs index 78762189b..31ee9d746 100644 --- a/examples/rust/memory_game/src/lib.rs +++ b/examples/rust/memory_game/src/lib.rs @@ -25,9 +25,9 @@ #![no_std] wasefire::applet!(); +use alloc::format; use alloc::rc::Rc; use alloc::string::String; -use alloc::{format, vec}; use core::cell::Cell; use core::time::Duration; @@ -43,13 +43,12 @@ fn main() { while serial::read_byte(&UsbSerial).unwrap() != 0x0d {} // Generate a question for this level. - let mut question = vec![0; level]; - rng::fill_bytes(&mut question).unwrap(); + let mut question = rng::bytes(level).unwrap(); for byte in &mut question { const BASE32: [u8; 32] = *b"ABCDEFGHIJKLMNOPQRSTUVWXYZ234567"; *byte = BASE32[(*byte & 0x1f) as usize]; } - let mut question = String::from_utf8(question).unwrap(); + let mut question = String::from_utf8(question.into()).unwrap(); // Display the question. process(3, "Memorize this", &mut question, |_, x| x == 0x0d); diff --git a/examples/rust/oom/Cargo.lock b/examples/rust/oom/Cargo.lock index 8553d9cb4..226080453 100644 --- a/examples/rust/oom/Cargo.lock +++ b/examples/rust/oom/Cargo.lock @@ -181,7 +181,7 @@ checksum = "49874b5167b65d7193b8aba1567f5c7d93d001cafc34600cee003eda787e483f" [[package]] name = "wasefire" -version = "0.7.1-git" +version = "0.8.0-git" dependencies = [ "bytemuck", "crypto-common", diff --git a/examples/rust/oom/src/lib.rs b/examples/rust/oom/src/lib.rs index ff8e069aa..2d20bd9fb 100644 --- a/examples/rust/oom/src/lib.rs +++ b/examples/rust/oom/src/lib.rs @@ -17,10 +17,7 @@ #![no_std] wasefire::applet!(); -use alloc::vec; - fn main() { - let mut data = vec![0; 100000]; - rng::fill_bytes(&mut data).unwrap(); + let data = rng::bytes(100000).unwrap(); store::insert(0, &data).unwrap(); } diff --git a/examples/rust/panic/Cargo.lock b/examples/rust/panic/Cargo.lock index 1fd5092ef..aab02dde9 100644 --- a/examples/rust/panic/Cargo.lock +++ b/examples/rust/panic/Cargo.lock @@ -181,7 +181,7 @@ checksum = "49874b5167b65d7193b8aba1567f5c7d93d001cafc34600cee003eda787e483f" [[package]] name = "wasefire" -version = "0.7.1-git" +version = "0.8.0-git" dependencies = [ "bytemuck", "crypto-common", diff --git a/examples/rust/perf/Cargo.lock b/examples/rust/perf/Cargo.lock index 1fd56c5e2..e0a725028 100644 --- a/examples/rust/perf/Cargo.lock +++ b/examples/rust/perf/Cargo.lock @@ -181,7 +181,7 @@ checksum = "49874b5167b65d7193b8aba1567f5c7d93d001cafc34600cee003eda787e483f" [[package]] name = "wasefire" -version = "0.7.1-git" +version = "0.8.0-git" dependencies = [ "bytemuck", "crypto-common", diff --git a/examples/rust/protocol/Cargo.lock b/examples/rust/protocol/Cargo.lock index e1e0cef97..9cbf6dbdd 100644 --- a/examples/rust/protocol/Cargo.lock +++ b/examples/rust/protocol/Cargo.lock @@ -181,7 +181,7 @@ checksum = "49874b5167b65d7193b8aba1567f5c7d93d001cafc34600cee003eda787e483f" [[package]] name = "wasefire" -version = "0.7.1-git" +version = "0.8.0-git" dependencies = [ "bytemuck", "crypto-common", diff --git a/examples/rust/rand/Cargo.lock b/examples/rust/rand/Cargo.lock index 73e63a636..2bff7c657 100644 --- a/examples/rust/rand/Cargo.lock +++ b/examples/rust/rand/Cargo.lock @@ -181,7 +181,7 @@ checksum = "49874b5167b65d7193b8aba1567f5c7d93d001cafc34600cee003eda787e483f" [[package]] name = "wasefire" -version = "0.7.1-git" +version = "0.8.0-git" dependencies = [ "bytemuck", "crypto-common", diff --git a/examples/rust/rand/src/lib.rs b/examples/rust/rand/src/lib.rs index 050cb1a4d..5143c103e 100644 --- a/examples/rust/rand/src/lib.rs +++ b/examples/rust/rand/src/lib.rs @@ -21,7 +21,7 @@ #![no_std] wasefire::applet!(); -use alloc::{format, vec}; +use alloc::format; use wasefire::usb::serial::UsbSerial; @@ -32,8 +32,7 @@ fn main() { b'0' => 10, _ => continue, }; - let mut buf = vec![0; len as usize]; - rng::fill_bytes(&mut buf).unwrap(); + let buf = rng::bytes(len as usize).unwrap(); serial::write_all(&UsbSerial, format!("{buf:02x?}\r\n").as_bytes()).unwrap(); } } diff --git a/examples/rust/reboot/Cargo.lock b/examples/rust/reboot/Cargo.lock index 8523065df..68a550097 100644 --- a/examples/rust/reboot/Cargo.lock +++ b/examples/rust/reboot/Cargo.lock @@ -181,7 +181,7 @@ checksum = "49874b5167b65d7193b8aba1567f5c7d93d001cafc34600cee003eda787e483f" [[package]] name = "wasefire" -version = "0.7.1-git" +version = "0.8.0-git" dependencies = [ "bytemuck", "crypto-common", diff --git a/examples/rust/rng_test/Cargo.lock b/examples/rust/rng_test/Cargo.lock index 0fd097520..4ad624cba 100644 --- a/examples/rust/rng_test/Cargo.lock +++ b/examples/rust/rng_test/Cargo.lock @@ -181,7 +181,7 @@ checksum = "49874b5167b65d7193b8aba1567f5c7d93d001cafc34600cee003eda787e483f" [[package]] name = "wasefire" -version = "0.7.1-git" +version = "0.8.0-git" dependencies = [ "bytemuck", "crypto-common", diff --git a/examples/rust/store/Cargo.lock b/examples/rust/store/Cargo.lock index 2e93d2826..9779bb3ba 100644 --- a/examples/rust/store/Cargo.lock +++ b/examples/rust/store/Cargo.lock @@ -181,7 +181,7 @@ checksum = "49874b5167b65d7193b8aba1567f5c7d93d001cafc34600cee003eda787e483f" [[package]] name = "wasefire" -version = "0.7.1-git" +version = "0.8.0-git" dependencies = [ "bytemuck", "crypto-common", diff --git a/examples/rust/store_test/Cargo.lock b/examples/rust/store_test/Cargo.lock index 7af46cd3b..191b695d9 100644 --- a/examples/rust/store_test/Cargo.lock +++ b/examples/rust/store_test/Cargo.lock @@ -181,7 +181,7 @@ checksum = "49874b5167b65d7193b8aba1567f5c7d93d001cafc34600cee003eda787e483f" [[package]] name = "wasefire" -version = "0.7.1-git" +version = "0.8.0-git" dependencies = [ "bytemuck", "crypto-common", diff --git a/examples/rust/sync_test/Cargo.lock b/examples/rust/sync_test/Cargo.lock index 4bb6d8b3e..63e4b572a 100644 --- a/examples/rust/sync_test/Cargo.lock +++ b/examples/rust/sync_test/Cargo.lock @@ -181,7 +181,7 @@ checksum = "49874b5167b65d7193b8aba1567f5c7d93d001cafc34600cee003eda787e483f" [[package]] name = "wasefire" -version = "0.7.1-git" +version = "0.8.0-git" dependencies = [ "bytemuck", "crypto-common", diff --git a/examples/rust/syscall_test/Cargo.lock b/examples/rust/syscall_test/Cargo.lock index bf270e68d..dce2a8338 100644 --- a/examples/rust/syscall_test/Cargo.lock +++ b/examples/rust/syscall_test/Cargo.lock @@ -181,7 +181,7 @@ checksum = "49874b5167b65d7193b8aba1567f5c7d93d001cafc34600cee003eda787e483f" [[package]] name = "wasefire" -version = "0.7.1-git" +version = "0.8.0-git" dependencies = [ "bytemuck", "crypto-common", diff --git a/examples/rust/syscall_test/src/lib.rs b/examples/rust/syscall_test/src/lib.rs index e5d918aca..386c21a09 100644 --- a/examples/rust/syscall_test/src/lib.rs +++ b/examples/rust/syscall_test/src/lib.rs @@ -32,6 +32,6 @@ fn test_error() { (0xffffffff, Err(Error::default())), ] { debug!("- {x:08x} -> {r:?}"); - assert_eq!(syscall(0, 0, 0, x), r); + assert_eq!(unsafe { syscall(0, 0, 0, x) }, r); } } diff --git a/examples/rust/timer/Cargo.lock b/examples/rust/timer/Cargo.lock index 7d7692c1e..c97aac26b 100644 --- a/examples/rust/timer/Cargo.lock +++ b/examples/rust/timer/Cargo.lock @@ -181,7 +181,7 @@ checksum = "49874b5167b65d7193b8aba1567f5c7d93d001cafc34600cee003eda787e483f" [[package]] name = "wasefire" -version = "0.7.1-git" +version = "0.8.0-git" dependencies = [ "bytemuck", "crypto-common", diff --git a/examples/rust/timer_test/Cargo.lock b/examples/rust/timer_test/Cargo.lock index ab13aaa18..2baad6ec8 100644 --- a/examples/rust/timer_test/Cargo.lock +++ b/examples/rust/timer_test/Cargo.lock @@ -181,7 +181,7 @@ checksum = "49874b5167b65d7193b8aba1567f5c7d93d001cafc34600cee003eda787e483f" [[package]] name = "wasefire" -version = "0.7.1-git" +version = "0.8.0-git" dependencies = [ "bytemuck", "crypto-common", diff --git a/examples/rust/uart-usb/Cargo.lock b/examples/rust/uart-usb/Cargo.lock index fa13c4de0..8f032e66b 100644 --- a/examples/rust/uart-usb/Cargo.lock +++ b/examples/rust/uart-usb/Cargo.lock @@ -181,7 +181,7 @@ checksum = "49874b5167b65d7193b8aba1567f5c7d93d001cafc34600cee003eda787e483f" [[package]] name = "wasefire" -version = "0.7.1-git" +version = "0.8.0-git" dependencies = [ "bytemuck", "crypto-common", diff --git a/examples/rust/update/Cargo.lock b/examples/rust/update/Cargo.lock index fb166815f..2c3d23623 100644 --- a/examples/rust/update/Cargo.lock +++ b/examples/rust/update/Cargo.lock @@ -181,7 +181,7 @@ checksum = "49874b5167b65d7193b8aba1567f5c7d93d001cafc34600cee003eda787e483f" [[package]] name = "wasefire" -version = "0.7.1-git" +version = "0.8.0-git" dependencies = [ "bytemuck", "crypto-common", diff --git a/examples/rust/version/Cargo.lock b/examples/rust/version/Cargo.lock index 3bb0dc597..d53280c39 100644 --- a/examples/rust/version/Cargo.lock +++ b/examples/rust/version/Cargo.lock @@ -181,7 +181,7 @@ checksum = "49874b5167b65d7193b8aba1567f5c7d93d001cafc34600cee003eda787e483f" [[package]] name = "wasefire" -version = "0.7.1-git" +version = "0.8.0-git" dependencies = [ "bytemuck", "crypto-common", diff --git a/markdownlint.rb b/markdownlint.rb index a1d38857c..fcb22592e 100644 --- a/markdownlint.rb +++ b/markdownlint.rb @@ -18,5 +18,6 @@ rule 'MD026', :punctuation => '.,;!' # Trailing punctuation in header exclude_rule 'MD001' # Header levels should only increment by one level at a time +exclude_rule 'MD002' # First header should be a top level header exclude_rule 'MD024' # Multiple headers with the same content exclude_rule 'MD041' # First line in file should be a top level header diff --git a/rust-toolchain.toml b/rust-toolchain.toml index ef9a22634..f3e593e6c 100644 --- a/rust-toolchain.toml +++ b/rust-toolchain.toml @@ -1,5 +1,5 @@ [toolchain] -channel = "nightly-2024-12-04" +channel = "nightly-2025-01-13" components = ["clippy", "llvm-tools", "miri", "rust-src", "rustfmt"] targets = [ "i686-unknown-linux-gnu", diff --git a/scripts/sync.sh b/scripts/sync.sh index 2c9aac4f0..44027c247 100755 --- a/scripts/sync.sh +++ b/scripts/sync.sh @@ -33,6 +33,8 @@ for dir in $(find crates -name Cargo.toml -printf '%h\n' | sort); do grep -q '^\[lints\.' $file && e "unexpected [lints.*] section in $file" sed -i '/^\[lints\]$/q' $file [ "$(tail -n1 $file)" = '[lints]' ] || printf '\n[lints]\n' >> $file + # TODO(https://github.com/rust-lang/rust-clippy/issues/13994): Remove when fixed. + add_lint $file allow clippy.literal-string-with-formatting-args add_lint $file warn clippy.mod-module-files add_lint $file allow clippy.unit-arg # add_lint $file warn rust.elided-lifetimes-in-paths @@ -50,7 +52,6 @@ for dir in $(find crates -name Cargo.toml -printf '%h\n' | sort); do interpreter|runner-*|scheduler|xtask|*/fuzz) ;; *) add_lint $file warn rust.unreachable-pub ;; esac - add_lint $file warn rust.unsafe-op-in-unsafe-fn case $crate in */fuzz) ;; *) add_lint $file warn rust.unused-crate-dependencies ;; diff --git a/scripts/wrapper.sh b/scripts/wrapper.sh index 08fefecd3..34b2fe44b 100755 --- a/scripts/wrapper.sh +++ b/scripts/wrapper.sh @@ -50,10 +50,10 @@ case "$1" in esac ;; mdbook) ensure_cargo mdbook 0.4.43 ;; - probe-rs) ensure_cargo probe-rs-tools 0.24.0 ;; + probe-rs) ensure_cargo probe-rs-tools 0.25.0 ;; rust-objcopy|rust-size) ensure_cargo cargo-binutils 0.3.6 ;; taplo) ensure_cargo taplo-cli 0.9.3 ;; - trunk) ensure_cargo trunk 0.21.4 ;; + trunk) ensure_cargo trunk 0.21.5 ;; twiggy) ensure_cargo twiggy 0.7.0 ;; *) IS_CARGO=n ;; esac diff --git a/third_party/SchemaStore/schemastore b/third_party/SchemaStore/schemastore index b49459dc8..f4f555de9 160000 --- a/third_party/SchemaStore/schemastore +++ b/third_party/SchemaStore/schemastore @@ -1 +1 @@ -Subproject commit b49459dc8f90228c7f44645ea859d57f75c880d9 +Subproject commit f4f555de92bc4a1f2ad05a0ad97e3f08e05ba5df diff --git a/third_party/WebAssembly/spec b/third_party/WebAssembly/spec index 06a88d08c..f3a0e0623 160000 --- a/third_party/WebAssembly/spec +++ b/third_party/WebAssembly/spec @@ -1 +1 @@ -Subproject commit 06a88d08cf0b1cf7f16d877f27ee25e1f5e09187 +Subproject commit f3a0e06235d2d84bb0f3b5014da4370613886965