Skip to content

Commit 593f673

Browse files
committed
uefi: BlockIo2: fix unidiomatic code
Unfortunately not discovered in the review.
1 parent 8ba5b7e commit 593f673

File tree

1 file changed

+21
-9
lines changed

1 file changed

+21
-9
lines changed

uefi/src/proto/media/block.rs

Lines changed: 21 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -237,7 +237,6 @@ impl BlockIO2 {
237237
/// * `media_id` - The media ID that the read request is for.
238238
/// * `lba` - The starting logical block address to read from on the device.
239239
/// * `token` - Transaction token for asynchronous read.
240-
/// * `len` - Buffer size.
241240
/// * `buffer` - The target buffer of the read operation
242241
///
243242
/// # Safety
@@ -256,12 +255,20 @@ impl BlockIO2 {
256255
media_id: u32,
257256
lba: Lba,
258257
token: Option<NonNull<BlockIO2Token>>,
259-
len: usize,
260-
buffer: *mut u8,
258+
buffer: &mut [u8],
261259
) -> Result {
262260
let token = opt_nonnull_to_ptr(token);
263-
unsafe { (self.0.read_blocks_ex)(&self.0, media_id, lba, token.cast(), len, buffer.cast()) }
264-
.to_result()
261+
unsafe {
262+
(self.0.read_blocks_ex)(
263+
&self.0,
264+
media_id,
265+
lba,
266+
token.cast(),
267+
buffer.len(),
268+
buffer.as_mut_ptr().cast(),
269+
)
270+
}
271+
.to_result()
265272
}
266273

267274
/// Writes a specified number of blocks to the device.
@@ -270,7 +277,6 @@ impl BlockIO2 {
270277
/// * `media_id` - The media ID that the write request is for.
271278
/// * `lba` - The starting logical block address to be written.
272279
/// * `token` - Transaction token for asynchronous write.
273-
/// * `len` - Buffer size.
274280
/// * `buffer` - Buffer to be written from.
275281
///
276282
/// # Safety
@@ -290,12 +296,18 @@ impl BlockIO2 {
290296
media_id: u32,
291297
lba: Lba,
292298
token: Option<NonNull<BlockIO2Token>>,
293-
len: usize,
294-
buffer: *const u8,
299+
buffer: &[u8],
295300
) -> Result {
296301
let token = opt_nonnull_to_ptr(token);
297302
unsafe {
298-
(self.0.write_blocks_ex)(&mut self.0, media_id, lba, token.cast(), len, buffer.cast())
303+
(self.0.write_blocks_ex)(
304+
&mut self.0,
305+
media_id,
306+
lba,
307+
token.cast(),
308+
buffer.len(),
309+
buffer.as_ptr().cast(),
310+
)
299311
}
300312
.to_result()
301313
}

0 commit comments

Comments
 (0)