Skip to contentSkip to conversation

rust: kunit: use crate-level mapping for `c_void`

PATCH Applied Jesung Yang 2 participants 3 messages May 28, 2025 – Jun 23, 2025

Subsystems (3)
lore
Share & tools
lore
#0 lore raw

PATCH v3 1/1 rust: kunit: use crate-level mapping for `c_void`

Remove use core::ffi::c_void, which shadows kernel::ffi::c_void brought in via use crate::prelude::*, to maintain consistency and centralize the abstraction.

Since kernel::ffi::c_void is a straightforward re-export of core::ffi::c_void, both are functionally equivalent. However, using kernel::ffi::c_void improves consistency across the kernel's Rust code and provides a unified reference point in case the definition ever needs to change, even if such a change is unlikely.

---
Changes in v3:
- Rebase on a3b2347343e0
- Remove the explicit import of kernel::ffi::c_void
- Reword the commit message accordingly
- Link to v2: https://lore.kernel.org/rust-for-linux/[email protected]/

Changes in v2:
- Add "Link" tag to the related discussion on Zulip
- Reword the commit message to clarify kernel::ffi::c_void is a re-export
- Link to v1: https://lore.kernel.org/rust-for-linux/[email protected]/

---
 rust/kernel/kunit.rs | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
rust/kernel/kunit.rs +1 -1
index 4b8cdcb21e77..603330f247c7 100644
@@ -7,7 +7,7 @@
 //! Reference: <https://docs.kernel.org/dev-tools/kunit/index.html>
 
 use crate::prelude::*;
-use core::{ffi::c_void, fmt};
+use core::fmt;
 
 /// Prints a KUnit error-level message.
 ///

base-commit: a3b2347343e077e81d3c169f32c9b2cb1364f4cc

Signature · 1 line
2.39.5
Acked-by on v3 1/1
#1 lore raw
Quoted 11 lines · Jesung Yang

Remove use core::ffi::c_void, which shadows kernel::ffi::c_void brought in via use crate::prelude::*, to maintain consistency and centralize the abstraction.

Since kernel::ffi::c_void is a straightforward re-export of core::ffi::c_void, both are functionally equivalent. However, using kernel::ffi::c_void improves consistency across the kernel's Rust code and provides a unified reference point in case the definition ever needs to change, even if such a change is unlikely.

Quoted 3 lines

Looks good to me, thanks! If KUnit picks this next cycle:

Otherwise, I am happy to take it too.

Cheers,
Miguel

Applied
#2 lore raw
In reply to Jesung Yang
Quoted 11 lines · Jesung Yang

Remove use core::ffi::c_void, which shadows kernel::ffi::c_void brought in via use crate::prelude::*, to maintain consistency and centralize the abstraction.

Since kernel::ffi::c_void is a straightforward re-export of core::ffi::c_void, both are functionally equivalent. However, using kernel::ffi::c_void improves consistency across the kernel's Rust code and provides a unified reference point in case the definition ever needs to change, even if such a change is unlikely.

Quoted 3 lines

Applied to rust-next -- thanks everyone!

Cheers,
Miguel