Re: [PATCH 06/10] rust: property: Add child accessor and iterator
From: Andrew Ballance
Date: Wed Mar 26 2025 - 17:04:45 EST
On Wed, Mar 26, 2025 at 12:13 PM Remo Senekowitsch Wrote:
> impl FwNode {
> + // SAFETY: `raw` must have its refcount incremented.
> + unsafe fn from_raw(raw: *mut bindings::fwnode_handle) -> ARef<Self> {
> + unsafe { ARef::from_raw(ptr::NonNull::new_unchecked(raw.cast())) }
> + }
this safety comment should say why it is ok to cast from a
struct fwnode_handle* to a *const FwNode
> + // We will pass `prev` to `fwnode_get_next_child_node`,
> + // which decrements its refcount, so we use
> + // `ARef::into_raw` to avoid decrementing the refcount
> + // twice.
> + let prev = ARef::into_raw(prev);
> + prev.as_ptr().cast()
> + }
> + };
> + let next = unsafe { bindings::fwnode_get_next_child_node(self.as_raw(), prev_ptr) };
this is missing a safety comment
> + if next.is_null() {
> + return None;
> + }
Andrew