From mboxrd@z Thu Jan 1 00:00:00 1970 From: Claude Code Review Bot To: dri-devel-reviews@example.com Subject: Claude review: rust: add warn_on_err macro Date: Thu, 23 Apr 2026 08:52:54 +1000 Message-ID: In-Reply-To: <20260421-nova-unload-v2-1-2fe54963af8b@nvidia.com> References: <20260421-nova-unload-v2-0-2fe54963af8b@nvidia.com> <20260421-nova-unload-v2-1-2fe54963af8b@nvidia.com> X-Mailer: Claude Code Patch Reviewer Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: 7bit MIME-Version: 1.0 Patch Review **File:** `rust/kernel/bug.rs` ```rust +/// Report a warning if `res` is an error and return it unmodified. +#[macro_export] +macro_rules! warn_on_err { + ($res:expr) => {{ + let res = $res; + let _ = $crate::warn_on!(res.is_err()); + res + }}; +} ``` Clean and straightforward. Evaluates `$res` exactly once, delegates to the existing `warn_on!` macro, and returns the result unmodified. The `let _ =` discard of `warn_on!`'s return value is correct since we only care about the side effect (the WARN). One minor point: this macro lives in `kernel/bug.rs` which is a shared crate-level utility. Since it's `#[macro_export]`, it becomes part of the `kernel` crate's public API. The Rust-for-Linux maintainers may want to weigh in on whether this is general enough to warrant that placement vs. being a driver-local helper. But given that `warn_on!` is already there, adding `warn_on_err!` alongside it is natural. No issues. --- Generated by Claude Code Patch Reviewer