@@ -192,7 +192,7 @@ impl Handle {
192
192
}
193
193
194
194
pub fn write ( & self , buf : & [ u8 ] ) -> io:: Result < usize > {
195
- unsafe { self . synchronous_write ( & buf, None ) }
195
+ self . synchronous_write ( & buf, None )
196
196
}
197
197
198
198
pub fn write_vectored ( & self , bufs : & [ IoSlice < ' _ > ] ) -> io:: Result < usize > {
@@ -205,7 +205,7 @@ impl Handle {
205
205
}
206
206
207
207
pub fn write_at ( & self , buf : & [ u8 ] , offset : u64 ) -> io:: Result < usize > {
208
- unsafe { self . synchronous_write ( & buf, Some ( offset) ) }
208
+ self . synchronous_write ( & buf, Some ( offset) )
209
209
}
210
210
211
211
pub fn try_clone ( & self ) -> io:: Result < Self > {
@@ -276,25 +276,27 @@ impl Handle {
276
276
/// See #81357.
277
277
///
278
278
/// If `offset` is `None` then the current file position is used.
279
- unsafe fn synchronous_write ( & self , buf : & [ u8 ] , offset : Option < u64 > ) -> io:: Result < usize > {
279
+ fn synchronous_write ( & self , buf : & [ u8 ] , offset : Option < u64 > ) -> io:: Result < usize > {
280
280
let mut io_status = c:: IO_STATUS_BLOCK :: default ( ) ;
281
281
282
282
// The length is clamped at u32::MAX.
283
283
let len = cmp:: min ( buf. len ( ) , c:: DWORD :: MAX as usize ) as c:: DWORD ;
284
- let status = c:: NtWriteFile (
285
- self . as_handle ( ) ,
286
- ptr:: null_mut ( ) ,
287
- None ,
288
- ptr:: null_mut ( ) ,
289
- & mut io_status,
290
- buf. as_ptr ( ) ,
291
- len,
292
- offset. map ( |n| n as _ ) . as_ref ( ) ,
293
- None ,
294
- ) ;
284
+ let status = unsafe {
285
+ c:: NtWriteFile (
286
+ self . as_handle ( ) ,
287
+ ptr:: null_mut ( ) ,
288
+ None ,
289
+ ptr:: null_mut ( ) ,
290
+ & mut io_status,
291
+ buf. as_ptr ( ) ,
292
+ len,
293
+ offset. map ( |n| n as _ ) . as_ref ( ) ,
294
+ None ,
295
+ )
296
+ } ;
295
297
match status {
296
298
// If the operation has not completed then abort the process.
297
- // Doing otherwise means that the buffer maybe read and the stack
299
+ // Doing otherwise means that the buffer may be read and the stack
298
300
// written to after this function returns.
299
301
c:: STATUS_PENDING => {
300
302
eprintln ! ( "I/O error: operation failed to complete synchronously" ) ;
@@ -305,7 +307,7 @@ impl Handle {
305
307
status if c:: nt_success ( status) => Ok ( io_status. Information ) ,
306
308
307
309
status => {
308
- let error = c:: RtlNtStatusToDosError ( status) ;
310
+ let error = unsafe { c:: RtlNtStatusToDosError ( status) } ;
309
311
Err ( io:: Error :: from_raw_os_error ( error as _ ) )
310
312
}
311
313
}
0 commit comments