rust-for-linux.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH v1] rust: time: Fix compile error in impl_has_hr_timer macro
@ 2025-06-06  2:05 FUJITA Tomonori
  2025-06-06 15:34 ` Miguel Ojeda
                   ` (2 more replies)
  0 siblings, 3 replies; 10+ messages in thread
From: FUJITA Tomonori @ 2025-06-06  2:05 UTC (permalink / raw)
  To: a.hindborg, alex.gaynor, ojeda
  Cc: aliceryhl, bjorn3_gh, boqun.feng, dakr, gary, lossin,
	rust-for-linux, tmgross, tamird

Fix a compile error in the `impl_has_hr_timer!` macro as follows:

error[E0599]: no method named cast_mut found for raw pointer *mut Foo in the current scope

The `container_of!` macro already returns a mutable pointer when used
in a `*mut T` context so the `.cast_mut()` method is not available.

Fixes: 74d6a606c2b3 ("rust: retain pointer mut-ness in `container_of!`")
Signed-off-by: FUJITA Tomonori <fujita.tomonori@gmail.com>
---
 rust/kernel/time/hrtimer.rs | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/rust/kernel/time/hrtimer.rs b/rust/kernel/time/hrtimer.rs
index 9df3dcd2fa39..36e1290cd079 100644
--- a/rust/kernel/time/hrtimer.rs
+++ b/rust/kernel/time/hrtimer.rs
@@ -517,7 +517,7 @@ unsafe fn timer_container_of(
             ) -> *mut Self {
                 // SAFETY: As per the safety requirement of this function, `ptr`
                 // is pointing inside a `$timer_type`.
-                unsafe { ::kernel::container_of!(ptr, $timer_type, $field).cast_mut() }
+                unsafe { ::kernel::container_of!(ptr, $timer_type, $field) }
             }
         }
     }

base-commit: e271ed52b344ac02d4581286961d0c40acc54c03
-- 
2.43.0


^ permalink raw reply related	[flat|nested] 10+ messages in thread

* Re: [PATCH v1] rust: time: Fix compile error in impl_has_hr_timer macro
  2025-06-06  2:05 [PATCH v1] rust: time: Fix compile error in impl_has_hr_timer macro FUJITA Tomonori
@ 2025-06-06 15:34 ` Miguel Ojeda
  2025-06-06 21:36   ` FUJITA Tomonori
  2025-06-08 21:26   ` Miguel Ojeda
  2025-06-06 19:34 ` Benno Lossin
  2025-06-10 19:30 ` Miguel Ojeda
  2 siblings, 2 replies; 10+ messages in thread
From: Miguel Ojeda @ 2025-06-06 15:34 UTC (permalink / raw)
  To: FUJITA Tomonori, a.hindborg
  Cc: alex.gaynor, ojeda, aliceryhl, bjorn3_gh, boqun.feng, dakr, gary,
	lossin, rust-for-linux, tmgross, tamird

On Fri, Jun 6, 2025 at 4:06 AM FUJITA Tomonori
<fujita.tomonori@gmail.com> wrote:
>
> Fix a compile error in the `impl_has_hr_timer!` macro as follows:
>
> error[E0599]: no method named cast_mut found for raw pointer *mut Foo in the current scope
>
> The `container_of!` macro already returns a mutable pointer when used
> in a `*mut T` context so the `.cast_mut()` method is not available.
>
> Fixes: 74d6a606c2b3 ("rust: retain pointer mut-ness in `container_of!`")
> Signed-off-by: FUJITA Tomonori <fujita.tomonori@gmail.com>

Ah, right, we missed this one because there is no caller yet and it is
a macro, sorry about that. So, just to confirm, the build error is
with extra code on top, right?

The Fixes tag seems right, since the code already existed back then.
We should probably backport too, even if there are no upstream users,
since there should be no downside and it is easy, so:

Cc: stable@vger.kernel.org

Thanks Tomo, I will take it as a fix then.

Cheers,
Miguel

^ permalink raw reply	[flat|nested] 10+ messages in thread

* Re: [PATCH v1] rust: time: Fix compile error in impl_has_hr_timer macro
  2025-06-06  2:05 [PATCH v1] rust: time: Fix compile error in impl_has_hr_timer macro FUJITA Tomonori
  2025-06-06 15:34 ` Miguel Ojeda
@ 2025-06-06 19:34 ` Benno Lossin
  2025-06-10 19:30 ` Miguel Ojeda
  2 siblings, 0 replies; 10+ messages in thread
From: Benno Lossin @ 2025-06-06 19:34 UTC (permalink / raw)
  To: FUJITA Tomonori, a.hindborg, alex.gaynor, ojeda
  Cc: aliceryhl, bjorn3_gh, boqun.feng, dakr, gary, rust-for-linux,
	tmgross, tamird

On Fri Jun 6, 2025 at 4:05 AM CEST, FUJITA Tomonori wrote:
> Fix a compile error in the `impl_has_hr_timer!` macro as follows:
>
> error[E0599]: no method named cast_mut found for raw pointer *mut Foo in the current scope
>
> The `container_of!` macro already returns a mutable pointer when used
> in a `*mut T` context so the `.cast_mut()` method is not available.
>
> Fixes: 74d6a606c2b3 ("rust: retain pointer mut-ness in `container_of!`")
> Signed-off-by: FUJITA Tomonori <fujita.tomonori@gmail.com>

Reviewed-by: Benno Lossin <lossin@kernel.org>

---
Cheers,
Benno

> ---
>  rust/kernel/time/hrtimer.rs | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)

^ permalink raw reply	[flat|nested] 10+ messages in thread

* Re: [PATCH v1] rust: time: Fix compile error in impl_has_hr_timer macro
  2025-06-06 15:34 ` Miguel Ojeda
@ 2025-06-06 21:36   ` FUJITA Tomonori
  2025-06-07 10:19     ` Miguel Ojeda
  2025-06-08 21:26   ` Miguel Ojeda
  1 sibling, 1 reply; 10+ messages in thread
From: FUJITA Tomonori @ 2025-06-06 21:36 UTC (permalink / raw)
  To: miguel.ojeda.sandonis
  Cc: fujita.tomonori, a.hindborg, alex.gaynor, ojeda, aliceryhl,
	bjorn3_gh, boqun.feng, dakr, gary, lossin, rust-for-linux,
	tmgross, tamird

On Fri, 6 Jun 2025 17:34:03 +0200
Miguel Ojeda <miguel.ojeda.sandonis@gmail.com> wrote:

> On Fri, Jun 6, 2025 at 4:06 AM FUJITA Tomonori
> <fujita.tomonori@gmail.com> wrote:
>>
>> Fix a compile error in the `impl_has_hr_timer!` macro as follows:
>>
>> error[E0599]: no method named cast_mut found for raw pointer *mut Foo in the current scope
>>
>> The `container_of!` macro already returns a mutable pointer when used
>> in a `*mut T` context so the `.cast_mut()` method is not available.
>>
>> Fixes: 74d6a606c2b3 ("rust: retain pointer mut-ness in `container_of!`")
>> Signed-off-by: FUJITA Tomonori <fujita.tomonori@gmail.com>
> 
> Ah, right, we missed this one because there is no caller yet and it is
> a macro, sorry about that. So, just to confirm, the build error is
> with extra code on top, right?

That's right.

> The Fixes tag seems right, since the code already existed back then.
> We should probably backport too, even if there are no upstream users,
> since there should be no downside and it is easy, so:
> 
> Cc: stable@vger.kernel.org

The commit was merged into mainline in the pull request for
v6.16. Isn't there no stable kernel version that this should be
backported to?


> Thanks Tomo, I will take it as a fix then.

Thanks!

^ permalink raw reply	[flat|nested] 10+ messages in thread

* Re: [PATCH v1] rust: time: Fix compile error in impl_has_hr_timer macro
  2025-06-06 21:36   ` FUJITA Tomonori
@ 2025-06-07 10:19     ` Miguel Ojeda
  0 siblings, 0 replies; 10+ messages in thread
From: Miguel Ojeda @ 2025-06-07 10:19 UTC (permalink / raw)
  To: FUJITA Tomonori
  Cc: a.hindborg, alex.gaynor, ojeda, aliceryhl, bjorn3_gh, boqun.feng,
	dakr, gary, lossin, rust-for-linux, tmgross, tamird

On Fri, Jun 6, 2025 at 11:36 PM FUJITA Tomonori
<fujita.tomonori@gmail.com> wrote:
>
> The commit was merged into mainline in the pull request for
> v6.16. Isn't there no stable kernel version that this should be
> backported to?

Yeah, you are right, sorry. I guess I wrote that thinking about the
hrtimer commit, not the other one.

Cheers,
Miguel

^ permalink raw reply	[flat|nested] 10+ messages in thread

* Re: [PATCH v1] rust: time: Fix compile error in impl_has_hr_timer macro
  2025-06-06 15:34 ` Miguel Ojeda
  2025-06-06 21:36   ` FUJITA Tomonori
@ 2025-06-08 21:26   ` Miguel Ojeda
  2025-06-10  7:36     ` Andreas Hindborg
  1 sibling, 1 reply; 10+ messages in thread
From: Miguel Ojeda @ 2025-06-08 21:26 UTC (permalink / raw)
  To: a.hindborg
  Cc: alex.gaynor, ojeda, aliceryhl, bjorn3_gh, boqun.feng, dakr, gary,
	lossin, rust-for-linux, tmgross, tamird, FUJITA Tomonori

On Fri, Jun 6, 2025 at 5:34 PM Miguel Ojeda
<miguel.ojeda.sandonis@gmail.com> wrote:
>
> Thanks Tomo, I will take it as a fix then.

Andreas: anything against this? (Acked-by?)

Thanks!

Cheers,
Miguel

^ permalink raw reply	[flat|nested] 10+ messages in thread

* Re: [PATCH v1] rust: time: Fix compile error in impl_has_hr_timer macro
  2025-06-08 21:26   ` Miguel Ojeda
@ 2025-06-10  7:36     ` Andreas Hindborg
  2025-06-10  9:49       ` Miguel Ojeda
  0 siblings, 1 reply; 10+ messages in thread
From: Andreas Hindborg @ 2025-06-10  7:36 UTC (permalink / raw)
  To: Miguel Ojeda
  Cc: alex.gaynor, ojeda, aliceryhl, bjorn3_gh, boqun.feng, dakr, gary,
	lossin, rust-for-linux, tmgross, tamird, FUJITA Tomonori

"Miguel Ojeda" <miguel.ojeda.sandonis@gmail.com> writes:

> On Fri, Jun 6, 2025 at 5:34 PM Miguel Ojeda
> <miguel.ojeda.sandonis@gmail.com> wrote:
>>
>> Thanks Tomo, I will take it as a fix then.
>
> Andreas: anything against this? (Acked-by?)


Acked-by: Andreas Hindborg <a.hindborg@kernel.org>

You want to take it directly in the rust fixes PR?


Best regards,
Andreas Hindborg




^ permalink raw reply	[flat|nested] 10+ messages in thread

* Re: [PATCH v1] rust: time: Fix compile error in impl_has_hr_timer macro
  2025-06-10  7:36     ` Andreas Hindborg
@ 2025-06-10  9:49       ` Miguel Ojeda
  2025-06-10 10:43         ` Andreas Hindborg
  0 siblings, 1 reply; 10+ messages in thread
From: Miguel Ojeda @ 2025-06-10  9:49 UTC (permalink / raw)
  To: Andreas Hindborg
  Cc: alex.gaynor, ojeda, aliceryhl, bjorn3_gh, boqun.feng, dakr, gary,
	lossin, rust-for-linux, tmgross, tamird, FUJITA Tomonori

On Tue, Jun 10, 2025 at 9:36 AM Andreas Hindborg <a.hindborg@kernel.org> wrote:
>
> Acked-by: Andreas Hindborg <a.hindborg@kernel.org>

Thanks!

> You want to take it directly in the rust fixes PR?

Yeah, since it is a fix, or what do you mean?

I guess there is no rush given there is no in-tree user, so you could
pick it in your -next one, but perhaps someone else wants to start
using it in another branch?

Cheers,
Miguel

^ permalink raw reply	[flat|nested] 10+ messages in thread

* Re: [PATCH v1] rust: time: Fix compile error in impl_has_hr_timer macro
  2025-06-10  9:49       ` Miguel Ojeda
@ 2025-06-10 10:43         ` Andreas Hindborg
  0 siblings, 0 replies; 10+ messages in thread
From: Andreas Hindborg @ 2025-06-10 10:43 UTC (permalink / raw)
  To: Miguel Ojeda
  Cc: alex.gaynor, ojeda, aliceryhl, bjorn3_gh, boqun.feng, dakr, gary,
	lossin, rust-for-linux, tmgross, tamird, FUJITA Tomonori

"Miguel Ojeda" <miguel.ojeda.sandonis@gmail.com> writes:

> On Tue, Jun 10, 2025 at 9:36 AM Andreas Hindborg <a.hindborg@kernel.org> wrote:
>>
>> Acked-by: Andreas Hindborg <a.hindborg@kernel.org>
>
> Thanks!
>
>> You want to take it directly in the rust fixes PR?
>
> Yeah, since it is a fix, or what do you mean?

Yes, I thought we might want to get it in for v6.16-rc2.

> I guess there is no rush given there is no in-tree user, so you could
> pick it in your -next one, but perhaps someone else wants to start
> using it in another branch?

Either way is fine, just let me know.


Best regards,
Andreas Hindborg



^ permalink raw reply	[flat|nested] 10+ messages in thread

* Re: [PATCH v1] rust: time: Fix compile error in impl_has_hr_timer macro
  2025-06-06  2:05 [PATCH v1] rust: time: Fix compile error in impl_has_hr_timer macro FUJITA Tomonori
  2025-06-06 15:34 ` Miguel Ojeda
  2025-06-06 19:34 ` Benno Lossin
@ 2025-06-10 19:30 ` Miguel Ojeda
  2 siblings, 0 replies; 10+ messages in thread
From: Miguel Ojeda @ 2025-06-10 19:30 UTC (permalink / raw)
  To: FUJITA Tomonori
  Cc: a.hindborg, alex.gaynor, ojeda, aliceryhl, bjorn3_gh, boqun.feng,
	dakr, gary, lossin, rust-for-linux, tmgross, tamird

On Fri, Jun 6, 2025 at 4:06 AM FUJITA Tomonori
<fujita.tomonori@gmail.com> wrote:
>
> Fix a compile error in the `impl_has_hr_timer!` macro as follows:
>
> error[E0599]: no method named cast_mut found for raw pointer *mut Foo in the current scope
>
> The `container_of!` macro already returns a mutable pointer when used
> in a `*mut T` context so the `.cast_mut()` method is not available.
>
> Fixes: 74d6a606c2b3 ("rust: retain pointer mut-ness in `container_of!`")
> Signed-off-by: FUJITA Tomonori <fujita.tomonori@gmail.com>

Applied to `rust-fixes`, thanks everyone!

    [ We missed this one because there is no caller yet and it is
      a macro. - Miguel ]

Cheers,
Miguel

^ permalink raw reply	[flat|nested] 10+ messages in thread

end of thread, other threads:[~2025-06-10 19:30 UTC | newest]

Thread overview: 10+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2025-06-06  2:05 [PATCH v1] rust: time: Fix compile error in impl_has_hr_timer macro FUJITA Tomonori
2025-06-06 15:34 ` Miguel Ojeda
2025-06-06 21:36   ` FUJITA Tomonori
2025-06-07 10:19     ` Miguel Ojeda
2025-06-08 21:26   ` Miguel Ojeda
2025-06-10  7:36     ` Andreas Hindborg
2025-06-10  9:49       ` Miguel Ojeda
2025-06-10 10:43         ` Andreas Hindborg
2025-06-06 19:34 ` Benno Lossin
2025-06-10 19:30 ` Miguel Ojeda

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).