Fix clippy warnings in components/third_party (#31623)

This commit is contained in:
Mucha Naibei 2024-03-12 20:17:23 +03:00 committed by GitHub
parent 59d89c8267
commit 4efebf1e62
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
7 changed files with 36 additions and 46 deletions

View file

@ -4,8 +4,6 @@
use std::{panic, process};
use {libc, mach2};
use crate::sampler::{Address, NativeStack, Registers, Sampler};
type MonitoredThreadId = mach2::mach_types::thread_act_t;

View file

@ -28,10 +28,7 @@ impl BluetoothAdapter {
trace!("BluetoothAdapter::init");
let delegate = bm::delegate();
let manager = cb::centralmanager(delegate);
let adapter = BluetoothAdapter {
manager: manager,
delegate: delegate,
};
let adapter = BluetoothAdapter { manager, delegate };
// NOTE: start discovery at once, servo leaves close to no time to do a proper discovery
// in a BluetoothDiscoverySession

View file

@ -18,7 +18,7 @@ pub mod bm {
// BlurMacDelegate : CBCentralManagerDelegate, CBPeripheralDelegate
const DELEGATE_PERIPHERALS_IVAR: &'static str = "_peripherals";
const DELEGATE_PERIPHERALS_IVAR: &str = "_peripherals";
fn delegate_class() -> &'static Class {
trace!("delegate_class");
@ -181,13 +181,12 @@ pub mod bm {
}
// Notify BluetoothDevice::get_gatt_services that discovery was successful.
match bmx::peripheralevents(delegate, peripheral) {
Ok(events) => ns::mutabledictionary_setobject_forkey(
if let Ok(events) = bmx::peripheralevents(delegate, peripheral) {
ns::mutabledictionary_setobject_forkey(
events,
wait::now(),
nsx::string_from_str(PERIPHERALEVENT_SERVICESDISCOVEREDKEY),
),
Err(_) => {},
);
}
}
}
@ -213,13 +212,12 @@ pub mod bm {
}
// Notify BluetoothGATTService::get_includes that discovery was successful.
match bmx::peripheralevents(delegate, peripheral) {
Ok(events) => ns::mutabledictionary_setobject_forkey(
if let Ok(events) = bmx::peripheralevents(delegate, peripheral) {
ns::mutabledictionary_setobject_forkey(
events,
wait::now(),
bmx::includedservicesdiscoveredkey(service),
),
Err(_) => {},
);
}
}
}
@ -245,13 +243,12 @@ pub mod bm {
}
// Notify BluetoothGATTService::get_gatt_characteristics that discovery was successful.
match bmx::peripheralevents(delegate, peripheral) {
Ok(events) => ns::mutabledictionary_setobject_forkey(
if let Ok(events) = bmx::peripheralevents(delegate, peripheral) {
ns::mutabledictionary_setobject_forkey(
events,
wait::now(),
bmx::characteristicsdiscoveredkey(service),
),
Err(_) => {},
);
}
}
}
@ -271,13 +268,12 @@ pub mod bm {
);
if error == nil {
// Notify BluetoothGATTCharacteristic::read_value that read was successful.
match bmx::peripheralevents(delegate, peripheral) {
Ok(events) => ns::mutabledictionary_setobject_forkey(
if let Ok(events) = bmx::peripheralevents(delegate, peripheral) {
ns::mutabledictionary_setobject_forkey(
events,
wait::now(),
bmx::valueupdatedkey(characteristic),
),
Err(_) => {},
);
}
}
}
@ -297,13 +293,12 @@ pub mod bm {
);
if error == nil {
// Notify BluetoothGATTCharacteristic::write_value that write was successful.
match bmx::peripheralevents(delegate, peripheral) {
Ok(events) => ns::mutabledictionary_setobject_forkey(
if let Ok(events) = bmx::peripheralevents(delegate, peripheral) {
ns::mutabledictionary_setobject_forkey(
events,
wait::now(),
bmx::valuewrittenkey(characteristic),
),
Err(_) => {},
);
}
}
}
@ -368,16 +363,16 @@ pub mod bm {
// "BlurMacPeripheralData" = NSMutableDictionary<NSString*, id>
pub const PERIPHERALDATA_PERIPHERALKEY: &'static str = "peripheral";
pub const PERIPHERALDATA_RSSIKEY: &'static str = "rssi";
pub const PERIPHERALDATA_UUIDSKEY: &'static str = "uuids";
pub const PERIPHERALDATA_EVENTSKEY: &'static str = "events";
pub const PERIPHERALDATA_PERIPHERALKEY: &str = "peripheral";
pub const PERIPHERALDATA_RSSIKEY: &str = "rssi";
pub const PERIPHERALDATA_UUIDSKEY: &str = "uuids";
pub const PERIPHERALDATA_EVENTSKEY: &str = "events";
pub const PERIPHERALEVENT_SERVICESDISCOVEREDKEY: &'static str = "services";
pub const PERIPHERALEVENT_INCLUDEDSERVICESDISCOVEREDKEYSUFFIX: &'static str = ":includes";
pub const PERIPHERALEVENT_CHARACTERISTICSDISCOVEREDKEYSUFFIX: &'static str = ":characteristics";
pub const PERIPHERALEVENT_VALUEUPDATEDKEYSUFFIX: &'static str = ":updated";
pub const PERIPHERALEVENT_VALUEWRITTENKEYSUFFIX: &'static str = ":written";
pub const PERIPHERALEVENT_SERVICESDISCOVEREDKEY: &str = "services";
pub const PERIPHERALEVENT_INCLUDEDSERVICESDISCOVEREDKEYSUFFIX: &str = ":includes";
pub const PERIPHERALEVENT_CHARACTERISTICSDISCOVEREDKEYSUFFIX: &str = ":characteristics";
pub const PERIPHERALEVENT_VALUEUPDATEDKEYSUFFIX: &str = ":updated";
pub const PERIPHERALEVENT_VALUEWRITTENKEYSUFFIX: &str = ":written";
}
pub mod bmx {

View file

@ -36,7 +36,7 @@ impl BluetoothDevice {
BluetoothDevice {
adapter: adapter.clone(),
peripheral: peripheral,
peripheral,
}
}
@ -58,7 +58,7 @@ impl BluetoothDevice {
pub fn get_id(&self) -> String {
trace!("BluetoothDevice::get_id -> get_address");
self.get_address().unwrap_or(String::new())
self.get_address().unwrap_or_default()
}
pub fn get_address(&self) -> Result<String, Box<dyn Error>> {

View file

@ -39,7 +39,7 @@ impl BluetoothGATTCharacteristic {
BluetoothGATTCharacteristic {
service: service.clone(),
characteristic: characteristic,
characteristic,
}
}
@ -58,7 +58,7 @@ impl BluetoothGATTCharacteristic {
pub fn get_id(&self) -> String {
trace!("BluetoothGATTCharacteristic::get_id");
self.get_uuid().unwrap_or(String::new())
self.get_uuid().unwrap_or_default()
}
pub fn get_uuid(&self) -> Result<String, Box<dyn Error>> {

View file

@ -38,7 +38,7 @@ impl BluetoothGATTService {
BluetoothGATTService {
device: device.clone(),
service: service,
service,
}
}
@ -59,7 +59,7 @@ impl BluetoothGATTService {
pub fn get_id(&self) -> String {
trace!("BluetoothGATTService::get_id");
self.get_uuid().unwrap_or(String::new())
self.get_uuid().unwrap_or_default()
}
pub fn get_uuid(&self) -> Result<String, Box<dyn Error>> {

View file

@ -13,10 +13,10 @@ use std::{thread, time};
use framework::{cb, nil, ns};
use objc::runtime::Object;
pub const NOT_SUPPORTED_ERROR: &'static str = "Error! Not supported by blurmac!";
pub const NO_PERIPHERAL_FOUND: &'static str = "Error! No peripheral found!";
pub const NO_SERVICE_FOUND: &'static str = "Error! No service found!";
pub const NO_CHARACTERISTIC_FOUND: &'static str = "Error! No characteristic found!";
pub const NOT_SUPPORTED_ERROR: &str = "Error! Not supported by blurmac!";
pub const NO_PERIPHERAL_FOUND: &str = "Error! No peripheral found!";
pub const NO_SERVICE_FOUND: &str = "Error! No service found!";
pub const NO_CHARACTERISTIC_FOUND: &str = "Error! No characteristic found!";
pub mod nsx {
use super::*;