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] [day] [month] [year] [list]
Message-Id: <79BAA514-E57D-4F0E-B297-F178184E36C9@collabora.com>
Date: Mon, 23 Jun 2025 15:32:00 -0300
From: Daniel Almeida <daniel.almeida@...labora.com>
To: Alexandre Courbot <acourbot@...dia.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>,
 Danilo Krummrich <dakr@...nel.org>,
 Boris Brezillon <boris.brezillon@...labora.com>,
 Sebastian Reichel <sebastian.reichel@...labora.com>,
 Liam Girdwood <lgirdwood@...il.com>,
 Mark Brown <broonie@...nel.org>,
 linux-kernel@...r.kernel.org,
 rust-for-linux@...r.kernel.org
Subject: Re: [PATCH v4] rust: regulator: add a bare minimum regulator
 abstraction

Hi Alex,

>> +
>> +/// A voltage in microvolts.
>> +///
>> +/// The explicit type is used to avoid confusion with other multiples of the
>> +/// volt, which can be desastrous.
>> +#[repr(transparent)]
>> +#[derive(Copy, Clone, PartialEq, Eq)]
>> +pub struct Microvolt(pub i32);
> 
> This type actually contains a voltage, but is named after the unit it
> stores. A bit like if `Duration` was named `Nanoseconds`. How about just
> naming it `Voltage` and give it `from_microvolts` and `as_microvolts`
> methods? We might not need to use other units, but at least it doesn't
> close that option.

I think that not accepting anything other than microvolts is by design, and
that changing this to `Voltage` would defeat the purpose, which is to make it
crystal clear that the unit is microvolts.

Also, the places where this type is used take microvolts, so I don't see why we
should add this indirection, which would require a convertion back and forth
from volt.

By the way, I went ahead and sent a new version [0] without this change.

— Daniel

[0] https://lore.kernel.org/rust-for-linux/20250623-topics-tyr-regulator-v5-0-99069658cb54@collabora.com/T/#t



Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ