You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@teaclave.apache.org by iv...@apache.org on 2026/04/13 09:54:04 UTC
(teaclave-trustzone-sdk) branch main updated (017c472 -> 2f14d6d)
This is an automated email from the ASF dual-hosted git repository.
ivila pushed a change to branch main
in repository https://gitbox.apache.org/repos/asf/teaclave-trustzone-sdk.git
from 017c472 optee-utee-macros: bump edition to 2024
new 93541be crates: fix clippy & fmt
new 2f14d6d tools/cargo-optee: fix clippy & fmt & unpin dependency
The 2 revisions listed above as "new" are entirely new to this
repository and will be described in separate emails. The revisions
listed as "add" were already present in the repository and have only
been added to this reference.
Summary of changes:
.github/workflows/reuse_test.yml | 9 +-
crates/optee-teec-macros/src/lib.rs | 17 ++--
crates/optee-teec-sys/src/tee_client_api.rs | 114 ++++++++++++++------------
crates/optee-teec-systest/src/main.rs | 2 +
crates/optee-teec/src/context.rs | 2 +-
crates/optee-teec/src/operation.rs | 2 +-
crates/optee-teec/src/session.rs | 2 +-
crates/optee-utee-build/src/code_generator.rs | 9 +-
crates/optee-utee-build/src/linker.rs | 5 +-
crates/optee-utee-macros/src/lib.rs | 7 +-
crates/optee-utee-systest/build.rs | 13 ++-
crates/optee-utee-systest/src/main.rs | 2 +-
crates/optee-utee/src/extension.rs | 5 +-
crates/secure_db/src/client.rs | 2 +-
tools/cargo-optee/Cargo.toml | 2 +-
tools/cargo-optee/src/ca_builder.rs | 8 +-
tools/cargo-optee/src/common.rs | 2 +-
tools/cargo-optee/src/config.rs | 28 +++----
tools/cargo-optee/src/ta_builder.rs | 20 +++--
19 files changed, 128 insertions(+), 123 deletions(-)
---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@teaclave.apache.org
For additional commands, e-mail: commits-help@teaclave.apache.org
(teaclave-trustzone-sdk) 01/02: crates: fix clippy & fmt
Posted by iv...@apache.org.
This is an automated email from the ASF dual-hosted git repository.
ivila pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/teaclave-trustzone-sdk.git
commit 93541bea0cd9a5b55cfbf4a2524f6c0ab176fea3
Author: ivila <39...@qq.com>
AuthorDate: Mon Apr 13 15:56:04 2026 +0800
crates: fix clippy & fmt
---
.github/workflows/reuse_test.yml | 9 +-
crates/optee-teec-macros/src/lib.rs | 17 ++--
crates/optee-teec-sys/src/tee_client_api.rs | 114 ++++++++++++++------------
crates/optee-teec-systest/src/main.rs | 2 +
crates/optee-teec/src/context.rs | 2 +-
crates/optee-teec/src/operation.rs | 2 +-
crates/optee-teec/src/session.rs | 2 +-
crates/optee-utee-build/src/code_generator.rs | 9 +-
crates/optee-utee-build/src/linker.rs | 5 +-
crates/optee-utee-macros/src/lib.rs | 7 +-
crates/optee-utee-systest/build.rs | 13 ++-
crates/optee-utee-systest/src/main.rs | 2 +-
crates/optee-utee/src/extension.rs | 5 +-
crates/secure_db/src/client.rs | 2 +-
14 files changed, 101 insertions(+), 90 deletions(-)
diff --git a/.github/workflows/reuse_test.yml b/.github/workflows/reuse_test.yml
index 770d136..e1df214 100644
--- a/.github/workflows/reuse_test.yml
+++ b/.github/workflows/reuse_test.yml
@@ -65,8 +65,13 @@ jobs:
# Clippy checks
(cd crates && \
- cargo clippy -p optee-utee --target aarch64-unknown-linux-gnu -- -D warnings && \
- cargo clippy -p optee-teec --target aarch64-unknown-linux-gnu -- -D warnings)
+ cargo clippy --workspace \
+ --exclude secure_db \
+ --exclude rustls_provider \
+ --target aarch64-unknown-linux-gnu -- -D warnings)
+
+ # fmt checks
+ (cd crates && cargo fmt --all --check)
build-and-test-examples-for-32bit-no-std-TAs:
uses: ./.github/workflows/reuse_host_build_and_qemu_run.yml
diff --git a/crates/optee-teec-macros/src/lib.rs b/crates/optee-teec-macros/src/lib.rs
index 3e74f80..dabd46b 100644
--- a/crates/optee-teec-macros/src/lib.rs
+++ b/crates/optee-teec-macros/src/lib.rs
@@ -20,7 +20,7 @@
extern crate proc_macro;
use proc_macro::TokenStream;
-use quote::{quote, ToTokens};
+use quote::{ToTokens, quote};
use syn::parse_macro_input;
use syn::spanned::Spanned;
@@ -72,13 +72,14 @@ pub fn plugin_init(_args: TokenStream, input: TokenStream) -> TokenStream {
// check if return_type of the function is `optee_teec::Result<()>`
fn check_return_type(item_fn: &syn::ItemFn) -> bool {
if let syn::ReturnType::Type(_, return_type) = item_fn.sig.output.to_owned()
- && let syn::Type::Path(path) = return_type.as_ref() {
- let expected_type = quote! { optee_teec::Result<()> };
- let actual_type = path.path.to_token_stream();
- if expected_type.to_string() == actual_type.to_string() {
- return true;
- }
+ && let syn::Type::Path(path) = return_type.as_ref()
+ {
+ let expected_type = quote! { optee_teec::Result<()> };
+ let actual_type = path.path.to_token_stream();
+ if expected_type.to_string() == actual_type.to_string() {
+ return true;
}
+ }
false
}
@@ -158,7 +159,7 @@ pub fn plugin_invoke(_args: TokenStream, input: TokenStream) -> TokenStream {
/// - **Buffer overflow attempt**: if inner logic (developer code) tries to return
/// more bytes than `in_len` → rejected by `set_buf_from_slice`, error returned with required `out_len`
/// - **Invalid pointers**: null pointers are checked, but other invalid cases of pointers
- /// such as dangling, misaligned, or read-only pointers will cause undefined behavior
+ /// such as dangling, misaligned, or read-only pointers will cause undefined behavior
/// and must be prevented by the caller
pub unsafe fn _plugin_invoke(
cmd: u32,
diff --git a/crates/optee-teec-sys/src/tee_client_api.rs b/crates/optee-teec-sys/src/tee_client_api.rs
index 9320c4c..75f73d4 100644
--- a/crates/optee-teec-sys/src/tee_client_api.rs
+++ b/crates/optee-teec-sys/src/tee_client_api.rs
@@ -15,10 +15,10 @@
// specific language governing permissions and limitations
// under the License.
-use core::ffi::*;
use crate::size_t;
+use core::ffi::*;
-pub fn TEEC_PARAM_TYPES(p0:u32, p1:u32, p2:u32, p3:u32) -> u32 {
+pub fn TEEC_PARAM_TYPES(p0: u32, p1: u32, p2: u32, p3: u32) -> u32 {
let tmp = p1 << 4 | p2 << 8 | p3 << 12;
p0 | tmp
}
@@ -27,52 +27,52 @@ pub const TEEC_CONFIG_PAYLOAD_REF_COUNT: u32 = 4;
pub const TEEC_CONFIG_SHAREDMEM_MAX_SIZE: c_ulong = -1 as c_long as c_ulong;
-pub const TEEC_NONE: u32 = 0x00000000;
-pub const TEEC_VALUE_INPUT: u32 = 0x00000001;
-pub const TEEC_VALUE_OUTPUT: u32 = 0x00000002;
-pub const TEEC_VALUE_INOUT: u32 = 0x00000003;
-pub const TEEC_MEMREF_TEMP_INPUT: u32 = 0x00000005;
-pub const TEEC_MEMREF_TEMP_OUTPUT: u32 = 0x00000006;
-pub const TEEC_MEMREF_TEMP_INOUT: u32 = 0x00000007;
-pub const TEEC_MEMREF_WHOLE: u32 = 0x0000000C;
-pub const TEEC_MEMREF_PARTIAL_INPUT: u32 = 0x0000000D;
+pub const TEEC_NONE: u32 = 0x00000000;
+pub const TEEC_VALUE_INPUT: u32 = 0x00000001;
+pub const TEEC_VALUE_OUTPUT: u32 = 0x00000002;
+pub const TEEC_VALUE_INOUT: u32 = 0x00000003;
+pub const TEEC_MEMREF_TEMP_INPUT: u32 = 0x00000005;
+pub const TEEC_MEMREF_TEMP_OUTPUT: u32 = 0x00000006;
+pub const TEEC_MEMREF_TEMP_INOUT: u32 = 0x00000007;
+pub const TEEC_MEMREF_WHOLE: u32 = 0x0000000C;
+pub const TEEC_MEMREF_PARTIAL_INPUT: u32 = 0x0000000D;
pub const TEEC_MEMREF_PARTIAL_OUTPUT: u32 = 0x0000000E;
-pub const TEEC_MEMREF_PARTIAL_INOUT: u32 = 0x0000000F;
+pub const TEEC_MEMREF_PARTIAL_INOUT: u32 = 0x0000000F;
-pub const TEEC_MEM_INPUT: u32 = 0x00000001;
+pub const TEEC_MEM_INPUT: u32 = 0x00000001;
pub const TEEC_MEM_OUTPUT: u32 = 0x00000002;
-pub const TEEC_SUCCESS: u32 = 0x00000000;
-pub const TEEC_ERROR_GENERIC: u32 = 0xFFFF0000;
-pub const TEEC_ERROR_ACCESS_DENIED: u32 = 0xFFFF0001;
-pub const TEEC_ERROR_CANCEL: u32 = 0xFFFF0002;
+pub const TEEC_SUCCESS: u32 = 0x00000000;
+pub const TEEC_ERROR_GENERIC: u32 = 0xFFFF0000;
+pub const TEEC_ERROR_ACCESS_DENIED: u32 = 0xFFFF0001;
+pub const TEEC_ERROR_CANCEL: u32 = 0xFFFF0002;
pub const TEEC_ERROR_ACCESS_CONFLICT: u32 = 0xFFFF0003;
-pub const TEEC_ERROR_EXCESS_DATA: u32 = 0xFFFF0004;
-pub const TEEC_ERROR_BAD_FORMAT: u32 = 0xFFFF0005;
-pub const TEEC_ERROR_BAD_PARAMETERS: u32 = 0xFFFF0006;
-pub const TEEC_ERROR_BAD_STATE: u32 = 0xFFFF0007;
-pub const TEEC_ERROR_ITEM_NOT_FOUND: u32 = 0xFFFF0008;
+pub const TEEC_ERROR_EXCESS_DATA: u32 = 0xFFFF0004;
+pub const TEEC_ERROR_BAD_FORMAT: u32 = 0xFFFF0005;
+pub const TEEC_ERROR_BAD_PARAMETERS: u32 = 0xFFFF0006;
+pub const TEEC_ERROR_BAD_STATE: u32 = 0xFFFF0007;
+pub const TEEC_ERROR_ITEM_NOT_FOUND: u32 = 0xFFFF0008;
pub const TEEC_ERROR_NOT_IMPLEMENTED: u32 = 0xFFFF0009;
-pub const TEEC_ERROR_NOT_SUPPORTED: u32 = 0xFFFF000A;
-pub const TEEC_ERROR_NO_DATA: u32 = 0xFFFF000B;
-pub const TEEC_ERROR_OUT_OF_MEMORY: u32 = 0xFFFF000C;
-pub const TEEC_ERROR_BUSY: u32 = 0xFFFF000D;
-pub const TEEC_ERROR_COMMUNICATION: u32 = 0xFFFF000E;
-pub const TEEC_ERROR_SECURITY: u32 = 0xFFFF000F;
-pub const TEEC_ERROR_SHORT_BUFFER: u32 = 0xFFFF0010;
+pub const TEEC_ERROR_NOT_SUPPORTED: u32 = 0xFFFF000A;
+pub const TEEC_ERROR_NO_DATA: u32 = 0xFFFF000B;
+pub const TEEC_ERROR_OUT_OF_MEMORY: u32 = 0xFFFF000C;
+pub const TEEC_ERROR_BUSY: u32 = 0xFFFF000D;
+pub const TEEC_ERROR_COMMUNICATION: u32 = 0xFFFF000E;
+pub const TEEC_ERROR_SECURITY: u32 = 0xFFFF000F;
+pub const TEEC_ERROR_SHORT_BUFFER: u32 = 0xFFFF0010;
pub const TEEC_ERROR_EXTERNAL_CANCEL: u32 = 0xFFFF0011;
-pub const TEEC_ERROR_TARGET_DEAD: u32 = 0xFFFF3024;
+pub const TEEC_ERROR_TARGET_DEAD: u32 = 0xFFFF3024;
-pub const TEEC_ORIGIN_API: u32 = 0x00000001;
-pub const TEEC_ORIGIN_COMMS: u32 = 0x00000002;
-pub const TEEC_ORIGIN_TEE: u32 = 0x00000003;
+pub const TEEC_ORIGIN_API: u32 = 0x00000001;
+pub const TEEC_ORIGIN_COMMS: u32 = 0x00000002;
+pub const TEEC_ORIGIN_TEE: u32 = 0x00000003;
pub const TEEC_ORIGIN_TRUSTED_APP: u32 = 0x00000004;
-pub const TEEC_LOGIN_PUBLIC: u32 = 0x00000000;
-pub const TEEC_LOGIN_USER: u32 = 0x00000001;
-pub const TEEC_LOGIN_GROUP: u32 = 0x00000002;
-pub const TEEC_LOGIN_APPLICATION: u32 = 0x00000004;
-pub const TEEC_LOGIN_USER_APPLICATION: u32 = 0x00000005;
+pub const TEEC_LOGIN_PUBLIC: u32 = 0x00000000;
+pub const TEEC_LOGIN_USER: u32 = 0x00000001;
+pub const TEEC_LOGIN_GROUP: u32 = 0x00000002;
+pub const TEEC_LOGIN_APPLICATION: u32 = 0x00000004;
+pub const TEEC_LOGIN_USER_APPLICATION: u32 = 0x00000005;
pub const TEEC_LOGIN_GROUP_APPLICATION: u32 = 0x00000006;
#[allow(non_camel_case_types)]
@@ -172,22 +172,30 @@ pub struct TEEC_Operation {
unsafe extern "C" {
pub fn TEEC_InitializeContext(name: *const c_char, context: *mut TEEC_Context) -> TEEC_Result;
pub fn TEEC_FinalizeContext(context: *mut TEEC_Context);
- pub fn TEEC_OpenSession(context: *mut TEEC_Context,
- session: *mut TEEC_Session,
- destination: *const TEEC_UUID,
- connectionMethod: u32,
- connectionData: *const c_void,
- operation: *mut TEEC_Operation,
- returnOrigin: *mut u32) -> TEEC_Result;
+ pub fn TEEC_OpenSession(
+ context: *mut TEEC_Context,
+ session: *mut TEEC_Session,
+ destination: *const TEEC_UUID,
+ connectionMethod: u32,
+ connectionData: *const c_void,
+ operation: *mut TEEC_Operation,
+ returnOrigin: *mut u32,
+ ) -> TEEC_Result;
pub fn TEEC_CloseSession(session: *mut TEEC_Session);
- pub fn TEEC_InvokeCommand(session: *mut TEEC_Session,
- commandID: u32,
- operation: *mut TEEC_Operation,
- returnOrigin: *mut u32) -> TEEC_Result;
- pub fn TEEC_RegisterSharedMemory(context: *mut TEEC_Context,
- sharedMem: *mut TEEC_SharedMemory) -> TEEC_Result;
- pub fn TEEC_AllocateSharedMemory(context: *mut TEEC_Context,
- sharedMem: *mut TEEC_SharedMemory) -> TEEC_Result;
+ pub fn TEEC_InvokeCommand(
+ session: *mut TEEC_Session,
+ commandID: u32,
+ operation: *mut TEEC_Operation,
+ returnOrigin: *mut u32,
+ ) -> TEEC_Result;
+ pub fn TEEC_RegisterSharedMemory(
+ context: *mut TEEC_Context,
+ sharedMem: *mut TEEC_SharedMemory,
+ ) -> TEEC_Result;
+ pub fn TEEC_AllocateSharedMemory(
+ context: *mut TEEC_Context,
+ sharedMem: *mut TEEC_SharedMemory,
+ ) -> TEEC_Result;
pub fn TEEC_ReleaseSharedMemory(sharedMemory: *mut TEEC_SharedMemory);
pub fn TEEC_RequestCancellation(operation: *mut TEEC_Operation);
}
diff --git a/crates/optee-teec-systest/src/main.rs b/crates/optee-teec-systest/src/main.rs
index a8fd56c..dd060fc 100644
--- a/crates/optee-teec-systest/src/main.rs
+++ b/crates/optee-teec-systest/src/main.rs
@@ -15,6 +15,8 @@
// specific language governing permissions and limitations
// under the License.
+#![allow(clippy::all)]
+
use core::ffi::*;
use optee_teec_sys::*;
diff --git a/crates/optee-teec/src/context.rs b/crates/optee-teec/src/context.rs
index bf17616..e33ceda 100644
--- a/crates/optee-teec/src/context.rs
+++ b/crates/optee-teec/src/context.rs
@@ -15,7 +15,7 @@
// specific language governing permissions and limitations
// under the License.
-use crate::{raw, ConnectionMethods, Error, Operation, Param, ParamNone, Result, Session, Uuid};
+use crate::{ConnectionMethods, Error, Operation, Param, ParamNone, Result, Session, Uuid, raw};
use std::{cell::RefCell, ptr, rc::Rc};
pub struct InnerContext(pub raw::TEEC_Context);
diff --git a/crates/optee-teec/src/operation.rs b/crates/optee-teec/src/operation.rs
index 2960182..b15b07d 100644
--- a/crates/optee-teec/src/operation.rs
+++ b/crates/optee-teec/src/operation.rs
@@ -15,7 +15,7 @@
// specific language governing permissions and limitations
// under the License.
-use crate::{raw, Param, ParamTypes};
+use crate::{Param, ParamTypes, raw};
use std::{marker::PhantomData, mem};
/// This type defines the payload of either an open session operation or an
diff --git a/crates/optee-teec/src/session.rs b/crates/optee-teec/src/session.rs
index 04f7525..02b6bc1 100644
--- a/crates/optee-teec/src/session.rs
+++ b/crates/optee-teec/src/session.rs
@@ -16,7 +16,7 @@
// under the License.
use super::context::InnerContext;
-use crate::{raw, Context, Error, Operation, Param, Result, Uuid};
+use crate::{Context, Error, Operation, Param, Result, Uuid, raw};
use std::{cell::RefCell, ptr, rc::Rc};
/// Session login methods.
diff --git a/crates/optee-utee-build/src/code_generator.rs b/crates/optee-utee-build/src/code_generator.rs
index 9f7d090..b471862 100644
--- a/crates/optee-utee-build/src/code_generator.rs
+++ b/crates/optee-utee-build/src/code_generator.rs
@@ -36,15 +36,14 @@ use std::str::FromStr;
/// # Ok(())
/// # }
/// ```
+#[derive(Default)]
pub struct HeaderFileGenerator {
code: proc_macro2::TokenStream,
}
impl HeaderFileGenerator {
pub fn new() -> Self {
- Self {
- code: quote!(),
- }
+ Default::default()
}
pub fn generate(mut self, conf: &TaConfig) -> Result<String, Error> {
self.write_includes();
@@ -240,9 +239,7 @@ fn property_value_data_codes(value: &PropertyValue) -> Result<proc_macro2::Token
PropertyValue::Uuid(v) => uuid_to_tee_uuid_value_codes(v),
PropertyValue::Str(v) => Ok(string_to_binary_codes(v)),
PropertyValue::BinaryBlock(v) => Ok(string_to_binary_codes(v)),
- PropertyValue::Identity(login, uuid) => {
- identity_to_tee_identity_value_codes(*login, uuid)
- }
+ PropertyValue::Identity(login, uuid) => identity_to_tee_identity_value_codes(*login, uuid),
}
}
diff --git a/crates/optee-utee-build/src/linker.rs b/crates/optee-utee-build/src/linker.rs
index c6258e6..065bb89 100644
--- a/crates/optee-utee-build/src/linker.rs
+++ b/crates/optee-utee-build/src/linker.rs
@@ -216,7 +216,10 @@ impl Linker {
fn generate_new_link_script(&self, ta_dev_kit_dir: PathBuf) -> Result<String, Error> {
let link_script_template_path = ta_dev_kit_dir.join("src/ta.ld.S");
- println!("cargo:rerun-if-changed={}", link_script_template_path.display());
+ println!(
+ "cargo:rerun-if-changed={}",
+ link_script_template_path.display()
+ );
let link_script_output = {
const ENV_CC: &str = "CC";
diff --git a/crates/optee-utee-macros/src/lib.rs b/crates/optee-utee-macros/src/lib.rs
index 6eb001c..0fa2927 100644
--- a/crates/optee-utee-macros/src/lib.rs
+++ b/crates/optee-utee-macros/src/lib.rs
@@ -375,9 +375,10 @@ pub fn ta_invoke_command(_args: TokenStream, input: TokenStream) -> TokenStream
fn extract_fn_arg_mut_ref_type(fn_arg: &syn::FnArg) -> Result<&syn::Type, syn::parse::Error> {
if let syn::FnArg::Typed(ty) = fn_arg
&& let syn::Type::Reference(type_ref) = ty.ty.as_ref()
- && type_ref.mutability.is_some() {
- return Ok(&*type_ref.elem);
- };
+ && type_ref.mutability.is_some()
+ {
+ return Ok(&*type_ref.elem);
+ };
Err(syn::parse::Error::new(
fn_arg.span(),
"this argument should have signature `_: &mut T`",
diff --git a/crates/optee-utee-systest/build.rs b/crates/optee-utee-systest/build.rs
index aa5ee5b..5422fb2 100644
--- a/crates/optee-utee-systest/build.rs
+++ b/crates/optee-utee-systest/build.rs
@@ -95,14 +95,11 @@ fn generate_cfg(ta_include_path: PathBuf) -> ctest::TestGenerator {
})
.skip_fn(|s| {
let s = s.ident();
- match s {
- "__utee_entry" => true,
- _ => false,
- }
+ matches!(s, "__utee_entry")
})
- .skip_union(|s| match s.ident() {
- "content" => true,
- _ => false,
+ .skip_union(|s| {
+ let s = s.ident();
+ matches!(s, "content")
})
.skip_union_field(|s, _field| {
let s = s.ident();
@@ -160,7 +157,7 @@ fn build_and_link_undefined(ta_include_path: PathBuf) {
let mut builder = cc::Build::new();
builder
.include(ta_include_path.display().to_string())
- .file(&undefined_path.display().to_string())
+ .file(undefined_path.display().to_string())
.compile("undefined");
println!("cargo:rustc-link-search=native={}", out_dir.display());
diff --git a/crates/optee-utee-systest/src/main.rs b/crates/optee-utee-systest/src/main.rs
index 490d78c..4cf58b1 100644
--- a/crates/optee-utee-systest/src/main.rs
+++ b/crates/optee-utee-systest/src/main.rs
@@ -15,7 +15,7 @@
// specific language governing permissions and limitations
// under the License.
-#![allow(bad_style)]
+#![allow(clippy::all)]
use optee_utee_sys::*;
diff --git a/crates/optee-utee/src/extension.rs b/crates/optee-utee/src/extension.rs
index 4827f6b..99f050c 100644
--- a/crates/optee-utee/src/extension.rs
+++ b/crates/optee-utee/src/extension.rs
@@ -185,10 +185,7 @@ pub mod test_loadable_plugin {
fn generate_random_bytes(len: usize) -> Vec<u8> {
use rand::RngExt;
- rand::rng()
- .sample_iter(&Alphanumeric)
- .take(len)
- .collect()
+ rand::rng().sample_iter(&Alphanumeric).take(len).collect()
}
fn generate_test_pairs(
diff --git a/crates/secure_db/src/client.rs b/crates/secure_db/src/client.rs
index 2ef489e..22a58a8 100644
--- a/crates/secure_db/src/client.rs
+++ b/crates/secure_db/src/client.rs
@@ -19,10 +19,10 @@ use crate::SecureStorageDb;
use crate::Storable;
use anyhow::{anyhow, Result};
use std::{
- string::ToString,
collections::HashMap,
convert::TryFrom,
hash::Hash,
+ string::ToString,
sync::{Arc, RwLock},
};
---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@teaclave.apache.org
For additional commands, e-mail: commits-help@teaclave.apache.org
(teaclave-trustzone-sdk) 02/02: tools/cargo-optee: fix clippy & fmt & unpin dependency
Posted by iv...@apache.org.
This is an automated email from the ASF dual-hosted git repository.
ivila pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/teaclave-trustzone-sdk.git
commit 2f14d6d126ba7942aafb7938b514b4e0d85ae9a3
Author: ivila <39...@qq.com>
AuthorDate: Mon Apr 13 15:59:15 2026 +0800
tools/cargo-optee: fix clippy & fmt & unpin dependency
---
tools/cargo-optee/Cargo.toml | 2 +-
tools/cargo-optee/src/ca_builder.rs | 8 ++++----
tools/cargo-optee/src/common.rs | 2 +-
tools/cargo-optee/src/config.rs | 28 ++++++++++------------------
tools/cargo-optee/src/ta_builder.rs | 20 +++++++++++---------
5 files changed, 27 insertions(+), 33 deletions(-)
diff --git a/tools/cargo-optee/Cargo.toml b/tools/cargo-optee/Cargo.toml
index b821231..be5d0a2 100644
--- a/tools/cargo-optee/Cargo.toml
+++ b/tools/cargo-optee/Cargo.toml
@@ -35,7 +35,7 @@ cargo_metadata = "0.18"
serde.workspace = true
serde_json.workspace = true
toml = "0.8"
-indexmap = "=2.11.4"
+indexmap = "2.11.4"
env_logger = "0.11"
log = "0.4"
tempfile = "3.8"
diff --git a/tools/cargo-optee/src/ca_builder.rs b/tools/cargo-optee/src/ca_builder.rs
index 4533320..d4095b7 100644
--- a/tools/cargo-optee/src/ca_builder.rs
+++ b/tools/cargo-optee/src/ca_builder.rs
@@ -18,13 +18,13 @@
use crate::cargo_command;
use crate::common;
use crate::common::{
- get_package_name, get_target_and_cross_compile, get_target_directory_from_metadata,
- print_cargo_command, print_output_and_bail, read_uuid_from_file, BuildMode,
- ChangeDirectoryGuard,
+ BuildMode, ChangeDirectoryGuard, get_package_name, get_target_and_cross_compile,
+ get_target_directory_from_metadata, print_cargo_command, print_output_and_bail,
+ read_uuid_from_file,
};
use crate::config::CaBuildConfig;
-use anyhow::{bail, Result};
+use anyhow::{Result, bail};
use std::path::{Path, PathBuf};
// Main function to build the CA, optionally installing to a target directory
diff --git a/tools/cargo-optee/src/common.rs b/tools/cargo-optee/src/common.rs
index 24a44cf..75ea756 100644
--- a/tools/cargo-optee/src/common.rs
+++ b/tools/cargo-optee/src/common.rs
@@ -15,7 +15,7 @@
// specific language governing permissions and limitations
// under the License.
-use anyhow::{bail, Result};
+use anyhow::{Result, bail};
use clap::ValueEnum;
use std::env;
use std::fs;
diff --git a/tools/cargo-optee/src/config.rs b/tools/cargo-optee/src/config.rs
index c1299d3..c541717 100644
--- a/tools/cargo-optee/src/config.rs
+++ b/tools/cargo-optee/src/config.rs
@@ -15,7 +15,7 @@
// specific language governing permissions and limitations
// under the License.
-use anyhow::{bail, Result};
+use anyhow::{Result, bail};
use cargo_metadata::MetadataCommand;
use serde_json::Value;
use std::path::{Path, PathBuf};
@@ -279,13 +279,13 @@ impl CaBuildConfig {
println!(" Arch: {:?}", self.arch);
println!(" Debug: {}", self.debug);
println!(" OP-TEE client export: {:?}", self.optee_client_export);
- if self.plugin {
- if let Some(ref uuid_path) = self.uuid_path {
- let absolute_uuid_path = uuid_path
- .canonicalize()
- .unwrap_or_else(|_| uuid_path.clone());
- println!(" UUID path: {:?}", absolute_uuid_path);
- }
+ if self.plugin
+ && let Some(ref uuid_path) = self.uuid_path
+ {
+ let absolute_uuid_path = uuid_path
+ .canonicalize()
+ .unwrap_or_else(|_| uuid_path.clone());
+ println!(" UUID path: {:?}", absolute_uuid_path);
}
if !self.env.is_empty() {
println!(" Environment variables: {} set", self.env.len());
@@ -433,11 +433,7 @@ fn extract_build_config_with_arch(
arch_value.as_str()
} else {
// Architecture key missing, try fallback to non-specific
- if v.is_string() {
- v.as_str()
- } else {
- None
- }
+ if v.is_string() { v.as_str() } else { None }
}
})
.filter(|s| !s.is_empty())
@@ -458,11 +454,7 @@ fn extract_build_config_with_arch(
arch_value.as_str()
} else {
// Architecture key missing, try fallback to non-specific
- if v.is_string() {
- v.as_str()
- } else {
- None
- }
+ if v.is_string() { v.as_str() } else { None }
}
})
.filter(|s| !s.is_empty())
diff --git a/tools/cargo-optee/src/ta_builder.rs b/tools/cargo-optee/src/ta_builder.rs
index b58a019..da3e062 100644
--- a/tools/cargo-optee/src/ta_builder.rs
+++ b/tools/cargo-optee/src/ta_builder.rs
@@ -18,13 +18,13 @@
use crate::cargo_command;
use crate::common;
use crate::common::{
- get_package_name, get_target_and_cross_compile, get_target_directory_from_metadata,
- print_cargo_command, print_output_and_bail, read_uuid_from_file, BuildMode,
- ChangeDirectoryGuard,
+ BuildMode, ChangeDirectoryGuard, get_package_name, get_target_and_cross_compile,
+ get_target_directory_from_metadata, print_cargo_command, print_output_and_bail,
+ read_uuid_from_file,
};
use crate::config::TaBuildConfig;
-use anyhow::{bail, Result};
+use anyhow::{Result, bail};
use std::env;
use std::fs;
use std::path::{Path, PathBuf};
@@ -267,8 +267,8 @@ fn check_toolchain_exists(cross_compile_prefix: &str) -> Result<()> {
// Check if objcopy exists
let objcopy_check = Command::new("which").arg(&objcopy_command).output();
- let gcc_exists = gcc_check.map_or(false, |output| output.status.success());
- let objcopy_exists = objcopy_check.map_or(false, |output| output.status.success());
+ let gcc_exists = gcc_check.is_ok_and(|output| output.status.success());
+ let objcopy_exists = objcopy_check.is_ok_and(|output| output.status.success());
if !gcc_exists || !objcopy_exists {
let missing_tools: Vec<&str> = [
@@ -388,11 +388,13 @@ fn setup_build_command(
if config.std {
let rust_src = env::var("__CARGO_TESTS_ONLY_SRC_ROOT")
.map(PathBuf::from)
- .map_err(|_| anyhow::anyhow!(
- "__CARGO_TESTS_ONLY_SRC_ROOT is not set.\n\
+ .map_err(|_| {
+ anyhow::anyhow!(
+ "__CARGO_TESTS_ONLY_SRC_ROOT is not set.\n\
For std TA builds, set it to the Rust library source directory, e.g.:\n\
export __CARGO_TESTS_ONLY_SRC_ROOT=/path/to/rust/library"
- ))?;
+ )
+ })?;
if !rust_src.exists() {
anyhow::bail!(
"__CARGO_TESTS_ONLY_SRC_ROOT points to a non-existent path: {:?}",
---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@teaclave.apache.org
For additional commands, e-mail: commits-help@teaclave.apache.org