File tree 3 files changed +14
-10
lines changed
3 files changed +14
-10
lines changed Original file line number Diff line number Diff line change @@ -134,26 +134,26 @@ compat_fn_with_fallback! {
134
134
// >= Win10 1607
135
135
// https://docs.microsoft.com/en-us/windows/win32/api/processthreadsapi/nf-processthreadsapi-setthreaddescription
136
136
pub fn SetThreadDescription ( hthread: HANDLE , lpthreaddescription: PCWSTR ) -> HRESULT {
137
- SetLastError ( ERROR_CALL_NOT_IMPLEMENTED as u32 ) ; E_NOTIMPL
137
+ unsafe { SetLastError ( ERROR_CALL_NOT_IMPLEMENTED as u32 ) ; E_NOTIMPL }
138
138
}
139
139
140
140
// >= Win10 1607
141
141
// https://docs.microsoft.com/en-us/windows/win32/api/processthreadsapi/nf-processthreadsapi-getthreaddescription
142
142
pub fn GetThreadDescription ( hthread: HANDLE , lpthreaddescription: * mut PWSTR ) -> HRESULT {
143
- SetLastError ( ERROR_CALL_NOT_IMPLEMENTED as u32 ) ; E_NOTIMPL
143
+ unsafe { SetLastError ( ERROR_CALL_NOT_IMPLEMENTED as u32 ) ; E_NOTIMPL }
144
144
}
145
145
146
146
// >= Win8 / Server 2012
147
147
// https://docs.microsoft.com/en-us/windows/win32/api/sysinfoapi/nf-sysinfoapi-getsystemtimepreciseasfiletime
148
148
#[ cfg( target_vendor = "win7" ) ]
149
149
pub fn GetSystemTimePreciseAsFileTime ( lpsystemtimeasfiletime: * mut FILETIME ) -> ( ) {
150
- GetSystemTimeAsFileTime ( lpsystemtimeasfiletime)
150
+ unsafe { GetSystemTimeAsFileTime ( lpsystemtimeasfiletime) }
151
151
}
152
152
153
153
// >= Win11 / Server 2022
154
154
// https://docs.microsoft.com/en-us/windows/win32/api/fileapi/nf-fileapi-gettemppath2a
155
155
pub fn GetTempPath2W ( bufferlength: u32 , buffer: PWSTR ) -> u32 {
156
- GetTempPathW ( bufferlength, buffer)
156
+ unsafe { GetTempPathW ( bufferlength, buffer) }
157
157
}
158
158
}
159
159
Original file line number Diff line number Diff line change @@ -158,8 +158,10 @@ macro_rules! compat_fn_with_fallback {
158
158
static PTR : AtomicPtr <c_void> = AtomicPtr :: new( load as * mut _) ;
159
159
160
160
unsafe extern "system" fn load( $( $argname: $argtype) ,* ) -> $rettype {
161
- let func = load_from_module( Module :: new( $module) ) ;
162
- func( $( $argname) ,* )
161
+ unsafe {
162
+ let func = load_from_module( Module :: new( $module) ) ;
163
+ func( $( $argname) ,* )
164
+ }
163
165
}
164
166
165
167
fn load_from_module( module: Option <Module >) -> F {
@@ -182,8 +184,10 @@ macro_rules! compat_fn_with_fallback {
182
184
183
185
#[ inline( always) ]
184
186
pub unsafe fn call( $( $argname: $argtype) ,* ) -> $rettype {
185
- let func: F = mem:: transmute( PTR . load( Ordering :: Relaxed ) ) ;
186
- func( $( $argname) ,* )
187
+ unsafe {
188
+ let func: F = mem:: transmute( PTR . load( Ordering :: Relaxed ) ) ;
189
+ func( $( $argname) ,* )
190
+ }
187
191
}
188
192
}
189
193
#[ allow( unused) ]
@@ -225,7 +229,7 @@ macro_rules! compat_fn_optional {
225
229
}
226
230
#[ inline]
227
231
pub unsafe extern "system" fn $symbol( $( $argname: $argtype) ,* ) $( -> $rettype) ? {
228
- $symbol:: option( ) . unwrap( ) ( $( $argname) ,* )
232
+ unsafe { $symbol:: option( ) . unwrap( ) ( $( $argname) ,* ) }
229
233
}
230
234
) +
231
235
)
Original file line number Diff line number Diff line change 1
1
#![ allow( missing_docs, nonstandard_style) ]
2
- #![ deny ( unsafe_op_in_unsafe_fn) ]
2
+ #![ forbid ( unsafe_op_in_unsafe_fn) ]
3
3
4
4
use crate :: ffi:: { OsStr , OsString } ;
5
5
use crate :: io:: ErrorKind ;
You can’t perform that action at this time.
0 commit comments