Repository navigation
Conversation
Fix a new without default warning in `UffdBuilder` new() implementation. Implement `Default` for `UffdBuilder` by hand and make `UffdBuilder::new()` return `UffdBuilder::default()`. `#[derive(Default)]` can't be used here: it would set `user_mode_only` to `false`, while `new()` has always defaulted it to `true`. Add a unit test that checks the defaults of `UffdBuilder::new()`. Also derive `Default` for `FeatureFlags` and `IoctlFlags`; the default value is the empty set of flags. Signed-off-by: Babis Chalios <mail@bchalios.io>
`Uffd::copy` and `Uffd::zeropage` write to a memory range of the calling process behind Rust's back. Document that the caller must ensure it is sound for the contents of that range to change, e.g. that no Rust references to it are live. The other requirements on the arguments (page alignment, the range being registered with the Uffd object, `src` being readable) are checked by the kernel, which returns an error if they don't hold, so they are not safety requirements. Signed-off-by: Babis Chalios <mail@bchalios.io>
Apply pattern match directly on the Errno variant (Errno::EAGAIN) instead of using a guard. Signed-off-by: Babis Chalios <mail@bchalios.io>
Drop the closure and pass the associated function itself, directly. Signed-off-by: Babis Chalios <mail@bchalios.io>
Use c_int::MAX instead. Signed-off-by: Babis Chalios <mail@bchalios.io>
Use `assert!` instead of `assert_eq!` with a literal bool, and drop a needless borrow of the arguments passed to `Command::args()`. Signed-off-by: Babis Chalios <mail@bchalios.io>
Check formatting with `cargo fmt --check` and run clippy on all targets for every kernel feature level, failing on any warning. This keeps the codebase warning-free now that the existing clippy warnings are fixed. Signed-off-by: Babis Chalios <mail@bchalios.io>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Fixes all
cargo clippy --all-targetswarnings, so CI can later run clippy with-D warnings.DefaultforUffdBuilder(new_without_default). It's written by hand rather than derived, because #[derive(Default)]would setuser_mode_onlytofalseinstead oftrue. A new unit test checks the defaults ofUffdBuilder::new().FeatureFlagsandIoctlFlagsalso deriveDefault`.# Safetysections toUffd::copyandUffd::zeropage: they write into the caller's address space, so the caller must make sure it is safe for the contents of the destination range to change.c_int::MAXinstead of the deprecatedlibc::INT_MAX.Err(Errno::EAGAIN)directly instead of using a guard, passEvent::from_uffd_msgto.map()without a closure, useassert!instead ofassert_eq!with a literalbool, and drop a needless borrow in the manpage test.No behavior change. The only API additions are the
Defaultimpls.This also adds a CI job for testing style (
rustfmtandclippyfor every PR)