Skip to content

Commit 284f189

Browse files
authored
Avoid transmute where possible (#3421)
1 parent b35dfd1 commit 284f189

File tree

289 files changed

+18161
-19584
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

289 files changed

+18161
-19584
lines changed

crates/libs/bindgen/src/types/cpp_method.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -682,14 +682,14 @@ impl CppMethod {
682682
quote! { #name.param().abi(), }
683683
}
684684
ParamHint::Optional => {
685-
quote! { core::mem::transmute(#name.unwrap_or(core::mem::zeroed())), }
685+
quote! { #name.unwrap_or(core::mem::zeroed()) as _, }
686686
}
687687
ParamHint::Bool => {
688688
quote! { #name.into(), }
689689
}
690690
ParamHint::ValueType => {
691691
if flags.contains(ParamAttributes::Out) {
692-
quote! { core::mem::transmute(#name), }
692+
quote! { #name as _, }
693693
} else {
694694
quote! { #name, }
695695
}

crates/libs/windows/src/Windows/Wdk/Devices/HumanInterfaceDevice/mod.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ pub unsafe fn VhfAsyncOperationComplete(vhfoperationhandle: *const core::ffi::c_
66
#[inline]
77
pub unsafe fn VhfCreate(vhfconfig: *const VHF_CONFIG, vhfhandle: *mut *mut core::ffi::c_void) -> super::super::super::Win32::Foundation::NTSTATUS {
88
windows_targets::link!("vhfum.dll" "system" fn VhfCreate(vhfconfig : *const VHF_CONFIG, vhfhandle : *mut *mut core::ffi::c_void) -> super::super::super::Win32::Foundation:: NTSTATUS);
9-
unsafe { VhfCreate(vhfconfig, core::mem::transmute(vhfhandle)) }
9+
unsafe { VhfCreate(vhfconfig, vhfhandle as _) }
1010
}
1111
#[inline]
1212
pub unsafe fn VhfDelete(vhfhandle: *const core::ffi::c_void, wait: bool) {

crates/libs/windows/src/Windows/Wdk/Foundation/mod.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ pub unsafe fn NtClose(handle: super::super::Win32::Foundation::HANDLE) -> super:
66
#[inline]
77
pub unsafe fn NtQueryObject(handle: Option<super::super::Win32::Foundation::HANDLE>, objectinformationclass: OBJECT_INFORMATION_CLASS, objectinformation: Option<*mut core::ffi::c_void>, objectinformationlength: u32, returnlength: Option<*mut u32>) -> super::super::Win32::Foundation::NTSTATUS {
88
windows_targets::link!("ntdll.dll" "system" fn NtQueryObject(handle : super::super::Win32::Foundation:: HANDLE, objectinformationclass : OBJECT_INFORMATION_CLASS, objectinformation : *mut core::ffi::c_void, objectinformationlength : u32, returnlength : *mut u32) -> super::super::Win32::Foundation:: NTSTATUS);
9-
unsafe { NtQueryObject(core::mem::transmute(handle.unwrap_or(core::mem::zeroed())), objectinformationclass, core::mem::transmute(objectinformation.unwrap_or(core::mem::zeroed())), objectinformationlength, core::mem::transmute(returnlength.unwrap_or(core::mem::zeroed()))) }
9+
unsafe { NtQueryObject(handle.unwrap_or(core::mem::zeroed()) as _, objectinformationclass, objectinformation.unwrap_or(core::mem::zeroed()) as _, objectinformationlength, returnlength.unwrap_or(core::mem::zeroed()) as _) }
1010
}
1111
#[repr(C)]
1212
#[cfg(all(feature = "Wdk_System_SystemServices", feature = "Win32_Security"))]

crates/libs/windows/src/Windows/Wdk/Graphics/Direct3D/mod.rs

Lines changed: 91 additions & 91 deletions
Large diffs are not rendered by default.

crates/libs/windows/src/Windows/Wdk/NetworkManagement/Ndis/mod.rs

Lines changed: 47 additions & 47 deletions
Large diffs are not rendered by default.

crates/libs/windows/src/Windows/Wdk/NetworkManagement/WindowsFilteringPlatform/mod.rs

Lines changed: 125 additions & 125 deletions
Large diffs are not rendered by default.

crates/libs/windows/src/Windows/Wdk/Storage/FileSystem/Minifilters/mod.rs

Lines changed: 174 additions & 242 deletions
Large diffs are not rendered by default.

crates/libs/windows/src/Windows/Wdk/Storage/FileSystem/mod.rs

Lines changed: 417 additions & 527 deletions
Large diffs are not rendered by default.

crates/libs/windows/src/Windows/Wdk/System/IO/mod.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,5 +2,5 @@
22
#[inline]
33
pub unsafe fn NtDeviceIoControlFile(filehandle: super::super::super::Win32::Foundation::HANDLE, event: Option<super::super::super::Win32::Foundation::HANDLE>, apcroutine: Option<super::super::super::Win32::System::IO::PIO_APC_ROUTINE>, apccontext: Option<*const core::ffi::c_void>, iostatusblock: *mut super::super::super::Win32::System::IO::IO_STATUS_BLOCK, iocontrolcode: u32, inputbuffer: Option<*const core::ffi::c_void>, inputbufferlength: u32, outputbuffer: Option<*mut core::ffi::c_void>, outputbufferlength: u32) -> super::super::super::Win32::Foundation::NTSTATUS {
44
windows_targets::link!("ntdll.dll" "system" fn NtDeviceIoControlFile(filehandle : super::super::super::Win32::Foundation:: HANDLE, event : super::super::super::Win32::Foundation:: HANDLE, apcroutine : super::super::super::Win32::System::IO:: PIO_APC_ROUTINE, apccontext : *const core::ffi::c_void, iostatusblock : *mut super::super::super::Win32::System::IO:: IO_STATUS_BLOCK, iocontrolcode : u32, inputbuffer : *const core::ffi::c_void, inputbufferlength : u32, outputbuffer : *mut core::ffi::c_void, outputbufferlength : u32) -> super::super::super::Win32::Foundation:: NTSTATUS);
5-
unsafe { NtDeviceIoControlFile(filehandle, core::mem::transmute(event.unwrap_or(core::mem::zeroed())), core::mem::transmute(apcroutine.unwrap_or(core::mem::zeroed())), core::mem::transmute(apccontext.unwrap_or(core::mem::zeroed())), core::mem::transmute(iostatusblock), iocontrolcode, core::mem::transmute(inputbuffer.unwrap_or(core::mem::zeroed())), inputbufferlength, core::mem::transmute(outputbuffer.unwrap_or(core::mem::zeroed())), outputbufferlength) }
5+
unsafe { NtDeviceIoControlFile(filehandle, event.unwrap_or(core::mem::zeroed()) as _, apcroutine.unwrap_or(core::mem::zeroed()) as _, apccontext.unwrap_or(core::mem::zeroed()) as _, iostatusblock as _, iocontrolcode, inputbuffer.unwrap_or(core::mem::zeroed()) as _, inputbufferlength, outputbuffer.unwrap_or(core::mem::zeroed()) as _, outputbufferlength) }
66
}

crates/libs/windows/src/Windows/Wdk/System/Memory/mod.rs

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,34 +1,34 @@
11
#[inline]
22
pub unsafe fn NtMapViewOfSection(sectionhandle: super::super::super::Win32::Foundation::HANDLE, processhandle: super::super::super::Win32::Foundation::HANDLE, baseaddress: *mut *mut core::ffi::c_void, zerobits: usize, commitsize: usize, sectionoffset: Option<*mut i64>, viewsize: *mut usize, inheritdisposition: SECTION_INHERIT, allocationtype: u32, win32protect: u32) -> super::super::super::Win32::Foundation::NTSTATUS {
33
windows_targets::link!("ntdll.dll" "system" fn NtMapViewOfSection(sectionhandle : super::super::super::Win32::Foundation:: HANDLE, processhandle : super::super::super::Win32::Foundation:: HANDLE, baseaddress : *mut *mut core::ffi::c_void, zerobits : usize, commitsize : usize, sectionoffset : *mut i64, viewsize : *mut usize, inheritdisposition : SECTION_INHERIT, allocationtype : u32, win32protect : u32) -> super::super::super::Win32::Foundation:: NTSTATUS);
4-
unsafe { NtMapViewOfSection(sectionhandle, processhandle, core::mem::transmute(baseaddress), zerobits, commitsize, core::mem::transmute(sectionoffset.unwrap_or(core::mem::zeroed())), core::mem::transmute(viewsize), inheritdisposition, allocationtype, win32protect) }
4+
unsafe { NtMapViewOfSection(sectionhandle, processhandle, baseaddress as _, zerobits, commitsize, sectionoffset.unwrap_or(core::mem::zeroed()) as _, viewsize as _, inheritdisposition, allocationtype, win32protect) }
55
}
66
#[cfg(all(feature = "Wdk_Foundation", feature = "Win32_Security"))]
77
#[inline]
88
pub unsafe fn NtOpenSection(sectionhandle: *mut super::super::super::Win32::Foundation::HANDLE, desiredaccess: u32, objectattributes: *const super::super::Foundation::OBJECT_ATTRIBUTES) -> super::super::super::Win32::Foundation::NTSTATUS {
99
windows_targets::link!("ntdll.dll" "system" fn NtOpenSection(sectionhandle : *mut super::super::super::Win32::Foundation:: HANDLE, desiredaccess : u32, objectattributes : *const super::super::Foundation:: OBJECT_ATTRIBUTES) -> super::super::super::Win32::Foundation:: NTSTATUS);
10-
unsafe { NtOpenSection(core::mem::transmute(sectionhandle), desiredaccess, objectattributes) }
10+
unsafe { NtOpenSection(sectionhandle as _, desiredaccess, objectattributes) }
1111
}
1212
#[inline]
1313
pub unsafe fn NtUnmapViewOfSection(processhandle: super::super::super::Win32::Foundation::HANDLE, baseaddress: Option<*const core::ffi::c_void>) -> super::super::super::Win32::Foundation::NTSTATUS {
1414
windows_targets::link!("ntdll.dll" "system" fn NtUnmapViewOfSection(processhandle : super::super::super::Win32::Foundation:: HANDLE, baseaddress : *const core::ffi::c_void) -> super::super::super::Win32::Foundation:: NTSTATUS);
15-
unsafe { NtUnmapViewOfSection(processhandle, core::mem::transmute(baseaddress.unwrap_or(core::mem::zeroed()))) }
15+
unsafe { NtUnmapViewOfSection(processhandle, baseaddress.unwrap_or(core::mem::zeroed()) as _) }
1616
}
1717
#[inline]
1818
pub unsafe fn ZwMapViewOfSection(sectionhandle: super::super::super::Win32::Foundation::HANDLE, processhandle: super::super::super::Win32::Foundation::HANDLE, baseaddress: *mut *mut core::ffi::c_void, zerobits: usize, commitsize: usize, sectionoffset: Option<*mut i64>, viewsize: *mut usize, inheritdisposition: SECTION_INHERIT, allocationtype: u32, win32protect: u32) -> super::super::super::Win32::Foundation::NTSTATUS {
1919
windows_targets::link!("ntdll.dll" "system" fn ZwMapViewOfSection(sectionhandle : super::super::super::Win32::Foundation:: HANDLE, processhandle : super::super::super::Win32::Foundation:: HANDLE, baseaddress : *mut *mut core::ffi::c_void, zerobits : usize, commitsize : usize, sectionoffset : *mut i64, viewsize : *mut usize, inheritdisposition : SECTION_INHERIT, allocationtype : u32, win32protect : u32) -> super::super::super::Win32::Foundation:: NTSTATUS);
20-
unsafe { ZwMapViewOfSection(sectionhandle, processhandle, core::mem::transmute(baseaddress), zerobits, commitsize, core::mem::transmute(sectionoffset.unwrap_or(core::mem::zeroed())), core::mem::transmute(viewsize), inheritdisposition, allocationtype, win32protect) }
20+
unsafe { ZwMapViewOfSection(sectionhandle, processhandle, baseaddress as _, zerobits, commitsize, sectionoffset.unwrap_or(core::mem::zeroed()) as _, viewsize as _, inheritdisposition, allocationtype, win32protect) }
2121
}
2222
#[cfg(all(feature = "Wdk_Foundation", feature = "Win32_Security"))]
2323
#[inline]
2424
pub unsafe fn ZwOpenSection(sectionhandle: *mut super::super::super::Win32::Foundation::HANDLE, desiredaccess: u32, objectattributes: *const super::super::Foundation::OBJECT_ATTRIBUTES) -> super::super::super::Win32::Foundation::NTSTATUS {
2525
windows_targets::link!("ntdll.dll" "system" fn ZwOpenSection(sectionhandle : *mut super::super::super::Win32::Foundation:: HANDLE, desiredaccess : u32, objectattributes : *const super::super::Foundation:: OBJECT_ATTRIBUTES) -> super::super::super::Win32::Foundation:: NTSTATUS);
26-
unsafe { ZwOpenSection(core::mem::transmute(sectionhandle), desiredaccess, objectattributes) }
26+
unsafe { ZwOpenSection(sectionhandle as _, desiredaccess, objectattributes) }
2727
}
2828
#[inline]
2929
pub unsafe fn ZwUnmapViewOfSection(processhandle: super::super::super::Win32::Foundation::HANDLE, baseaddress: Option<*const core::ffi::c_void>) -> super::super::super::Win32::Foundation::NTSTATUS {
3030
windows_targets::link!("ntdll.dll" "system" fn ZwUnmapViewOfSection(processhandle : super::super::super::Win32::Foundation:: HANDLE, baseaddress : *const core::ffi::c_void) -> super::super::super::Win32::Foundation:: NTSTATUS);
31-
unsafe { ZwUnmapViewOfSection(processhandle, core::mem::transmute(baseaddress.unwrap_or(core::mem::zeroed()))) }
31+
unsafe { ZwUnmapViewOfSection(processhandle, baseaddress.unwrap_or(core::mem::zeroed()) as _) }
3232
}
3333
#[repr(transparent)]
3434
#[derive(Clone, Copy, Debug, Default, Eq, PartialEq)]

0 commit comments

Comments
 (0)