Skip to content

Commit 06e5e98

Browse files
committed
remove unneeded code
1 parent d60cd61 commit 06e5e98

File tree

1 file changed

+4
-11
lines changed

1 file changed

+4
-11
lines changed

ForTunCli/src/device_ops.rs

Lines changed: 4 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ use std::time::Duration;
1111
use version_compare::Version;
1212
use windows::core::{wcslen, GUID, HRESULT, HSTRING, PCWSTR, PWSTR};
1313
use windows::w;
14-
use windows::Win32::Devices::DeviceAndDriverInstallation::{CM_Get_DevNode_PropertyW, CM_Get_Device_ID_ListW, CM_Get_Device_ID_List_SizeW, CM_Get_Device_Interface_ListW, CM_Get_Device_Interface_List_SizeW, CM_Locate_DevNodeW, SetupCopyOEMInfW, SetupDiSetClassInstallParamsW, CM_GETIDLIST_FILTER_CLASS, CM_GET_DEVICE_INTERFACE_LIST_ALL_DEVICES, CM_LOCATE_DEVINST_NORMAL, CM_LOCATE_DEVNODE_PHANTOM, CR_NO_SUCH_DEVNODE, CR_SUCCESS, DIF_REMOVE, DI_REMOVEDEVICE_GLOBAL, GUID_DEVCLASS_NET, HDEVINFO, SPOST_PATH, SP_CLASSINSTALL_HEADER, SP_COPY_NEWER, SP_DEVINFO_DATA, SP_REMOVEDEVICE_PARAMS, SetupDiEnumDriverInfoW};
14+
use windows::Win32::Devices::DeviceAndDriverInstallation::{CM_Get_DevNode_PropertyW, CM_Get_Device_ID_ListW, CM_Get_Device_ID_List_SizeW, CM_Get_Device_Interface_ListW, CM_Get_Device_Interface_List_SizeW, CM_Locate_DevNodeW, SetupCopyOEMInfW, SetupDiSetClassInstallParamsW, CM_GETIDLIST_FILTER_CLASS, CM_GET_DEVICE_INTERFACE_LIST_ALL_DEVICES, CM_LOCATE_DEVINST_NORMAL, CM_LOCATE_DEVNODE_PHANTOM, CR_NO_SUCH_DEVNODE, CR_SUCCESS, DIF_REMOVE, DI_REMOVEDEVICE_GLOBAL, GUID_DEVCLASS_NET, HDEVINFO, SPOST_PATH, SP_CLASSINSTALL_HEADER, SP_COPY_NEWER, SP_DEVINFO_DATA, SP_REMOVEDEVICE_PARAMS};
1515
use windows::Win32::Devices::Enumeration::Pnp::{
1616
SWDeviceCapabilitiesDriverRequired, SWDeviceCapabilitiesSilentInstall, SwDeviceClose,
1717
SwDeviceCreate, HSWDEVICE, SW_DEVICE_CREATE_INFO,
@@ -144,7 +144,7 @@ pub fn init_device<T:AsRef<Path>>(
144144
current_version > working_driver_version
145145
}).is_some();
146146
if has_old {
147-
return bail!("There is running old driver device, please stop it before running app")
147+
bail!("There is running old driver device, please stop it before running app")
148148
}
149149
}
150150

@@ -347,7 +347,7 @@ unsafe extern "system" fn creation_callback(
347347
context: *const c_void,
348348
_device_instance_id: PCWSTR,
349349
) {
350-
let mut context = &mut *(context as *mut CreateDeviceContext);
350+
let context = &mut *(context as *mut CreateDeviceContext);
351351
if _create_result.is_ok() {
352352
context.instance_id = _device_instance_id.to_string().unwrap();
353353
context.success = true;
@@ -629,9 +629,6 @@ fn enum_device(device_class_id: &GUID, hwid: &str) -> anyhow::Result<Vec<(String
629629
let device_class_id = PCWSTR(device_class_id.as_ptr());
630630

631631
let flag = CM_GETIDLIST_FILTER_CLASS;
632-
unsafe {
633-
634-
}
635632
let cr = unsafe { CM_Get_Device_ID_List_SizeW(&mut device_list_len, device_class_id, flag) };
636633

637634
if cr != CR_SUCCESS {
@@ -647,11 +644,7 @@ fn enum_device(device_class_id: &GUID, hwid: &str) -> anyhow::Result<Vec<(String
647644
}
648645

649646
let mut dev_inst: u32 = 0;
650-
let mut property_type: DEVPROPTYPE = DEVPROPTYPE::default();
651-
652647
let mut property_value: Vec<u8> = Vec::with_capacity(2048);
653-
let mut property_value_length = 0;
654-
655648
let mut index = 0;
656649
let mut device_id = PCWSTR::from_raw(buffer[index..].as_mut_ptr());
657650

@@ -710,7 +703,7 @@ fn _cm_get_string_property(dev_inst:u32, key:&DEVPROPKEY, property_value:&mut Ve
710703
dev_inst,
711704
key,
712705
&mut property_type,
713-
Some(buf.as_mut_ptr()),
706+
Some(property_value.as_mut_ptr()),
714707
&mut property_value_length,
715708
0,
716709
);

0 commit comments

Comments
 (0)