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: page: add `from_raw()` Date: Mon, 23 Feb 2026 06:08:51 +1000 Message-ID: In-Reply-To: <20260220-unique-ref-v15-9-893ed86b06cc@kernel.org> References: <20260220-unique-ref-v15-0-893ed86b06cc@kernel.org> <20260220-unique-ref-v15-9-893ed86b06cc@kernel.org> X-Mailer: Claude Code Patch Reviewer Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: 7bit MIME-Version: 1.0 Patch Review > + /// Create a `&Page` from a raw `struct page` pointer > + /// > + /// # Safety > + /// > + /// `ptr` must be valid for use as a reference for the duration of `'a`. > + pub unsafe fn from_raw<'a>(ptr: *const bindings::page) -> &'a Self { > + // SAFETY: By function safety requirements, ptr is not null and is > + // valid for use as a reference. > + unsafe { &*Opaque::cast_from(ptr).cast::() } As Alice noted, `Opaque::cast_from(ptr)` is just `ptr.cast()`, so the whole expression simplifies to `&*ptr.cast::()`. The extra indirection through `Opaque::cast_from` doesn't add safety and obscures what's happening. As Miguel noted: the doc comment should end with a period, `ptr` in the safety comment should use backticks, and the safety requirement wording should use established terminology ("convertible to a shared reference" per the Rust standard library). The `Signed-off-by` uses `a.hindborg@samsung.com` rather than `a.hindborg@kernel.org` which is used in all other patches -- likely a copy-paste artifact from an older version. --- Generated by Claude Code Patch Reviewer