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: <Z56ZDEM9gcJhIXxW@pollux.localdomain>
Date: Sat, 1 Feb 2025 22:58:36 +0100
From: Danilo Krummrich <dakr@...nel.org>
To: Tamir Duberstein <tamird@...il.com>
Cc: Miguel Ojeda <ojeda@...nel.org>, Alex Gaynor <alex.gaynor@...il.com>,
	Boqun Feng <boqun.feng@...il.com>, Gary Guo <gary@...yguo.net>,
	Björn Roy Baron <bjorn3_gh@...tonmail.com>,
	Benno Lossin <benno.lossin@...ton.me>,
	Andreas Hindborg <a.hindborg@...nel.org>,
	Alice Ryhl <aliceryhl@...gle.com>, Trevor Gross <tmgross@...ch.edu>,
	rust-for-linux@...r.kernel.org, linux-kernel@...r.kernel.org
Subject: Re: [PATCH] rust: alloc: satisfy `aligned_alloc` requirements

On Sat, Feb 01, 2025 at 04:19:48PM -0500, Tamir Duberstein wrote:
> Hi Danilo, thanks for the review!
> 
> On Sat, Feb 1, 2025 at 3:18 PM Danilo Krummrich <dakr@...nel.org> wrote:
> >
> > I think I prefer this to be slightly more compact:
> >
> >    let min_align = core::mem::size_of::<*const crate::ffi::c_void>();
> >    let (align, size) = if layout.align() < min_align {
> >        (min_align, layout.size().div_ceil(min_align) * min_align)
> >    } else {
> >        (layout.align(), layout.size())
> >    };
> 
> I was trying to avoid repeated calls to either function, but I'm happy
> to shorten the variable names. Would that suit?

I think calling layout.align() twice is fine, no need shadow align for that.

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ