@@ -189,24 +189,31 @@ unsafe extern "efiapi" fn disk_io2_callback(event: Event, ctx: Option<NonNull<c_
189
189
assert_eq ! ( * ptr. offset( 510 ) , 0x55 ) ;
190
190
assert_eq ! ( * ptr. offset( 511 ) , 0xaa ) ;
191
191
192
- system_table ( ) . as_ref ( ) . boot_services ( ) . close_event ( event) . unwrap ( ) ;
192
+ system_table ( )
193
+ . as_ref ( )
194
+ . boot_services ( )
195
+ . close_event ( event)
196
+ . unwrap ( ) ;
193
197
}
194
198
195
199
/// Tests raw disk I/O through the DiskIo2 protocol.
196
200
fn test_raw_disk_io2 ( handle : Handle , image : Handle , bt : & BootServices ) {
197
201
info ! ( "Testing raw disk I/O 2" ) ;
198
202
199
203
// Open the disk I/O protocol on the input handle
200
- let disk_io2 = bt
201
- . open_protocol :: < DiskIo2 > (
202
- OpenProtocolParams {
203
- handle,
204
- agent : image,
205
- controller : None ,
206
- } ,
207
- OpenProtocolAttributes :: GetProtocol ,
208
- )
209
- . expect ( "Failed to get disk I/O 2 protocol" ) ;
204
+ let disk_io2 = bt. open_protocol :: < DiskIo2 > (
205
+ OpenProtocolParams {
206
+ handle,
207
+ agent : image,
208
+ controller : None ,
209
+ } ,
210
+ OpenProtocolAttributes :: GetProtocol ,
211
+ ) ;
212
+ if disk_io2. is_err ( ) {
213
+ return ;
214
+ }
215
+
216
+ let disk_io2 = disk_io2. unwrap ( ) ;
210
217
211
218
// Allocate a temporary buffer to read into
212
219
const SIZE : usize = 512 ;
@@ -236,7 +243,7 @@ fn test_raw_disk_io2(handle: Handle, image: Handle, bt: &BootServices) {
236
243
. read_disk_raw ( 0 , 0 , & mut token, SIZE , buf)
237
244
. expect ( "Failed to read from disk" ) ;
238
245
}
239
-
246
+
240
247
info ! ( "Raw disk I/O 2 succeeded" ) ;
241
248
bt. free_pool ( buf) . unwrap ( ) ;
242
249
}
0 commit comments