Skip to content

Commit

Permalink
build: reduce noise from bindgen warnings
Browse files Browse the repository at this point in the history
  • Loading branch information
wmmc88 committed Jan 5, 2024
1 parent 712e63f commit 3db1336
Show file tree
Hide file tree
Showing 7 changed files with 3,632 additions and 185 deletions.
2 changes: 1 addition & 1 deletion .gitattributes
Original file line number Diff line number Diff line change
Expand Up @@ -3,4 +3,4 @@

*.rs text diff=rust
*.toml text diff=toml
Cargo.lock text
Cargo.lock text diff=toml
58 changes: 55 additions & 3 deletions Cargo.lock

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

3 changes: 2 additions & 1 deletion crates/wdk-sys/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,8 @@ categories = [
bindgen.workspace = true
wdk-build.workspace = true
thiserror = "1.0.48"
tracing-subscriber = "0.3.17"
tracing-subscriber = { version = "0.3.17", features = ["env-filter"] }
anyhow = "1.0.79"

[dependencies]
wdk-macros.workspace = true
Expand Down
50 changes: 48 additions & 2 deletions crates/wdk-sys/build.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ use std::{
};

use bindgen::CodegenConfig;
use tracing_subscriber::{filter::LevelFilter, EnvFilter};
use wdk_build::{BuilderExt, Config, ConfigError, DriverConfig, KMDFConfig};

// FIXME: feature gate the WDF version
Expand Down Expand Up @@ -64,8 +65,53 @@ fn generate_wdf(out_path: &Path, config: Config) -> Result<(), ConfigError> {
)
}

fn main() -> Result<(), ConfigError> {
tracing_subscriber::fmt::init();
fn main() -> anyhow::Result<()> {
let tracing_filter = EnvFilter::default()
// Show errors and warnings by default
.add_directive(LevelFilter::WARN.into())
// Silence various warnings originating from bindgen that are not currently actionable
// FIXME: this currently sets the minimum log level to error for the listed modules. It should actually be turning off logging (level=off) for specific warnings in these modules, but a bug in the tracing crate's filtering is preventing this from working as expected. See https://github.com/tokio-rs/tracing/issues/2843.
.add_directive("bindgen::codegen::helpers[{message}]=error".parse()?)
.add_directive("bindgen::codegen::struct_layout[{message}]=error".parse()?)
.add_directive("bindgen::ir::comp[{message}]=error".parse()?)
.add_directive("bindgen::ir::context[{message}]=error".parse()?)
.add_directive("bindgen::ir::ty[{message}]=error".parse()?)
.add_directive("bindgen::ir::var[{message}]=error".parse()?);

// Allow overriding tracing behaviour via `EnvFilter::DEFAULT_ENV` env var
let tracing_filter =
if let Ok(filter_directives_from_env_var) = env::var(EnvFilter::DEFAULT_ENV) {
// Append each directive from the env var to the filter
filter_directives_from_env_var.split(',').fold(
tracing_filter,
|tracing_filter, filter_directive| {
match filter_directive.parse() {
Ok(parsed_filter_directive) => {
tracing_filter.add_directive(parsed_filter_directive)
}
Err(parsing_error) => {
// Must use eprintln!() here as tracing is not yet initialized
eprintln!(
"Skipping filter directive, {}, which failed to be parsed from {} \
obtained from {} with the following error: {}",
filter_directive,
filter_directives_from_env_var,
EnvFilter::DEFAULT_ENV,
parsing_error
);
tracing_filter
}
}
},
)
} else {
tracing_filter
};

tracing_subscriber::fmt()
.pretty()
.with_env_filter(tracing_filter)
.init();

let config = Config {
// FIXME: this should be based off of Cargo feature version
Expand Down
48 changes: 42 additions & 6 deletions crates/wdk-sys/generated_bindings/constants.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1958,6 +1958,7 @@ pub const PF_AVX512F_INSTRUCTIONS_AVAILABLE: u32 = 41;
pub const PF_ERMS_AVAILABLE: u32 = 42;
pub const PF_ARM_V82_DP_INSTRUCTIONS_AVAILABLE: u32 = 43;
pub const PF_ARM_V83_JSCVT_INSTRUCTIONS_AVAILABLE: u32 = 44;
pub const PF_ARM_V83_LRCPC_INSTRUCTIONS_AVAILABLE: u32 = 45;
pub const IsNEC_98: u32 = 0;
pub const IsNotNEC_98: u32 = 1;
pub const PROCESSOR_FEATURE_MAX: u32 = 64;
Expand Down Expand Up @@ -2457,8 +2458,9 @@ pub const DMA_IOMMU_INTERFACE_VERSION: u32 = 1;
pub const DMA_IOMMU_INTERFACE_EX_VERSION_1: u32 = 1;
pub const DMA_IOMMU_INTERFACE_EX_VERSION_2: u32 = 2;
pub const DMA_IOMMU_INTERFACE_EX_VERSION_MIN: u32 = 1;
pub const DMA_IOMMU_INTERFACE_EX_VERSION_MAX: u32 = 2;
pub const DMA_IOMMU_INTERFACE_EX_VERSION: u32 = 1;
pub const DMA_IOMMU_INTERFACE_EX_VERSION_3: u32 = 3;
pub const DMA_IOMMU_INTERFACE_EX_VERSION_MAX: u32 = 3;
pub const DMA_IOMMU_INTERFACE_EX_VERSION: u32 = 3;
pub const PO_MEM_PRESERVE: u32 = 1;
pub const PO_MEM_CLONE: u32 = 2;
pub const PO_MEM_CL_OR_NCHK: u32 = 4;
Expand Down Expand Up @@ -3685,6 +3687,7 @@ pub const TOKEN_READ: u32 = 131080;
pub const TOKEN_WRITE: u32 = 131296;
pub const TOKEN_EXECUTE: u32 = 131072;
pub const TOKEN_TRUST_CONSTRAINT_MASK: u32 = 131096;
pub const TOKEN_TRUST_ALLOWED_MASK: u32 = 131102;
pub const TOKEN_ACCESS_PSEUDO_HANDLE_WIN8: u32 = 24;
pub const TOKEN_ACCESS_PSEUDO_HANDLE: u32 = 24;
pub const TOKEN_MANDATORY_POLICY_OFF: u32 = 0;
Expand Down Expand Up @@ -4229,6 +4232,8 @@ pub const PERSISTENT_VOLUME_STATE_REALLOCATE_ALL_DATA_WRITES: u32 = 512;
pub const PERSISTENT_VOLUME_STATE_CHKDSK_RAN_ONCE: u32 = 1024;
pub const PERSISTENT_VOLUME_STATE_MODIFIED_BY_CHKDSK: u32 = 2048;
pub const PERSISTENT_VOLUME_STATE_DAX_FORMATTED: u32 = 4096;
pub const PERSISTENT_VOLUME_STATE_DEV_VOLUME: u32 = 8192;
pub const PERSISTENT_VOLUME_STATE_TRUSTED_VOLUME: u32 = 16384;
pub const OPLOCK_LEVEL_CACHE_READ: u32 = 1;
pub const OPLOCK_LEVEL_CACHE_HANDLE: u32 = 2;
pub const OPLOCK_LEVEL_CACHE_WRITE: u32 = 4;
Expand All @@ -4238,6 +4243,7 @@ pub const REQUEST_OPLOCK_INPUT_FLAG_COMPLETE_ACK_ON_CLOSE: u32 = 4;
pub const REQUEST_OPLOCK_CURRENT_VERSION: u32 = 1;
pub const REQUEST_OPLOCK_OUTPUT_FLAG_ACK_REQUIRED: u32 = 1;
pub const REQUEST_OPLOCK_OUTPUT_FLAG_MODES_PROVIDED: u32 = 2;
pub const REQUEST_OPLOCK_OUTPUT_FLAG_WRITABLE_SECTION_PRESENT: u32 = 4;
pub const QUERY_DEPENDENT_VOLUME_REQUEST_FLAG_HOST_VOLUMES: u32 = 1;
pub const QUERY_DEPENDENT_VOLUME_REQUEST_FLAG_GUEST_VOLUMES: u32 = 2;
pub const SD_GLOBAL_CHANGE_TYPE_MACHINE_SID: u32 = 1;
Expand Down Expand Up @@ -4285,12 +4291,12 @@ pub const STREAM_LAYOUT_ENTRY_NO_CLUSTERS_ALLOCATED: u32 = 8;
pub const STREAM_LAYOUT_ENTRY_HAS_INFORMATION: u32 = 16;
pub const STREAM_EXTENT_ENTRY_AS_RETRIEVAL_POINTERS: u32 = 1;
pub const STREAM_EXTENT_ENTRY_ALL_EXTENTS: u32 = 2;
pub const CHECKSUM_TYPE_UNCHANGED: i32 = -1;
pub const CHECKSUM_TYPE_NONE: u32 = 0;
pub const CHECKSUM_TYPE_CRC32: u32 = 1;
pub const CHECKSUM_TYPE_CRC64: u32 = 2;
pub const CHECKSUM_TYPE_ECC: u32 = 3;
pub const CHECKSUM_TYPE_FIRST_UNUSED_TYPE: u32 = 4;
pub const CHECKSUM_TYPE_SHA256: u32 = 4;
pub const CHECKSUM_TYPE_FIRST_UNUSED_TYPE: u32 = 5;
pub const FSCTL_INTEGRITY_FLAG_CHECKSUM_ENFORCEMENT_OFF: u32 = 1;
pub const OFFLOAD_READ_FLAG_ALL_ZERO_BEYOND_CURRENT_RANGE: u32 = 1;
pub const SET_PURGE_FAILURE_MODE_ENABLED: u32 = 1;
Expand Down Expand Up @@ -4366,6 +4372,7 @@ pub const IO_REPARSE_TAG_RESERVED_ONE: u32 = 1;
pub const IO_REPARSE_TAG_RESERVED_TWO: u32 = 2;
pub const IO_REPARSE_TAG_RESERVED_RANGE: u32 = 2;
pub const IO_REPARSE_TAG_VALID_VALUES: u32 = 4026597375;
pub const IO_REPARSE_TAG_RESERVED_INVALID: u32 = 3221258240;
pub const IO_REPARSE_TAG_MOUNT_POINT: u32 = 2684354563;
pub const IO_REPARSE_TAG_HSM: u32 = 3221225476;
pub const IO_REPARSE_TAG_DRIVE_EXTENDER: u32 = 2147483653;
Expand Down Expand Up @@ -4540,13 +4547,22 @@ pub const FILE_PIPE_SYMLINK_FLAG_RELATIVE: u32 = 2;
pub const FILE_PIPE_SYMLINK_VALID_FLAGS: u32 = 3;
pub const QUERY_DIRECT_ACCESS_IMAGE_EXTENTS: u32 = 1;
pub const QUERY_DIRECT_ACCESS_DATA_EXTENTS: u32 = 2;
pub const REFS_VOLUME_DEDUP_INFO_INPUT_BUFFER_VERSION: u32 = 1;
pub const REFS_VOLUME_DEDUP_INFO_OUTPUT_BUFFER_VERSION: u32 = 1;
pub const REFS_QUERY_VOLUME_TOTAL_SHARED_LCNS_OUTPUT_BUFFER_VERSION: u32 = 1;
pub const REFS_SET_VOLUME_COMPRESSION_INFO_INPUT_BUFFER_VERSION: u32 = 1;
pub const REFS_QUERY_VOLUME_COMPRESSION_INFO_OUTPUT_BUFFER_VERSION: u32 = 1;
pub const REFS_SET_VOLUME_IO_METRICS_INFO_INPUT_BUFFER_VERSION: u32 = 1;
pub const REFS_QUERY_VOLUME_IO_METRICS_INFO_INPUT_BUFFER_VERSION: u32 = 1;
pub const REFS_QUERY_VOLUME_IO_METRICS_INFO_OUTPUT_BUFFER_VERSION: u32 = 1;
pub const IO_QOS_MAX_RESERVATION: u32 = 1000000000;
pub const SMB_CCF_APP_INSTANCE_EA_NAME: &[u8; 29] = b"ClusteredApplicationInstance\0";
pub const NETWORK_APP_INSTANCE_CSV_FLAGS_VALID_ONLY_IF_CSV_COORDINATOR: u32 = 1;
pub const LX_FILE_METADATA_UID_EA_NAME: &[u8; 7] = b"$LXUID\0";
pub const LX_FILE_METADATA_GID_EA_NAME: &[u8; 7] = b"$LXGID\0";
pub const LX_FILE_METADATA_MODE_EA_NAME: &[u8; 7] = b"$LXMOD\0";
pub const LX_FILE_METADATA_DEVICE_ID_EA_NAME: &[u8; 7] = b"$LXDEV\0";
pub const VALID_COPY_FILE_CHUNK_FLAGS: u32 = 0;
pub const SYSTEM_PAGE_PRIORITY_BITS: u32 = 3;
pub const SYSTEM_PAGE_PRIORITY_LEVELS: u32 = 8;
pub const TOKEN_HAS_TRAVERSE_PRIVILEGE: u32 = 1;
Expand Down Expand Up @@ -4576,6 +4592,7 @@ pub const TOKEN_AUDIT_REDIRECTION_TRUST: u32 = 8388608;
pub const TOKEN_LEARNING_MODE_LOGGING: u32 = 16777216;
pub const TOKEN_PERMISSIVE_LEARNING_MODE: u32 = 50331648;
pub const TOKEN_INHERIT_SECURITY_FLAGS: u32 = 3670016;
pub const SECURITY_DESCRIPTOR_DO_NOT_FREE: u32 = 67108864;
pub const IO_OPEN_PAGING_FILE: u32 = 2;
pub const IO_OPEN_TARGET_DIRECTORY: u32 = 4;
pub const IO_STOP_ON_SYMLINK: u32 = 8;
Expand Down Expand Up @@ -4743,6 +4760,7 @@ pub const ECP_OPEN_PARAMETERS_FLAG_OPEN_FOR_WRITE: u32 = 2;
pub const ECP_OPEN_PARAMETERS_FLAG_OPEN_FOR_DELETE: u32 = 4;
pub const ECP_OPEN_PARAMETERS_FLAG_IGNORE_DIR_CASE_SENSITIVITY: u32 = 8;
pub const ECP_OPEN_PARAMETERS_FLAG_FAIL_ON_CASE_SENSITIVE_DIR: u32 = 16;
pub const OPLOCK_FS_FILTER_FLAGS_MASK: u32 = 8;
pub const QoCFileStatInformation: u32 = 1;
pub const QoCFileLxInformation: u32 = 2;
pub const QoCFileEaInformation: u32 = 4;
Expand Down Expand Up @@ -4847,10 +4865,22 @@ pub const SECBUFFER_SUBSCRIBE_GENERIC_TLS_EXTENSION: u32 = 26;
pub const SECBUFFER_FLAGS: u32 = 27;
pub const SECBUFFER_TRAFFIC_SECRETS: u32 = 28;
pub const SECBUFFER_CERTIFICATE_REQUEST_CONTEXT: u32 = 29;
pub const SECBUFFER_CHANNEL_BINDINGS_RESULT: u32 = 30;
pub const SECBUFFER_ATTRMASK: u32 = 4026531840;
pub const SECBUFFER_READONLY: u32 = 2147483648;
pub const SECBUFFER_READONLY_WITH_CHECKSUM: u32 = 268435456;
pub const SECBUFFER_RESERVED: u32 = 1610612736;
pub const SEC_CHANNEL_BINDINGS_AUDIT_BINDINGS: u32 = 1;
pub const SEC_CHANNEL_BINDINGS_VALID_FLAGS: u32 = 1;
pub const SEC_CHANNEL_BINDINGS_RESULT_CLIENT_SUPPORT: u32 = 1;
pub const SEC_CHANNEL_BINDINGS_RESULT_ABSENT: u32 = 2;
pub const SEC_CHANNEL_BINDINGS_RESULT_NOTVALID_MISMATCH: u32 = 4;
pub const SEC_CHANNEL_BINDINGS_RESULT_NOTVALID_MISSING: u32 = 8;
pub const SEC_CHANNEL_BINDINGS_RESULT_VALID_MATCHED: u32 = 16;
pub const SEC_CHANNEL_BINDINGS_RESULT_VALID_PROXY: u32 = 32;
pub const SEC_CHANNEL_BINDINGS_RESULT_VALID_MISSING: u32 = 64;
pub const SEC_CHANNEL_BINDINGS_RESULT_VALID: u32 = 112;
pub const SEC_CHANNEL_BINDINGS_RESULT_NOTVALID: u32 = 12;
pub const SZ_ALG_MAX_SIZE: u32 = 64;
pub const SECURITY_NATIVE_DREP: u32 = 16;
pub const SECURITY_NETWORK_DREP: u32 = 0;
Expand Down Expand Up @@ -5290,10 +5320,16 @@ extern "C" {
pub static GUID_STANDBY_RESET_PERCENT: GUID;
}
extern "C" {
pub static GUID_HUPR_ADAPTIVE_DISPLAY_TIMEOUT: GUID;
pub static GUID_HUPR_ADAPTIVE_AWAY_DISPLAY_TIMEOUT: GUID;
}
extern "C" {
pub static GUID_HUPR_ADAPTIVE_DIM_TIMEOUT: GUID;
pub static GUID_HUPR_ADAPTIVE_INATTENTIVE_DIM_TIMEOUT: GUID;
}
extern "C" {
pub static GUID_HUPR_ADAPTIVE_INATTENTIVE_DISPLAY_TIMEOUT: GUID;
}
extern "C" {
pub static GUID_HUPR_ADAPTIVE_AWAY_DIM_TIMEOUT: GUID;
}
extern "C" {
pub static GUID_ALLOW_STANDBY_STATES: GUID;
Expand Down
23 changes: 23 additions & 0 deletions crates/wdk-sys/generated_bindings/ntddk.rs
Original file line number Diff line number Diff line change
Expand Up @@ -10512,6 +10512,21 @@ extern "C" {
IoStatusBlock: PIO_STATUS_BLOCK,
) -> NTSTATUS;
}
extern "C" {
#[must_use]
pub fn NtCopyFileChunk(
SourceHandle: HANDLE,
DestHandle: HANDLE,
Event: HANDLE,
IoStatusBlock: PIO_STATUS_BLOCK,
Length: ULONG,
SourceOffset: PLARGE_INTEGER,
DestOffset: PLARGE_INTEGER,
SourceKey: PULONG,
DestKey: PULONG,
Flags: ULONG,
) -> NTSTATUS;
}
extern "C" {
#[must_use]
pub fn NtQueryObject(
Expand Down Expand Up @@ -12874,6 +12889,14 @@ extern "C" {
NotifyRoutine: POPLOCK_NOTIFY_ROUTINE,
) -> NTSTATUS;
}
extern "C" {
#[must_use]
pub fn FsRtlCheckOplockForFsFilterCallback(
Oplock: POPLOCK,
CallbackData: PVOID,
Flags: ULONG,
) -> NTSTATUS;
}
extern "C" {
pub fn FsRtlGetCurrentProcessLoaderList() -> PLIST_ENTRY;
}
Expand Down
Loading

0 comments on commit 3db1336

Please sign in to comment.