[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <CANiq72kZzU5gUnj=Li1UdS0qCbroDXr9-mnNhvTBs88rYVai_g@mail.gmail.com>
Date: Mon, 19 Jan 2026 09:21:06 +0100
From: Miguel Ojeda <miguel.ojeda.sandonis@...il.com>
To: Onur Özkan <work@...rozkan.dev>
Cc: rust-for-linux@...r.kernel.org, ojeda@...nel.org, alex.gaynor@...il.com,
boqun.feng@...il.com, gary@...yguo.net, bjorn3_gh@...tonmail.com,
lossin@...nel.org, a.hindborg@...nel.org, aliceryhl@...gle.com,
tmgross@...ch.edu, dakr@...nel.org, yutaro.ono.418@...il.com,
charmitro@...teo.net, borys.tyran@...tonmail.com, daniel@...lak.dev,
tamird@...il.com, linux-kernel@...r.kernel.org
Subject: Re: [PATCH v1] rbtree: reduce unsafe blocks on pointer derefs
On Thu, Nov 13, 2025 at 3:46 PM Onur Özkan <work@...rozkan.dev> wrote:
>
> 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@...rozkan.dev>
Applied to `rust-next` -- thanks everyone!
[ Alice writes:
"One consequence of creating a &_ to the bindings::rb_node struct means
that we assert immutability for the entire struct and not just the
rb_left/rb_right fields, but I have verified that this is ok."
- Miguel ]
[ Reworded title and replaced `cursor_lower_bound()` with
`find_best_match()` in message. - Miguel ]
Cheers,
Miguel
Powered by blists - more mailing lists