@@ -192,7 +192,7 @@ impl Handle {
192192 }
193193
194194 pub fn write ( & self , buf : & [ u8 ] ) -> io:: Result < usize > {
195- unsafe { self . synchronous_write ( & buf, None ) }
195+ self . synchronous_write ( & buf, None )
196196 }
197197
198198 pub fn write_vectored ( & self , bufs : & [ IoSlice < ' _ > ] ) -> io:: Result < usize > {
@@ -205,7 +205,7 @@ impl Handle {
205205 }
206206
207207 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) )
209209 }
210210
211211 pub fn try_clone ( & self ) -> io:: Result < Self > {
@@ -276,25 +276,27 @@ impl Handle {
276276 /// See #81357.
277277 ///
278278 /// 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 > {
280280 let mut io_status = c:: IO_STATUS_BLOCK :: default ( ) ;
281281
282282 // The length is clamped at u32::MAX.
283283 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+ } ;
295297 match status {
296298 // 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
298300 // written to after this function returns.
299301 c:: STATUS_PENDING => {
300302 eprintln ! ( "I/O error: operation failed to complete synchronously" ) ;
@@ -305,7 +307,7 @@ impl Handle {
305307 status if c:: nt_success ( status) => Ok ( io_status. Information ) ,
306308
307309 status => {
308- let error = c:: RtlNtStatusToDosError ( status) ;
310+ let error = unsafe { c:: RtlNtStatusToDosError ( status) } ;
309311 Err ( io:: Error :: from_raw_os_error ( error as _ ) )
310312 }
311313 }
0 commit comments