lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <87ms1xstzs.fsf@t14s.mail-host-address-is-not-set>
Date: Wed, 28 Jan 2026 15:16:07 +0100
From: Andreas Hindborg <a.hindborg@...nel.org>
To: Alice Ryhl <aliceryhl@...gle.com>
Cc: Will Deacon <will@...nel.org>, Peter Zijlstra <peterz@...radead.org>,
 Boqun Feng <boqun.feng@...il.com>, Mark Rutland <mark.rutland@....com>,
 Gary Guo <gary@...yguo.net>, Miguel Ojeda <ojeda@...nel.org>, Björn Roy
 Baron <bjorn3_gh@...tonmail.com>, Benno Lossin <lossin@...nel.org>, Trevor
 Gross <tmgross@...ch.edu>, Danilo Krummrich <dakr@...nel.org>,
 linux-kernel@...r.kernel.org, rust-for-linux@...r.kernel.org
Subject: Re: [PATCH] rust: atomic: add fetch_sub

"Alice Ryhl" <aliceryhl@...gle.com> writes:

> On Wed, Jan 28, 2026 at 01:47:11PM +0100, Andreas Hindborg wrote:
>> Add `Atomic::fetch_sub` with implementation and documentation in line with
>> existing `Atomic::fetch_add` implementation.
>>
>> Signed-off-by: Andreas Hindborg <a.hindborg@...nel.org>
>
>> +    /// let x = Atomic::new(42);
>> +    ///
>> +    /// assert_eq!(42, x.load(Relaxed));
>> +    ///
>> +    /// assert_eq!(30, { x.fetch_sub(12, Acquire); x.load(Relaxed) });
>
> These asserts are a bit confusing to read. After all, the fetch_sub call
> also returns a value, so how about this?
>
> let x = Atomic::new(42);
> assert_eq!(42, x.load(Relaxed));
> assert_eq!(42, x.fetch_sub(12, Acquire));
> assert_eq!(30, x.load(Relaxed));

We can do that. I basically copied the docs from add. Should I change
those as well?


Best regards,
Andreas Hindborg




Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ