Skip to content
New issue

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

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

Already on GitHub? Sign in to your account

fix!: explicitly mark _KGDTENTRY64 and _KIDTENTRY64 as opaque types in bindgen #277

Merged
merged 2 commits into from
Jan 31, 2025

Conversation

wmmc88
Copy link
Collaborator

@wmmc88 wmmc88 commented Jan 24, 2025

This pull request includes several changes to the wdk-build crate to improve its functionality and maintainability. The most important changes include explicitly marking _KGDTENTRY64 and _KIDTENTRY64 as opaque types and adding new tests for the bindgen_header_contents method.

The new types are generated as:

#[repr(C)]
#[derive(Copy, Clone)]
pub union _KGDTENTRY64 {
    pub _address: u8,
}
pub union _KIDTENTRY64 {
    pub _address: u8,
}

and replace the historic structs that were manually added to the bindgen input header. These historic structs are no longer present in modern WDK headers, and these types should be treated as opaque.

Cfg Updates:

  • crates/wdk-build/build.rs: Updated the cfg name from nightly_feature to nightly_toolchain to reflect its purpose of enabling when the toolchain is detected as nightly.

Blocklist Additions:

Typo Fix:

Code Refactoring:

  • crates/wdk-build/src/lib.rs: Refactored the bindgen_header_contents method to use flat_map and collect for improved readability and performance. Removed the hardcoded definitions for KGDTENTRY64 and KIDTENTRY64.

Test Additions:

  • crates/wdk-build/src/lib.rs: Added new tests for the bindgen_header_contents method to ensure it generates the correct headers for different driver configurations (Wdm, Kmdf, and Umdf).
     
     
    BREAKING CHANGE: definitions for _KGDTENTRY64 and _KIDTENTRY64 have been removed

@wmmc88 wmmc88 requested a review from leon-xd January 24, 2025 01:59
@wmmc88 wmmc88 self-assigned this Jan 24, 2025
@wmmc88 wmmc88 requested review from a team and Copilot January 24, 2025 01:59
Copy link

@Copilot Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copilot reviewed 24 out of 39 changed files in this pull request and generated 2 comments.

Files not reviewed (15)
  • .vscode/settings.json: Language not supported
  • crates/wdk-sys/src/input.h: Language not supported
  • crates/wdk-sys/src/wdf.c: Language not supported
  • .github/workflows/code-formatting-check.yaml: Evaluated as low risk
  • .github/workflows/codeql.yml: Evaluated as low risk
  • .github/workflows/build.yaml: Evaluated as low risk
  • Cargo.toml: Evaluated as low risk
  • crates/wdk-sys/src/ntddk.rs: Evaluated as low risk
  • crates/wdk-build/src/bindgen.rs: Evaluated as low risk
  • CONTRIBUTING.md: Evaluated as low risk
  • .github/workflows/docs.yaml: Evaluated as low risk
  • crates/wdk-sys/Cargo.toml: Evaluated as low risk
  • crates/wdk-sys/src/lib.rs: Evaluated as low risk
  • .github/workflows/test.yaml: Evaluated as low risk
  • .github/workflows/lint.yaml: Evaluated as low risk
Comments suppressed due to low confidence (3)

crates/wdk-sys/src/hid.rs:13

  • The reason parameter is not valid for the #[allow] attribute. It should be removed.
#[allow(missing_docs, reason = "most items in the WDK headers have no inline documentation, so bindgen is unable to generate documentation for their bindings")]

crates/wdk-sys/src/hid.rs:19

  • The reason parameter is not valid for the #[allow] attribute. It should be removed.
#[allow(clippy::wildcard_imports, reason = "the underlying c code relies on all type definitions being in scope, which results in the bindgen generated code relying on the generated types being in scope as well")]

crates/wdk-sys/build.rs:47

  • The usage of unreachable! macro might not be the best way to handle unexpected configurations. Consider using a more descriptive error message or handle the case more gracefully.
unreachable!("generate_wdf_function_table is only called with WDF driver configurations")

crates/wdk-build/src/lib.rs Outdated Show resolved Hide resolved
crates/wdk-build/src/lib.rs Outdated Show resolved Hide resolved
@wmmc88 wmmc88 force-pushed the opaque-missing-km-structs branch 3 times, most recently from 85dc60f to d8c1e96 Compare January 25, 2025 04:07
…s in bindgen

BREAKING CHANGE: defintions for `_KGDTENTRY64` and `_KIDTENTRY64` have been removed
@wmmc88 wmmc88 force-pushed the opaque-missing-km-structs branch from d8c1e96 to 15d65ba Compare January 30, 2025 05:04
@wmmc88 wmmc88 marked this pull request as ready for review January 30, 2025 05:06
@wmmc88 wmmc88 changed the title fix!: explicitly mark _KGDTENTRY64 and _KIDTENTRY64 as opaque types in bindgen fix!: explicitly mark _KGDTENTRY64 and _KIDTENTRY64 as opaque types in bindgen Jan 30, 2025
hamzamust
hamzamust previously approved these changes Jan 30, 2025
leon-xd
leon-xd previously approved these changes Jan 30, 2025
@wmmc88 wmmc88 enabled auto-merge January 31, 2025 18:01
@wmmc88 wmmc88 dismissed stale reviews from leon-xd and hamzamust via 6afddc0 January 31, 2025 19:12
@wmmc88 wmmc88 force-pushed the opaque-missing-km-structs branch from 5d3d02b to 6afddc0 Compare January 31, 2025 19:12
@wmmc88 wmmc88 requested review from hamzamust and leon-xd January 31, 2025 19:51
@wmmc88 wmmc88 added this pull request to the merge queue Jan 31, 2025
Merged via the queue into microsoft:main with commit b64d8f4 Jan 31, 2025
62 checks passed
@wmmc88 wmmc88 deleted the opaque-missing-km-structs branch January 31, 2025 21:36
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants