Skip to content

Commit c90dea8

Browse files
committed
drm/asahi: float: Clippy fixes
Signed-off-by: Asahi Lina <[email protected]>
1 parent f0cd458 commit c90dea8

1 file changed

Lines changed: 6 additions & 1 deletion

File tree

drivers/gpu/drm/asahi/float.rs

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,8 +27,10 @@ use kernel::{init::Zeroable, of, prelude::*};
2727

2828
/// An IEEE754-compatible floating point number implemented in software.
2929
#[derive(Default, Debug, Copy, Clone)]
30+
#[repr(transparent)]
3031
pub(crate) struct F32(u32);
3132

33+
// SAFETY: F32 is a transparent repr of `u32` and therefore zeroable
3234
unsafe impl Zeroable for F32 {}
3335

3436
#[derive(Default, Debug, Copy, Clone)]
@@ -49,7 +51,10 @@ impl F32 {
4951
// This must ONLY be used in const context. Use the `f32!{}` macro to do it safely.
5052
#[doc(hidden)]
5153
pub(crate) const fn from_f32(v: f32) -> F32 {
52-
F32(unsafe { core::mem::transmute(v) })
54+
// Replace with to_bits() after kernel Rust minreq is >= 1.83.0
55+
#[allow(clippy::transmute_float_to_int)]
56+
// SAFETY: Transmuting f32 to u32 is always safe
57+
F32(unsafe { core::mem::transmute::<f32, u32>(v) })
5358
}
5459

5560
// Convert an F32 into a `f32` value

0 commit comments

Comments
 (0)