rust: cpumask: Mark CpumaskVar as transparent
Subsystems (3)
PATCH 1/1 rust: cpumask: Mark CpumaskVar as transparent
Unsafe code in CpumaskVar's methods assumes that the type has the same layout as bindings::cpumask_var_t. This is not guaranteed by the default struct representation in Rust, but requires specifying the transparent representation.
--- rust/kernel/cpumask.rs | 1 + 1 file changed, 1 insertion(+)
rust/kernel/cpumask.rs +1 -0
@@ -212,6 +212,7 @@ pub fn copy(&self, dstp: &mut Self) {/// } /// assert_eq!(mask2.weight(), count); /// ``` +#[repr(transparent)] pub struct CpumaskVar {#[cfg( CONFIG_CPUMASK_OFFSTACK )] ptr:NonNull <Cpumask >,
Signature · 1 line
2.43.0
Quoted 9 lines · Baptiste Lepers
Unsafe code in CpumaskVar's methods assumes that the type has the same layout as
bindings::cpumask_var_t. This is not guaranteed by the default struct representation in Rust, but requires specifying thetransparentrepresentation.Fixes 8961b8cb3099a ("rust: cpumask: Add initial abstractions")Signed-off-by Baptiste Lepers <[email protected]>
Only during CONFIG_CPUMASK_OFFSTACK=n, but yes.
Quoted 11 lines · Baptiste Lepers
Unsafe code in CpumaskVar's methods assumes that the type has the same layout as
bindings::cpumask_var_t. This is not guaranteed by the default struct representation in Rust, but requires specifying thetransparentrepresentation.Fixes 8961b8cb3099a ("rust: cpumask: Add initial abstractions")Signed-off-by Baptiste Lepers <[email protected]>--- rust/kernel/cpumask.rs | 1 + 1 file changed, 1 insertion(+)
Applied. Thanks.
Signature · 1 line
viresh