Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit db43627

Browse files
committed
uefi: fix clippy::as_ptr_cast_mut in gop
We can't use `as_mut_ptr()` as the underlying buffer is only readable. As we know the operation is only reading from the buffer, this is safe.
1 parent 031f2c6 commit db43627

File tree

2 files changed

+8
-4
lines changed

2 files changed

+8
-4
lines changed

‎uefi-raw/src/protocol/console.rs‎

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -161,6 +161,8 @@ pub struct GraphicsOutputProtocol {
161161
pub set_mode: unsafe extern "efiapi" fn(*mut Self, mode_number: u32) -> Status,
162162
pub blt: unsafe extern "efiapi" fn(
163163
*mut Self,
164+
// Depending on `blt_operation`, this is an IN parameter (readable)
165+
// or an OUT parameter (writeable).
164166
blt_buffer: *mut GraphicsOutputBltPixel,
165167
blt_operation: GraphicsOutputBltOperation,
166168
source_x: usize,

‎uefi/src/proto/console/gop.rs‎

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -59,8 +59,8 @@ use core::fmt::{Debug, Formatter};
5959
use core::marker::PhantomData;
6060
use core::ptr::{self, NonNull};
6161
use uefi_raw::protocol::console::{
62-
GraphicsOutputBltOperation, GraphicsOutputModeInformation,GraphicsOutputProtocol,
63-
GraphicsOutputProtocolMode,
62+
GraphicsOutputBltOperation, GraphicsOutputBltPixel,GraphicsOutputModeInformation,
63+
GraphicsOutputProtocol,GraphicsOutputProtocolMode,
6464
};
6565

6666
pub use uefi_raw::protocol::console::PixelBitmask;
@@ -201,7 +201,8 @@ impl GraphicsOutput {
201201
match src_region {
202202
BltRegion::Full => (self.0.blt)(
203203
&mut self.0,
204-
buffer.as_ptr() as *mut _,
204+
// SAFETY: The buffer is only used for reading.
205+
buffer.as_ptr().cast::<GraphicsOutputBltPixel>().cast_mut(),
205206
GraphicsOutputBltOperation::BLT_BUFFER_TO_VIDEO,
206207
0,
207208
0,
@@ -217,7 +218,8 @@ impl GraphicsOutput {
217218
px_stride,
218219
} => (self.0.blt)(
219220
&mut self.0,
220-
buffer.as_ptr() as *mut _,
221+
// SAFETY: The buffer is only used for reading.
222+
buffer.as_ptr().cast::<GraphicsOutputBltPixel>().cast_mut(),
221223
GraphicsOutputBltOperation::BLT_BUFFER_TO_VIDEO,
222224
src_x,
223225
src_y,

0 commit comments

Comments
(0)

AltStyle によって変換されたページ (->オリジナル) /