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: <0984E8E7-C442-42E6-A8E7-691616304F6F@collabora.com>
Date: Wed, 16 Jul 2025 14:32:50 -0300
From: Daniel Almeida <daniel.almeida@...labora.com>
To: Danilo Krummrich <dakr@...nel.org>
Cc: abdiel.janulgue@...il.com,
 robin.murphy@....com,
 a.hindborg@...nel.org,
 ojeda@...nel.org,
 alex.gaynor@...il.com,
 boqun.feng@...il.com,
 gary@...yguo.net,
 bjorn3_gh@...tonmail.com,
 lossin@...nel.org,
 aliceryhl@...gle.com,
 tmgross@...ch.edu,
 bhelgaas@...gle.com,
 kwilczynski@...nel.org,
 gregkh@...uxfoundation.org,
 rafael@...nel.org,
 rust-for-linux@...r.kernel.org,
 linux-pci@...r.kernel.org,
 linux-kernel@...r.kernel.org
Subject: Re: [PATCH v2 2/5] rust: dma: add DMA addressing capabilities

Hi Danilo,

> +    #[inline]
> +    pub const fn new(n: usize) -> Result<Self> {
> +        Ok(Self(match n {
> +            0 => 0,
> +            1..=64 => u64::MAX >> (64 - n),
> +            _ => return Err(EINVAL),
> +        }))
> +    }
> +

Isn’t this equivalent to genmask_u64(0..=n) ? See [0].

You should also get a compile-time failure if n is out of bounds by default using
genmask.

— Daniel

[0]: https://lore.kernel.org/rust-for-linux/20250714-topics-tyr-genmask2-v9-1-9e6422cbadb6@collabora.com/#r

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ