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

Enforce rustfmt on CI #22126

Merged
merged 6 commits into from Nov 7, 2018
Merged
Changes from all commits
Commits
File filter...
Filter file types
Jump to…
The table of contents is too big for display.

Always

Just for now

@@ -4,6 +4,9 @@ matrix:
fast_finish: true
include:
- sudo: false
before_install:
- curl https://sh.rustup.rs -sSf | sh -s -- --default-toolchain none -y
- source ~/.profile
script:
- ./mach test-tidy --no-progress --all
- ./mach test-tidy --no-progress --self-test
@@ -23,38 +23,30 @@ mod platform {

/// Memory allocation APIs compatible with libc
pub mod libc_compat {
pub use super::ffi::{malloc, realloc, free};
pub use super::ffi::{free, malloc, realloc};
}

pub struct Allocator;

// The minimum alignment guaranteed by the architecture. This value is used to
// add fast paths for low alignment values.
#[cfg(
all(
any(
target_arch = "arm",
target_arch = "mips",
target_arch = "mipsel",
target_arch = "powerpc"
)
)
)]
#[cfg(all(any(
target_arch = "arm",
target_arch = "mips",
target_arch = "mipsel",
target_arch = "powerpc"
)))]
const MIN_ALIGN: usize = 8;
#[cfg(
all(
any(
target_arch = "x86",
target_arch = "x86_64",
target_arch = "aarch64",
target_arch = "powerpc64",
target_arch = "powerpc64le",
target_arch = "mips64",
target_arch = "s390x",
target_arch = "sparc64"
)
)
)]
#[cfg(all(any(
target_arch = "x86",
target_arch = "x86_64",
target_arch = "aarch64",
target_arch = "powerpc64",
target_arch = "powerpc64le",
target_arch = "mips64",
target_arch = "s390x",
target_arch = "sparc64"
)))]
const MIN_ALIGN: usize = 16;

fn layout_to_flags(align: usize, size: usize) -> c_int {
@@ -106,8 +98,8 @@ mod platform {
mod platform {
extern crate kernel32;

pub use std::alloc::System as Allocator;
use self::kernel32::{GetProcessHeap, HeapSize, HeapValidate};
pub use std::alloc::System as Allocator;
use std::os::raw::c_void;

/// Get the size of a heap block.
@@ -6,7 +6,7 @@ extern crate string_cache_codegen;

use std::env;
use std::fs::File;
use std::io::{BufReader, BufRead};
use std::io::{BufRead, BufReader};
use std::path::Path;

fn main() {
@@ -16,11 +16,13 @@ extern crate uuid;

pub mod test;

use bluetooth_traits::blocklist::{uuid_is_blocklisted, Blocklist};
use bluetooth_traits::scanfilter::{
BluetoothScanfilter, BluetoothScanfilterSequence, RequestDeviceoptions,
};
use bluetooth_traits::{BluetoothCharacteristicMsg, BluetoothDescriptorMsg, BluetoothServiceMsg};
use bluetooth_traits::{BluetoothDeviceMsg, BluetoothRequest, BluetoothResponse, GATTType};
use bluetooth_traits::{BluetoothError, BluetoothResponseResult, BluetoothResult};
use bluetooth_traits::blocklist::{uuid_is_blocklisted, Blocklist};
use bluetooth_traits::scanfilter::{BluetoothScanfilter, BluetoothScanfilterSequence, RequestDeviceoptions};
use device::bluetooth::{BluetoothAdapter, BluetoothDevice, BluetoothGATTCharacteristic};
use device::bluetooth::{BluetoothGATTDescriptor, BluetoothGATTService};
use embedder_traits::{EmbedderMsg, EmbedderProxy};
@@ -74,7 +76,8 @@ impl BluetoothThreadFactory for IpcSender<BluetoothRequest> {
BluetoothAdapter::init()
} else {
BluetoothAdapter::init_mock()
}.ok();
}
.ok();
thread::Builder::new()
.name("BluetoothThread".to_owned())
.spawn(move || {
@@ -465,8 +468,10 @@ impl BluetoothManager {
};

services.retain(|s| {
!uuid_is_blocklisted(&s.get_uuid().unwrap_or(String::new()), Blocklist::All) &&
self.allowed_services.get(device_id).map_or(false, |uuids| {
!uuid_is_blocklisted(&s.get_uuid().unwrap_or(String::new()), Blocklist::All) && self
.allowed_services
.get(device_id)
.map_or(false, |uuids| {
uuids.contains(&s.get_uuid().unwrap_or(String::new()))
})
});
@@ -556,9 +561,9 @@ impl BluetoothManager {
}

fn characteristic_is_cached(&self, characteristic_id: &str) -> bool {
self.cached_characteristics.contains_key(characteristic_id) &&
self.characteristic_to_service
.contains_key(characteristic_id)
self.cached_characteristics.contains_key(characteristic_id) && self
.characteristic_to_service
.contains_key(characteristic_id)
}

// Descriptor
@@ -4,10 +4,12 @@

use crate::BluetoothManager;
use device::bluetooth::{BluetoothAdapter, BluetoothDevice};
use device::bluetooth::{BluetoothGATTCharacteristic, BluetoothGATTDescriptor, BluetoothGATTService};
use device::bluetooth::{
BluetoothGATTCharacteristic, BluetoothGATTDescriptor, BluetoothGATTService,
};
use std::borrow::ToOwned;
use std::cell::RefCell;
use std::collections::{HashSet, HashMap};
use std::collections::{HashMap, HashSet};
use std::error::Error;
use std::string::String;
use uuid::Uuid;
@@ -294,14 +296,16 @@ fn create_generic_access_service(
NUMBER_OF_DIGITALS_UUID.to_owned(),
vec![49],
)?;
number_of_digitals_descriptor_1.set_flags(vec![READ_FLAG.to_string(), WRITE_FLAG.to_string()])?;
number_of_digitals_descriptor_1
.set_flags(vec![READ_FLAG.to_string(), WRITE_FLAG.to_string()])?;

let number_of_digitals_descriptor_2 = create_descriptor_with_value(
&device_name_characteristic,
NUMBER_OF_DIGITALS_UUID.to_owned(),
vec![50],
)?;
number_of_digitals_descriptor_2.set_flags(vec![READ_FLAG.to_string(), WRITE_FLAG.to_string()])?;
number_of_digitals_descriptor_2
.set_flags(vec![READ_FLAG.to_string(), WRITE_FLAG.to_string()])?;

// Characteristic User Description Descriptor
let _characteristic_user_description = create_descriptor_with_value(
ProTip! Use n and p to navigate between commits in a pull request.
You can’t perform that action at this time.