[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <20250225105425.ooqvefiae5bmr723@vireshk-i7>
Date: Tue, 25 Feb 2025 16:24:25 +0530
From: Viresh Kumar <viresh.kumar@...aro.org>
To: Alice Ryhl <aliceryhl@...gle.com>
Cc: Yury Norov <yury.norov@...il.com>,
Rasmus Villemoes <linux@...musvillemoes.dk>,
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>,
Trevor Gross <tmgross@...ch.edu>, linux-kernel@...r.kernel.org,
Danilo Krummrich <dakr@...hat.com>, rust-for-linux@...r.kernel.org,
Vincent Guittot <vincent.guittot@...aro.org>
Subject: Re: [PATCH 1/2] rust: Add initial cpumask abstractions
On 25-02-25, 10:55, Alice Ryhl wrote:
> On Tue, Feb 25, 2025 at 10:47 AM Viresh Kumar <viresh.kumar@...aro.org> wrote:
> > +impl Drop for Cpumask {
> > + fn drop(&mut self) {
> > + if self.owned {
> > + // SAFETY: `ptr` is guaranteed to be valid for the lifetime of `self`. And it is safe
> > + // to call `free_cpumask_var()`.
> > + unsafe { bindings::free_cpumask_var(self.ptr) }
>
> This is missing a semicolon, but it's not the last statement in the
> block. Did you compile this with CPUMASK_OFFSTACK=n? I don't think it
> compiles with that setting.
I would always add a semicolon here, yeah I missed adding that but ..
I have missed minor things before sending a series a few times in the
past and this one really scared me thinking here I did it again :)
Though I was sure that I have built the code with both
CPUMASK_OFFSTACK=y and =n, I performed the builds again and it worked
(again). That confused me even more :)
And here is what I think is happening here (which makes it build fine
accidentally):
- free_cpumask_var() has a return type of void.
- The block {} allows it to build fine without a semicolon here.
- I performed a simple test for this [1] and it works too.
> > + #[cfg(not(CONFIG_CPUMASK_OFFSTACK))]
> > + // SAFETY: The pointer was earlier initialized from the result of `KBox::into_raw()`.
> > + unsafe {
> > + drop(KBox::from_raw(self.ptr))
> > + };
>
> This looks like you did not run rustfmt.
I did this:
make CLIPPY=1 rustfmtcheck ARCH=arm64 O=../barm64t/ -j8 CROSS_COMPILE=aarch64-linux-gnu- CONFIG_DEBUG_SECTION_MISMATCH=y
I hope that is all I need ? I checked again with both CONFIG options,
doesn't complain with rustc 1.84.1.
--
viresh
[1] https://play.rust-lang.org/?version=stable&mode=debug&edition=2024&gist=70cd7d31633d98774a088fed68ebb00d
Powered by blists - more mailing lists