Re: [PATCH v2 06/16] rust: io: register: allow explicit base type specification

[email protected] Wed, 05 Aug 2026 16:43:34 +0000
Newsgroups gmane.linux.kernel.pci,gmane.comp.video.dri.devel
Message-ID <[email protected]>
Thank you for your contribution! Sashiko AI review found 1 potential issue(s) to consider:
- [Medium] The `register!` macro fallback rule `($($rest:tt)*)` causes infinite recursion on any syntax error.
--

--- Patch [6]: [PATCH v2 06/16] rust: io: register: allow explicit base type specification ---
commit f65d8a2bc4e7792b0378bf9b7d9359faf6c62680
Author: Gary Guo <[email protected]>

rust: io: register: allow explicit base type specification

This commit adds a base parameter to the register! macro to allow explicit
base type specification for I/O regions. It updates the macro definitions
to accept this parameter and adds a compatibility fallback rule for users
that have not yet been converted.

> diff --git a/rust/kernel/io/register.rs b/rust/kernel/io/register.rs
> index e4039e31b4e78..7dca2437b5516 100644
> --- a/rust/kernel/io/register.rs
> +++ b/rust/kernel/io/register.rs

[ ... ]

> @@ -962,4 +1010,12 @@ impl $crate::io::register::RegisterArray for $name {
>  
>          impl $crate::io::register::RelativeRegisterArray for $name {}
>      };
> +
> +    // Compatibility rule when base is not specified.
> +    ($($rest:tt)*) => {
> +        $crate::register!(
> +            base: $crate::io::Region;
> +            $($rest)*
> +        );
> +    }
>  }

[Severity: Medium]
Will this catch-all rule cause infinite recursion if there is a syntax
error elsewhere in the macro invocation?

If a developer makes a typo inside a register! block, the strict explicit
matching rules will fail. The token stream then falls through to this
compatibility rule, which prepends the base region and recursively invokes
the macro. Because the original syntax error is still present, the explicit
rules will fail again, triggering this fallback rule repeatedly.

Could this obfuscate the original syntax error by ultimately failing with a
compiler recursion limit error instead?

-- 
Sashiko AI review ยท https://sashiko.dev/#/patchset/[email protected]?part=6