Skip to content

Commit

Permalink
fix: only emit must_use hint when wdf function has return type (#122)
Browse files Browse the repository at this point in the history
  • Loading branch information
wmmc88 authored Apr 24, 2024
1 parent 6410897 commit 5d52a43
Show file tree
Hide file tree
Showing 99 changed files with 2,878 additions and 848 deletions.
65 changes: 65 additions & 0 deletions .github/workflows/local-development-makefile.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,65 @@
on:
push:
pull_request:
merge_group:
schedule: # Trigger a job on default branch at 4AM PST everyday
- cron: "0 11 * * *"

name: Local Development Makefile

env:
RUSTFLAGS: -D warnings

jobs:
build:
name: Test WDR's local cargo-make Makefile
runs-on: windows-latest
strategy:
matrix:
wdk:
- Microsoft.WindowsWDK.10.0.22621 # NI WDK

target_triple:
- x86_64-pc-windows-msvc
# - aarch64-pc-windows-msvc FIXME: find a way to validate the local makefile on aarch64

steps:
- name: Checkout Repository
uses: actions/checkout@v4

- name: Install Winget
uses: ./.github/actions/winget-install
with:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

- name: Install WDK (${{ matrix.wdk }})
run: |
if (!(winget list --exact --source winget --id ${{ matrix.wdk }})[-1].contains("${{ matrix.wdk }}")) {
winget install --disable-interactivity --source winget --exact --id ${{ matrix.wdk }}
}
- name: Install Nightly Rust Toolchain (${{ matrix.target_triple }})
uses: dtolnay/rust-toolchain@nightly
with:
components: clippy, rustfmt
targets: ${{ matrix.target_triple }}

- name: Install Beta Rust Toolchain (${{ matrix.target_triple }})
uses: dtolnay/rust-toolchain@beta
with:
components: clippy
targets: ${{ matrix.target_triple }}

- name: Install Stable Rust Toolchain (${{ matrix.target_triple }})
uses: dtolnay/rust-toolchain@stable
with:
components: clippy
targets: ${{ matrix.target_triple }}

- name: Install Cargo Make
uses: taiki-e/install-action@v2
with:
tool: cargo-make

- name: Test wdk-pre-commit-flow cargo-make task
run: cargo make wdk-pre-commit-flow
52 changes: 49 additions & 3 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

48 changes: 45 additions & 3 deletions Makefile.toml
Original file line number Diff line number Diff line change
@@ -1,12 +1,14 @@
extend = "./crates/wdk-build/rust-driver-makefile.toml"

[config]
min_version = "0.37.11"
additional_profiles = ["all-default-tasks"]

[env]
CARGO_MAKE_SKIP_SLOW_SECONDARY_FLOWS = false
CARGO_MAKE_CLIPPY_ARGS = "--all-targets -- -D warnings"
RUSTFLAGS = "-D warnings"
CARGO_MAKE_RUST_DEFAULT_TOOLCHAIN = "stable"

[tasks.wdk-pre-commit-flow]
description = "Run pre-commit tasks and checks"
Expand All @@ -25,6 +27,9 @@ dependencies = [
"nightly-test-flow",
"nightly-clippy-flow",
"nightly-docs",
"beta-test-flow",
"beta-clippy-flow",
"beta-docs",
]

[tasks.format]
Expand All @@ -43,7 +48,10 @@ assert ${success} "Failed to delete tests directory"
'''

[tasks.test]
install_crate = { crate_name = "cargo-expand", version = "1.0.80" }
install_crate = { crate_name = "cargo-expand", binary = "cargo", test_arg = [
"expand",
"--version",
], version = "1.0.80" }

[tasks.audit]
args = ["audit", "--deny", "warnings"]
Expand All @@ -70,7 +78,6 @@ env = { CARGO_MAKE_CARGO_BUILD_TEST_FLAGS = { unset = true } }

[tasks.nightly-clippy-flow]
extend = "clippy-flow"
toolchain = "nightly"
dependencies = [
"pre-nightly-clippy",
"nightly-clippy-router",
Expand All @@ -88,9 +95,44 @@ env = { CARGO_MAKE_CLIPPY_ARGS = "--features nightly ${CARGO_MAKE_CLIPPY_ARGS}",

[tasks.post-nightly-clippy]
extend = "post-clippy"
env = { CARGO_MAKE_RUST_DEFAULT_TOOLCHAIN = { unset = true } }
env = { CARGO_MAKE_RUST_DEFAULT_TOOLCHAIN = "${CARGO_MAKE_RUST_DEFAULT_TOOLCHAIN}" }

[tasks.nightly-docs]
extend = "docs"
toolchain = "nightly"
args = ["doc", "--no-deps", "--features", "nightly"]

[tasks.beta-test-flow]
extend = "test-flow"
dependencies = ["pre-beta-test", "beta-test", "post-beta-test"]

[tasks.pre-beta-test]
alias = "pre-test"

[tasks.beta-test]
extend = "test"
toolchain = "beta"

[tasks.post-beta-test]
alias = "post-test"

[tasks.beta-clippy-flow]
extend = "clippy-flow"
dependencies = ["pre-beta-clippy", "beta-clippy-router", "post-beta-clippy"]

[tasks.pre-beta-clippy]
extend = "pre-clippy"
# Proc-macro crates fail to trigger recompilation when switching toolchains due to bug in rustc resulting in "found invalid metadata files for crate" errors.
run_task = "clean"

[tasks.beta-clippy-router]
extend = "clippy-router"
env = { CARGO_MAKE_RUST_DEFAULT_TOOLCHAIN = "beta" }

[tasks.post-beta-clippy]
extend = "post-clippy"
env = { CARGO_MAKE_RUST_DEFAULT_TOOLCHAIN = "${CARGO_MAKE_RUST_DEFAULT_TOOLCHAIN}" }

[tasks.beta-docs]
extend = "docs"
toolchain = "beta"
2 changes: 1 addition & 1 deletion crates/sample-kmdf-driver/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -31,4 +31,4 @@ wdk-build.workspace = true

[features]
default = []
nightly = ["wdk-macros/nightly"]
nightly = ["wdk-macros/nightly", "wdk/nightly", "wdk-sys/nightly"]
3 changes: 1 addition & 2 deletions crates/sample-kmdf-driver/build.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,5 @@
// License: MIT OR Apache-2.0

fn main() -> Result<(), wdk_build::ConfigError> {
wdk_build::Config::from_env_auto()?.configure_binary_build()?;
Ok(())
wdk_build::Config::from_env_auto()?.configure_binary_build()
}
3 changes: 0 additions & 3 deletions crates/sample-kmdf-driver/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@
// License: MIT OR Apache-2.0

#![no_std]
#![cfg_attr(feature = "nightly", feature(hint_must_use))]
#![deny(unsafe_op_in_unsafe_fn)]
#![deny(clippy::all)]
#![deny(clippy::pedantic)]
Expand Down Expand Up @@ -96,7 +95,6 @@ pub unsafe extern "system" fn driver_entry(
// 4. `driver_config` is a valid pointer to a valid `WDF_DRIVER_CONFIG`
// 5. `driver_handle_output` is expected to be null
unsafe {
#![allow(clippy::multiple_unsafe_ops_per_block)]
wdf_driver_create_ntstatus = call_unsafe_wdf_function_binding!(
WdfDriverCreate,
driver as wdk_sys::PDRIVER_OBJECT,
Expand Down Expand Up @@ -167,7 +165,6 @@ extern "C" fn evt_driver_device_add(
// null
// 3. `device_handle_output` is expected to be null
unsafe {
#![allow(clippy::multiple_unsafe_ops_per_block)]
ntstatus = wdk_macros::call_unsafe_wdf_function_binding!(
WdfDeviceCreate,
&mut device_init,
Expand Down
22 changes: 13 additions & 9 deletions crates/wdk-macros/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,9 @@ edition = "2021"
name = "wdk-macros"
version = "0.2.0"
description = "A collection of macros that help make it easier to interact with wdk-sys's direct bindings"
repository = "https://github.com/microsoft/windows-drivers-rs"
readme = "README.md"
license = "MIT OR Apache-2.0"
repository.workspace = true
readme.workspace = true
license.workspace = true
keywords = ["wdk", "windows", "wdf", "wdm", "ffi"]
categories = [
"external-ffi-bindings",
Expand All @@ -19,21 +19,25 @@ categories = [
proc-macro = true

[dependencies]
cfg-if = "1.0.0"
cargo_metadata = "0.18.1"
itertools = "0.12.1"
proc-macro2 = "1.0.78"
quote = "1.0.35"
scratch = "1.0"
syn = { version = "2.0.48", features = ["full"] }

[dev-dependencies]
# use path dependency instead of workspace due to: https://github.com/eupn/macrotest/issues/95
wdk-sys.path = "../wdk-sys"
wdk-sys.workspace = true
fs4 = { version = "0.8.2", features = ["sync"] }
pathdiff = "0.2.0"
lazy_static = "1.4.0"
# Pin to github version due to: https://github.com/eupn/macrotest/issues/94
macrotest = { git = "https://github.com/eupn/macrotest", rev = "c4151a5" }
macrotest = "1.0.11"
owo-colors = "4.0.0"
paste = "1.0.14"
pretty_assertions = "1.4.0"
rustversion = "1.0.14"
syn = { version = "2.0.48", features = ["extra-traits"] }
trybuild = "1.0.89"
owo-colors = "4.0.0"

[package.metadata.cargo-udeps.ignore]
development = [
Expand Down
Loading

0 comments on commit 5d52a43

Please sign in to comment.