Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix clippy warnings in components/third_party #31623

Merged
merged 1 commit into from Mar 12, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
2 changes: 0 additions & 2 deletions components/background_hang_monitor/sampler_mac.rs
Expand Up @@ -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;
Expand Down
5 changes: 1 addition & 4 deletions third_party/blurmac/src/adapter.rs
Expand Up @@ -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
Expand Down
55 changes: 25 additions & 30 deletions third_party/blurmac/src/delegate.rs
Expand Up @@ -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");
Expand Down Expand Up @@ -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(_) => {},
);
}
}
}
Expand All @@ -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(_) => {},
);
}
}
}
Expand All @@ -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(_) => {},
);
}
}
}
Expand All @@ -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(_) => {},
);
}
}
}
Expand All @@ -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(_) => {},
);
}
}
}
Expand Down Expand Up @@ -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 {
Expand Down
4 changes: 2 additions & 2 deletions third_party/blurmac/src/device.rs
Expand Up @@ -36,7 +36,7 @@ impl BluetoothDevice {

BluetoothDevice {
adapter: adapter.clone(),
peripheral: peripheral,
peripheral,
}
}

Expand All @@ -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>> {
Expand Down
4 changes: 2 additions & 2 deletions third_party/blurmac/src/gatt_characteristic.rs
Expand Up @@ -39,7 +39,7 @@ impl BluetoothGATTCharacteristic {

BluetoothGATTCharacteristic {
service: service.clone(),
characteristic: characteristic,
characteristic,
}
}

Expand All @@ -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>> {
Expand Down
4 changes: 2 additions & 2 deletions third_party/blurmac/src/gatt_service.rs
Expand Up @@ -38,7 +38,7 @@ impl BluetoothGATTService {

BluetoothGATTService {
device: device.clone(),
service: service,
service,
}
}

Expand All @@ -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>> {
Expand Down
8 changes: 4 additions & 4 deletions third_party/blurmac/src/utils.rs
Expand Up @@ -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::*;
Expand Down