Re: [PATCH v2 1/2] rust: atomic: add fetch_sub

From: Andreas Hindborg

Date: Thu Feb 19 2026 - 08:34:44 EST


"Miguel Ojeda" <miguel.ojeda.sandonis@xxxxxxxxx> writes:

> On Thu, Feb 19, 2026 at 1:20 PM Andreas Hindborg <a.hindborg@xxxxxxxxxx> wrote:
>>
>> + fn fetch_sub[acquire, release, relaxed](a: &AtomicRepr<Self>, v: Self::Delta) -> Self {
>> + // SAFETY: `a.as_ptr()` is valid and properly aligned.
>> + unsafe { bindings::#call(v, a.as_ptr().cast()) }
>> + }
>
> [ I see `fetch_add` does the same, so it is fine here in this patch
> for consistency, but I thought I would leave a note here anyway... ]
>
> The safety comment, as written, could be read as just saying something
> it is true without justifying it. Something like:
>
> `a.as_ptr()` guarantees the returned pointer is valid and properly aligned.

I'll respin and fix this, for `fetch_add` as well. I can take the
spurious newline you mentioned on same occasion.


Best regards,
Andreas Hindborg