Skip to content

Commit 5ae842d

Browse files
committed
opt: optee-utee: format files
1 parent fac9759 commit 5ae842d

File tree

18 files changed

+106
-127
lines changed

18 files changed

+106
-127
lines changed

optee-utee/optee-utee-sys/src/tee_isocket.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,7 @@ pub struct TEE_iSocket_s {
5454
}
5555

5656
pub const TEE_ISOCKET_VERSION: u32 = 0x01000000;
57-
57+
5858
pub const TEE_ISOCKET_ERROR_PROTOCOL: u32 = 0xF1007001;
5959
pub const TEE_ISOCKET_ERROR_REMOTE_CLOSED: u32 = 0xF1007002;
6060
pub const TEE_ISOCKET_ERROR_TIMEOUT: u32 = 0xF1007003;

optee-utee/optee-utee-sys/src/tee_tcpsocket.rs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,6 @@ extern "C" {
3030
pub static TEE_tcpSocket: *const TEE_iSocket;
3131
}
3232

33-
3433
pub const TEE_ISOCKET_PROTOCOLID_TCP: u32 = 0x65;
3534
pub const TEE_ISOCKET_TCP_WARNING_UNKNOWN_OUT_OF_BAND: u32 = 0xF1010002;
3635

optee-utee/optee-utee-sys/src/user_ta_header.rs

Lines changed: 13 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -15,10 +15,10 @@
1515
// specific language governing permissions and limitations
1616
// under the License.
1717

18-
use core::ffi::*;
1918
use super::tee_api_types::*;
2019
use super::utee_syscalls::*;
2120
use super::utee_types::*;
21+
use core::ffi::*;
2222

2323
pub const TA_FLAG_SINGLE_INSTANCE: u32 = 1 << 2;
2424
pub const TA_FLAG_MULTI_SESSION: u32 = 1 << 3;
@@ -38,7 +38,12 @@ pub struct ta_head {
3838
}
3939

4040
extern "C" {
41-
pub fn __utee_entry(func: c_ulong, session_id: c_ulong, up: *mut utee_params, cmd_id: c_ulong) -> TEE_Result;
41+
pub fn __utee_entry(
42+
func: c_ulong,
43+
session_id: c_ulong,
44+
up: *mut utee_params,
45+
cmd_id: c_ulong,
46+
) -> TEE_Result;
4247
}
4348

4449
/// # Safety
@@ -48,7 +53,12 @@ extern "C" {
4853
/// by the OP-TEE runtime environment. This function should never be called directly
4954
/// from user code - it is only exported for the OP-TEE OS loader.
5055
#[no_mangle]
51-
unsafe fn __ta_entry(func: c_ulong, session_id: c_ulong, up: *mut utee_params, cmd_id: c_ulong) -> ! {
56+
unsafe fn __ta_entry(
57+
func: c_ulong,
58+
session_id: c_ulong,
59+
up: *mut utee_params,
60+
cmd_id: c_ulong,
61+
) -> ! {
5262
let res: u32 = __utee_entry(func, session_id, up, cmd_id);
5363

5464
_utee_return(res.into());

optee-utee/optee-utee-sys/src/utee_types.rs

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -55,10 +55,10 @@ pub struct utee_attribute {
5555
#[repr(C)]
5656
pub struct utee_object_info {
5757
obj_type: u32,
58-
obj_size: u32,
59-
max_obj_size: u32,
60-
obj_usage: u32,
61-
data_size: u32,
62-
data_pos: u32,
63-
handle_flags: u32,
58+
obj_size: u32,
59+
max_obj_size: u32,
60+
obj_usage: u32,
61+
data_size: u32,
62+
data_pos: u32,
63+
handle_flags: u32,
6464
}

optee-utee/src/arithmetical.rs

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -16,10 +16,10 @@
1616
// under the License.
1717

1818
use crate::{Error, Result};
19-
use optee_utee_sys as raw;
20-
use core::{cmp::max, fmt};
2119
#[cfg(not(feature = "std"))]
2220
use alloc::vec::Vec;
21+
use core::{cmp::max, fmt};
22+
use optee_utee_sys as raw;
2323

2424
pub type BigIntUnit = u32;
2525
pub type BigIntFMMUnit = u32;
@@ -274,9 +274,7 @@ impl BigIntFMMContext {
274274
pub fn new(bits: u32, modulus: BigInt) -> Result<Self> {
275275
let size: usize = Self::size_in_u32(bits as usize);
276276
let mut tmp_vec: Vec<BigIntFMMContextUnit> = vec![0; size];
277-
unsafe {
278-
raw::TEE_BigIntInitFMMContext(tmp_vec.as_mut_ptr(), size, modulus.data_ptr())
279-
};
277+
unsafe { raw::TEE_BigIntInitFMMContext(tmp_vec.as_mut_ptr(), size, modulus.data_ptr()) };
280278
Ok(Self(tmp_vec))
281279
}
282280
}

optee-utee/src/crypto_op.rs

Lines changed: 10 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -621,9 +621,7 @@ impl Cipher {
621621
&mut dest_size,
622622
)
623623
} {
624-
raw::TEE_SUCCESS => {
625-
Ok(dest_size)
626-
}
624+
raw::TEE_SUCCESS => Ok(dest_size),
627625
code => Err(Error::from_raw_error(code)),
628626
}
629627
}
@@ -742,7 +740,11 @@ impl Cipher {
742740
/// 6) If operation is not in initial state.
743741
/// 7) Hardware or cryptographic algorithm failure.
744742
/// 8) If the Implementation detects any other error.
745-
pub fn set_key_2<T: GenericObject, D: GenericObject>(&self, object1: &T, object2: &D) -> Result<()> {
743+
pub fn set_key_2<T: GenericObject, D: GenericObject>(
744+
&self,
745+
object1: &T,
746+
object2: &D,
747+
) -> Result<()> {
746748
match unsafe {
747749
raw::TEE_SetOperationKey2(self.handle(), object1.handle(), object2.handle())
748750
} {
@@ -1067,9 +1069,7 @@ impl AE {
10671069
&mut dest_size,
10681070
)
10691071
} {
1070-
raw::TEE_SUCCESS => {
1071-
Ok(dest_size)
1072-
}
1072+
raw::TEE_SUCCESS => Ok(dest_size),
10731073
code => Err(Error::from_raw_error(code)),
10741074
}
10751075
}
@@ -1155,9 +1155,7 @@ impl AE {
11551155
&mut tag_size,
11561156
)
11571157
} {
1158-
raw::TEE_SUCCESS => {
1159-
Ok((dest_size, tag_size))
1160-
}
1158+
raw::TEE_SUCCESS => Ok((dest_size, tag_size)),
11611159
code => Err(Error::from_raw_error(code)),
11621160
}
11631161
}
@@ -1198,9 +1196,7 @@ impl AE {
11981196
tag.len(),
11991197
)
12001198
} {
1201-
raw::TEE_SUCCESS => {
1202-
Ok(dest_size)
1203-
}
1199+
raw::TEE_SUCCESS => Ok(dest_size),
12041200
code => Err(Error::from_raw_error(code)),
12051201
}
12061202
}
@@ -1417,9 +1413,7 @@ impl Asymmetric {
14171413
&mut signature_size,
14181414
)
14191415
} {
1420-
raw::TEE_SUCCESS => {
1421-
Ok(signature_size)
1422-
}
1416+
raw::TEE_SUCCESS => Ok(signature_size),
14231417
code => Err(Error::from_raw_error(code)),
14241418
}
14251419
}

optee-utee/src/net/optee.rs

Lines changed: 8 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -41,25 +41,25 @@ impl Setup {
4141
})
4242
}
4343
/// Construct a new IPv4 target parameter using the address and port. It
44-
/// will return `BadParameters` if the address contains a `\0` character in
44+
/// will return `BadParameters` if the address contains a `\0` character in
4545
/// the middle.
4646
pub fn new_v4(addr: &str, port: u16) -> crate::Result<Self> {
4747
Self::new(addr, port, raw::TEE_ipSocket_ipVersion::TEE_IP_VERSION_4)
4848
}
4949
/// Construct a new IPv6 target parameter using the address and port. It
50-
/// will return `BadParameters` if the address contains a `\0` character in
50+
/// will return `BadParameters` if the address contains a `\0` character in
5151
/// the middle.
5252
pub fn new_v6(addr: &str, port: u16) -> crate::Result<Self> {
5353
Self::new(addr, port, raw::TEE_ipSocket_ipVersion::TEE_IP_VERSION_6)
5454
}
5555
}
5656

57-
/// An adapter for TCP sockets in OP-TEE. Typically, it is not used directly,
58-
/// but can be employed for wrapper operations, such as traffic control within
57+
/// An adapter for TCP sockets in OP-TEE. Typically, it is not used directly,
58+
/// but can be employed for wrapper operations, such as traffic control within
5959
/// the TEE.
6060
pub struct TcpAdapter(raw::TEE_iSocketHandle);
61-
/// An adapter for UDP sockets in OP-TEE. Typically, it is not used directly,
62-
/// but can be employed for wrapper operations, such as traffic control within
61+
/// An adapter for UDP sockets in OP-TEE. Typically, it is not used directly,
62+
/// but can be employed for wrapper operations, such as traffic control within
6363
/// the TEE.
6464
pub struct UdpAdapter(raw::TEE_iSocketHandle);
6565
/// A TcpStream that is compatible with OP-TEE.
@@ -108,12 +108,7 @@ impl SocketAdapter for TcpAdapter {
108108
fn send(handle: &mut Self::Handle, buf: &[u8], timeout: u32) -> Result<usize, SocketError> {
109109
let mut length: u32 = buf.len() as _;
110110
let ret = unsafe {
111-
((*raw::TEE_tcpSocket).send)(
112-
handle.0,
113-
buf.as_ptr() as _,
114-
&mut length,
115-
timeout,
116-
)
111+
((*raw::TEE_tcpSocket).send)(handle.0, buf.as_ptr() as _, &mut length, timeout)
117112
};
118113
match ret {
119114
raw::TEE_SUCCESS => Ok(length as usize),
@@ -168,12 +163,7 @@ impl SocketAdapter for UdpAdapter {
168163
fn send(handle: &mut Self::Handle, buf: &[u8], timeout: u32) -> Result<usize, SocketError> {
169164
let mut length: u32 = buf.len() as _;
170165
let ret = unsafe {
171-
((*raw::TEE_udpSocket).send)(
172-
handle.0,
173-
buf.as_ptr() as _,
174-
&mut length,
175-
timeout,
176-
)
166+
((*raw::TEE_udpSocket).send)(handle.0, buf.as_ptr() as _, &mut length, timeout)
177167
};
178168
match ret {
179169
raw::TEE_SUCCESS => Ok(length as usize),

optee-utee/src/net/optee_no_std.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@
1616
// under the License.
1717
use super::{Setup, Socket, SocketAdapter, SocketError};
1818

19-
/// A trait used for convenience; import it so that the code remains consistent
19+
/// A trait used for convenience; import it so that the code remains consistent
2020
/// with the std version (with the only difference being the return error type).
2121
///
2222
/// Take TcpStream as example:
@@ -42,7 +42,7 @@ pub trait StdCompatConnect: Sized {
4242
}
4343
}
4444

45-
/// A trait used for convenience; import it so that the code remains consistent
45+
/// A trait used for convenience; import it so that the code remains consistent
4646
/// with the std version (with the only difference being the return error type).
4747
///
4848
/// Take TcpStream as example:
@@ -81,7 +81,7 @@ pub trait StdCompatWrite {
8181
}
8282
}
8383

84-
/// A trait used for convenience; import it so that the code remains consistent
84+
/// A trait used for convenience; import it so that the code remains consistent
8585
/// with the std version (with the only difference being the return error type).
8686
///
8787
/// Take TcpStream as example:

optee-utee/src/net/optee_std.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -106,7 +106,7 @@ impl std::io::Write for UdpSocket {
106106
}
107107
}
108108

109-
// This is implemented to save developers from having to make numerous map_err
109+
// This is implemented to save developers from having to make numerous map_err
110110
// calls.
111111
impl Into<std::io::Error> for SocketError {
112112
fn into(self) -> std::io::Error {

optee-utee/src/net/socket.rs

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ use optee_utee_sys as raw;
2020
use super::SocketError;
2121
use core::time::Duration;
2222

23-
/// A trait designed to accommodate various implementations of GP TEE Sockets
23+
/// A trait designed to accommodate various implementations of GP TEE Sockets
2424
/// API.
2525
///
2626
/// An implementation of this trait is responsible for handling all
@@ -62,16 +62,16 @@ impl<T: SocketAdapter> Socket<T> {
6262
pub fn set_send_timeout_in_milli(&mut self, milliseconds: u32) {
6363
self.send_timeout = milliseconds;
6464
}
65-
/// a wrapper of `set_recv_timeout_in_milli`, similar to `set_read_timeout`
66-
/// in std::net::TcpStream, it will set timeout to `TEE_TIMEOUT_INFINITE`
65+
/// a wrapper of `set_recv_timeout_in_milli`, similar to `set_read_timeout`
66+
/// in std::net::TcpStream, it will set timeout to `TEE_TIMEOUT_INFINITE`
6767
/// if `Option::None` is provided.
6868
pub fn set_recv_timeout(&mut self, dur: Option<Duration>) -> crate::Result<()> {
6969
let milliseconds = convert_duration_option_to_timeout(dur)?;
7070
self.set_recv_timeout_in_milli(milliseconds);
7171
Ok(())
7272
}
73-
/// a wrapper of `set_send_timeout_in_milli`, similar to
74-
/// `set_write_timeout` in std::net::TcpStream, it will set timeout to
73+
/// a wrapper of `set_send_timeout_in_milli`, similar to
74+
/// `set_write_timeout` in std::net::TcpStream, it will set timeout to
7575
/// `TEE_TIMEOUT_INFINITE` if `Option::None` is provided.
7676
pub fn set_send_timeout(&mut self, dur: Option<Duration>) -> crate::Result<()> {
7777
let milliseconds = convert_duration_option_to_timeout(dur)?;

0 commit comments

Comments
 (0)