From bf489e80379a8271e39ed27f2df3bbb370313157 Mon Sep 17 00:00:00 2001 From: Yuval Adam <_@yuv.al> Date: Sat, 28 Jul 2018 11:35:59 +0300 Subject: Cleanup warnings --- src/lib.rs | 13 +++++-------- 1 file changed, 5 insertions(+), 8 deletions(-) diff --git a/src/lib.rs b/src/lib.rs index d9b178f..9ec7734 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -17,7 +17,6 @@ pub struct RtlSdr<'a> { ctx: &'a libusb::Context, dev: Option>, iface_id: u8, - iface: Option> } impl<'a> RtlSdr<'a> { @@ -27,15 +26,14 @@ impl<'a> RtlSdr<'a> { ctx, dev: None, iface_id: INTERFACE_ID, - iface: None } } pub fn init(&mut self) { - self.dev = self.find_device(); + self.find_device(); } - fn write_reg(&self, handle: &libusb::DeviceHandle, block: u16, addr: u16, val: u8, len: u8) -> usize { + fn write_reg(&self, handle: &libusb::DeviceHandle, block: u16, addr: u16, val: u8, _len: u8) -> usize { let vendor_out = libusb::request_type(Direction::Out, RequestType::Vendor, Recipient::Device); let mut data: [u8; 2] = [0, 0]; let index: u16 = (block << 8) | 0x10; @@ -49,7 +47,7 @@ impl<'a> RtlSdr<'a> { } } - pub fn find_device(&self) -> Option> { + pub fn find_device(&mut self) { for mut dev in self.ctx.devices().unwrap().iter() { let desc = dev.device_descriptor().unwrap(); let vid = desc.vendor_id(); @@ -67,7 +65,7 @@ impl<'a> RtlSdr<'a> { _ => false }; - let iface = handle.claim_interface(self.iface_id).unwrap(); + let _iface = handle.claim_interface(self.iface_id).unwrap(); let res = self.write_reg(&handle, BLOCK_USBB, ADDR_USB_SYSCTL, 0x09, 1); println!("Got {}", res); @@ -76,11 +74,10 @@ impl<'a> RtlSdr<'a> { handle.attach_kernel_driver(self.iface_id).ok(); } - return Some(handle) + self.dev = Some(handle); } } } - None } } -- cgit v1.3.1