Re: [PATCH v1] rbtree: reduce unsafe blocks on pointer derefs

From: Charalampos Mitrodimas
Date: Mon Nov 17 2025 - 07:13:40 EST


Onur Özkan <work@xxxxxxxxxxxxx> writes:

> Refactors parts of the get() and cursor_lower_bound()
> traversal logic to minimize the scope of unsafe blocks
> and avoid duplicating same safety comments.
>
> One of the removed comments was also misleading:
>
> // SAFETY: `node` is a non-null node...
> Ordering::Equal => return Some(unsafe { &(*this).value }),
>
> as `node` should have been `this`.
>
> No functional changes intended; this is purely a safety
> improvement that reduces the amount of unsafe blocks
> while keeping all invariants intact.
>
> Signed-off-by: Onur Özkan <work@xxxxxxxxxxxxx>
> ---
> rust/kernel/rbtree.rs | 27 +++++++++++++++------------
> 1 file changed, 15 insertions(+), 12 deletions(-)
>

This is a nice change to have if it reaches the general consensus.

Acked-By: Charalampos Mitrodimas <charmitro@xxxxxxxxxx>

--
C. Mitrodimas