From 310426d56f44030e00602658192b77b3622aa67b Mon Sep 17 00:00:00 2001 From: Michael Kubacki Date: Thu, 16 Apr 2026 10:15:52 -0400 Subject: [PATCH 1/4] patina_stacktrace: Replace mod.rs with named module files Move x64/mod.rs to x64.rs and aarch64/mod.rs to aarch64.rs to follow the project convention of using named module files instead of mod.rs. Signed-off-by: Michael Kubacki --- core/patina_stacktrace/src/{aarch64/mod.rs => aarch64.rs} | 0 core/patina_stacktrace/src/{x64/mod.rs => x64.rs} | 0 2 files changed, 0 insertions(+), 0 deletions(-) rename core/patina_stacktrace/src/{aarch64/mod.rs => aarch64.rs} (100%) rename core/patina_stacktrace/src/{x64/mod.rs => x64.rs} (100%) diff --git a/core/patina_stacktrace/src/aarch64/mod.rs b/core/patina_stacktrace/src/aarch64.rs similarity index 100% rename from core/patina_stacktrace/src/aarch64/mod.rs rename to core/patina_stacktrace/src/aarch64.rs diff --git a/core/patina_stacktrace/src/x64/mod.rs b/core/patina_stacktrace/src/x64.rs similarity index 100% rename from core/patina_stacktrace/src/x64/mod.rs rename to core/patina_stacktrace/src/x64.rs From 80c8df3e4d45146e8a66b8f4784b3d60e4a9a0b6 Mon Sep 17 00:00:00 2001 From: Michael Kubacki Date: Thu, 16 Apr 2026 10:16:11 -0400 Subject: [PATCH 2/4] patina_mm: Replace mod.rs in integration test with a named module file Rename mod.rs to tests_root.rs and update the test entry point to use a #[path] attribute redirect, eliminating mod.rs while preserving the existing module hierarchy and crate-level import paths. Signed-off-by: Michael Kubacki --- components/patina_mm/tests/patina_mm_integration.rs | 2 +- .../tests/patina_mm_integration/{mod.rs => tests_root.rs} | 0 2 files changed, 1 insertion(+), 1 deletion(-) rename components/patina_mm/tests/patina_mm_integration/{mod.rs => tests_root.rs} (100%) diff --git a/components/patina_mm/tests/patina_mm_integration.rs b/components/patina_mm/tests/patina_mm_integration.rs index a280aa414..9aae839c2 100644 --- a/components/patina_mm/tests/patina_mm_integration.rs +++ b/components/patina_mm/tests/patina_mm_integration.rs @@ -9,5 +9,5 @@ //! //! SPDX-License-Identifier: Apache-2.0 -#[path = "patina_mm_integration/mod.rs"] +#[path = "patina_mm_integration/tests_root.rs"] mod patina_mm_integration; diff --git a/components/patina_mm/tests/patina_mm_integration/mod.rs b/components/patina_mm/tests/patina_mm_integration/tests_root.rs similarity index 100% rename from components/patina_mm/tests/patina_mm_integration/mod.rs rename to components/patina_mm/tests/patina_mm_integration/tests_root.rs From 5f8ee4e8f1751946a23916837ca83779d7bf4370 Mon Sep 17 00:00:00 2001 From: Michael Kubacki Date: Thu, 16 Apr 2026 10:16:27 -0400 Subject: [PATCH 3/4] Replace unwrap() with expect() in a few locations We prefer expect() in production code to provide more context in the event of an error. Add descriptive messages to unwrap() calls in: - rbt.rs: RBT rebalancing where sibling/parent nodes are guaranteed to exist by the algorithm invariants - x64/runtime_function.rs: PE .pdata chunk reads validated by preceding size checks - aarch64/runtime_function.rs: same pattern for AArch64 .pdata parsing Signed-off-by: Michael Kubacki --- core/patina_internal_collections/src/rbt.rs | 8 ++++---- core/patina_stacktrace/src/aarch64/runtime_function.rs | 6 +++--- core/patina_stacktrace/src/x64/runtime_function.rs | 6 +++--- 3 files changed, 10 insertions(+), 10 deletions(-) diff --git a/core/patina_internal_collections/src/rbt.rs b/core/patina_internal_collections/src/rbt.rs index 0b09861ab..2001b1431 100644 --- a/core/patina_internal_collections/src/rbt.rs +++ b/core/patina_internal_collections/src/rbt.rs @@ -803,7 +803,7 @@ where if node_is_left_child && sibling.right().is_black() { sibling.left().set_black(); sibling.set_red(); - if let Some(subtree_root) = Self::rotate_right(sibling.unwrap()) + if let Some(subtree_root) = Self::rotate_right(sibling.expect("sibling must exist in case 5")) && subtree_root.parent().is_none() { root.set(subtree_root.as_mut_ptr()); @@ -813,7 +813,7 @@ where } else if !node_is_left_child && sibling.left().is_black() { sibling.right().set_black(); sibling.set_red(); - if let Some(subtree_root) = Self::rotate_left(sibling.unwrap()) + if let Some(subtree_root) = Self::rotate_left(sibling.expect("sibling must exist in case 5")) && subtree_root.parent().is_none() { root.set(subtree_root.as_mut_ptr()); @@ -830,7 +830,7 @@ where node.parent().set_black(); if node_is_left_child { sibling.right().set_black(); - if let Some(subtree_root) = Self::rotate_left(node.parent().unwrap()) + if let Some(subtree_root) = Self::rotate_left(node.parent().expect("node must have parent in case 6")) && subtree_root.parent().is_none() { root.set(subtree_root.as_mut_ptr()); @@ -838,7 +838,7 @@ where } } else { sibling.left().set_black(); - if let Some(subtree_root) = Self::rotate_right(node.parent().unwrap()) + if let Some(subtree_root) = Self::rotate_right(node.parent().expect("node must have parent in case 6")) && subtree_root.parent().is_none() { root.set(subtree_root.as_mut_ptr()); diff --git a/core/patina_stacktrace/src/aarch64/runtime_function.rs b/core/patina_stacktrace/src/aarch64/runtime_function.rs index 11cf84176..3e546aa2b 100644 --- a/core/patina_stacktrace/src/aarch64/runtime_function.rs +++ b/core/patina_stacktrace/src/aarch64/runtime_function.rs @@ -88,8 +88,8 @@ impl<'a> RuntimeFunction<'a> { [exception_table_rva as usize..(exception_table_rva + exception_table_size) as usize] .chunks(core::mem::size_of::() * 2) // 2 u32 .map(|ele| { - let func_start_rva = ele.read32(0).unwrap(); // unwrap() will work validated above - let unwind_info = ele.read32(4).unwrap(); // unwrap() will work validated above + let func_start_rva = ele.read32(0).expect("chunk is 8 bytes, offset 0 is valid"); + let unwind_info = ele.read32(4).expect("chunk is 8 bytes, offset 4 is valid"); let flag = unwind_info & 0x3; @@ -102,7 +102,7 @@ impl<'a> RuntimeFunction<'a> { 0 => { let xdata_rva = unwind_info as usize; let xdata_header = &pe.bytes[xdata_rva..xdata_rva + 4]; - let xdata_header = xdata_header.read32(0).unwrap(); + let xdata_header = xdata_header.read32(0).expect("xdata header slice is 4 bytes"); (xdata_header & 0x3FFFF) * 4 } // Packed unwind data used with a single prolog and epilog diff --git a/core/patina_stacktrace/src/x64/runtime_function.rs b/core/patina_stacktrace/src/x64/runtime_function.rs index 94a7a432b..fb7f9b369 100644 --- a/core/patina_stacktrace/src/x64/runtime_function.rs +++ b/core/patina_stacktrace/src/x64/runtime_function.rs @@ -90,9 +90,9 @@ impl<'a> RuntimeFunction<'a> { .chunks(core::mem::size_of::() * 3) // 3 u32 .map(|ele| { ( - ele.read32(0).unwrap(), // start_rva - unwrap() will work validated above - ele.read32(4).unwrap(), // end_rva - unwrap() will work validated above - ele.read32(8).unwrap(), // unwindinfo_rva - unwrap() will work validated above + ele.read32(0).expect("chunk is 12 bytes, offset 0 is valid"), + ele.read32(4).expect("chunk is 12 bytes, offset 4 is valid"), + ele.read32(8).expect("chunk is 12 bytes, offset 8 is valid"), ) }) .find(|ele| ele.0 <= rip_rva && rip_rva < ele.1) From bdc7bfb45dfaaabc1fe1fca7b842f9f5ab9f9d3e Mon Sep 17 00:00:00 2001 From: Michael Kubacki Date: Thu, 16 Apr 2026 10:36:54 -0400 Subject: [PATCH 4/4] components: Enforce missing_docs lint in all component crates Add #![deny(missing_docs)] to component crate lib.rs files to enforce documentation requirements on public items. Signed-off-by: Michael Kubacki --- components/patina_acpi/src/lib.rs | 1 + components/patina_adv_logger/src/lib.rs | 1 + components/patina_mm/src/lib.rs | 1 + components/patina_performance/src/lib.rs | 1 + components/patina_samples/src/lib.rs | 1 + components/patina_smbios/src/lib.rs | 1 + components/patina_test/src/lib.rs | 1 + 7 files changed, 7 insertions(+) diff --git a/components/patina_acpi/src/lib.rs b/components/patina_acpi/src/lib.rs index 65f9b0c4e..a0c46645c 100644 --- a/components/patina_acpi/src/lib.rs +++ b/components/patina_acpi/src/lib.rs @@ -37,6 +37,7 @@ //! #![cfg_attr(all(not(feature = "std"), not(test), not(feature = "mockall")), no_std)] +#![deny(missing_docs)] #![feature(coverage_attribute)] #![feature(allocator_api)] diff --git a/components/patina_adv_logger/src/lib.rs b/components/patina_adv_logger/src/lib.rs index 4821ba391..9c9f1745f 100644 --- a/components/patina_adv_logger/src/lib.rs +++ b/components/patina_adv_logger/src/lib.rs @@ -5,6 +5,7 @@ " SPDX-License-Identifier: Apache-2.0\n", )] #![cfg_attr(all(not(feature = "std"), not(doc)), no_std)] +#![deny(missing_docs)] #![feature(coverage_attribute)] #[cfg(any(feature = "alloc", test, doc))] diff --git a/components/patina_mm/src/lib.rs b/components/patina_mm/src/lib.rs index e90a80f09..2c53a115f 100644 --- a/components/patina_mm/src/lib.rs +++ b/components/patina_mm/src/lib.rs @@ -4,6 +4,7 @@ " Copyright (c) Microsoft Corporation.\n\n", )] #![cfg_attr(all(not(feature = "std"), not(test), not(feature = "mockall")), no_std)] +#![deny(missing_docs)] #![feature(coverage_attribute)] extern crate alloc; diff --git a/components/patina_performance/src/lib.rs b/components/patina_performance/src/lib.rs index 702796fe3..26d6d8a39 100644 --- a/components/patina_performance/src/lib.rs +++ b/components/patina_performance/src/lib.rs @@ -30,6 +30,7 @@ //! #![cfg_attr(not(test), no_std)] +#![deny(missing_docs)] #![allow(unexpected_cfgs)] #![feature(coverage_attribute)] diff --git a/components/patina_samples/src/lib.rs b/components/patina_samples/src/lib.rs index 6fedf2663..7c99f3168 100644 --- a/components/patina_samples/src/lib.rs +++ b/components/patina_samples/src/lib.rs @@ -16,6 +16,7 @@ //! SPDX-License-Identifier: Apache-2.0 //! #![cfg_attr(not(feature = "std"), no_std)] +#![deny(missing_docs)] #![feature(coverage_attribute)] #![coverage(off)] // Disable all coverage instrumentation for sample code pub mod component; diff --git a/components/patina_smbios/src/lib.rs b/components/patina_smbios/src/lib.rs index 368d99a37..aaa130548 100644 --- a/components/patina_smbios/src/lib.rs +++ b/components/patina_smbios/src/lib.rs @@ -310,6 +310,7 @@ //! SPDX-License-Identifier: Apache-2.0 #![cfg_attr(all(not(feature = "std"), not(test), not(feature = "mockall")), no_std)] +#![deny(missing_docs)] #![feature(coverage_attribute)] // SMBIOS tables require little-endian byte order. The SmbiosRecord derive macro diff --git a/components/patina_test/src/lib.rs b/components/patina_test/src/lib.rs index 214c6ab1f..ad16e356a 100644 --- a/components/patina_test/src/lib.rs +++ b/components/patina_test/src/lib.rs @@ -4,6 +4,7 @@ " Copyright (c) Microsoft Corporation.\n\n", )] #![no_std] +#![deny(missing_docs)] #![feature(coverage_attribute)] extern crate alloc;