Skip to content

Commit 3e6fbdb

Browse files
committed
fix to run clippy for trusted crates
Signed-off-by: Jun Kimura <junkxdev@gmail.com>
1 parent ea45e08 commit 3e6fbdb

File tree

5 files changed

+24
-23
lines changed

5 files changed

+24
-23
lines changed

Makefile

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -15,10 +15,12 @@ fmt-check:
1515
.PHONY: clippy
1616
clippy:
1717
@find . -name Cargo.toml -not -path "./target/*" -exec dirname {} \; | while read dir; do \
18-
echo "Running clippy on $$dir..."; \
19-
if echo "$$dir" | grep -E -q "(enclave$$|sgx-ert)"; then \
20-
echo "Skipping $$dir"; \
18+
if echo "$$dir" | grep -E -q "(enclave$$|sgx-ert|sgx-trts|sgx-tcrypto|sgx-tse|sgx-tseal)"; then \
19+
echo "Running clippy on $$dir with SGX target..."; \
20+
TARGET_SPEC="$$(pwd)/unit-test/enclave/x86_64-unknown-unknown-sgx.json"; \
21+
(cd "$$dir" && cargo clippy -Z build-std=core,alloc --target="$$TARGET_SPEC" --all-features -- -D warnings) || exit 1; \
2122
else \
23+
echo "Running clippy on $$dir..."; \
2224
(cd "$$dir" && cargo clippy --all-targets --all-features -- -D warnings) || exit 1; \
2325
fi; \
2426
done

samples/hello-rust/enclave/src/lib.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ pub extern "C" fn ecall_sample(
3333
};
3434

3535
// Process the input (example: echo back with prefix)
36-
let result = format!("Hello from enclave: {}", input_string);
36+
let result = format!("Hello from enclave: {input_string}");
3737
let result_bytes = result.as_bytes();
3838

3939
// Check if output buffer is large enough

unit-test/enclave/src/test_crate.rs

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -2,16 +2,16 @@ use crate::utils::*;
22
use crate::TestResult;
33
use alloc::string::String;
44

5-
static HASH_TEST_VEC: &'static [&'static str] = &[
6-
&"abc",
7-
&"abcdbcdecdefdefgefghfghighijhijkijkljklmklmnlmnomnopnopq",
8-
&"abcdefghbcdefghicdefghijdefghijkefghijklfghijklmghijklmnhijklmnoijklmnopjklmnopqklmnopqrlmnopqrsmnopqrstnopqrstu",
5+
static HASH_TEST_VEC: &[&str] = &[
6+
"abc",
7+
"abcdbcdecdefdefgefghfghighijhijkijkljklmklmnlmnomnopnopq",
8+
"abcdefghbcdefghicdefghijdefghijkefghijklfghijklmghijklmnhijklmnoijklmnopjklmnopqklmnopqrlmnopqrsmnopqrstnopqrstu",
99
];
1010

11-
static HASH_SHA256_TRUTH: &'static [&'static str] = &[
12-
&"ba7816bf8f01cfea414140de5dae2223b00361a396177a9cb410ff61f20015ad",
13-
&"248d6a61d20638b8e5c026930c3e6039a33ce45964ff2167f6ecedd419db06c1",
14-
&"cf5b16a778af8380036ce59e7b0492370b249b11e8f07a51afac45037afee9d1",
11+
static HASH_SHA256_TRUTH: &[&str] = &[
12+
"ba7816bf8f01cfea414140de5dae2223b00361a396177a9cb410ff61f20015ad",
13+
"248d6a61d20638b8e5c026930c3e6039a33ce45964ff2167f6ecedd419db06c1",
14+
"cf5b16a778af8380036ce59e7b0492370b249b11e8f07a51afac45037afee9d1",
1515
];
1616

1717
pub fn test_sha2_crate() -> TestResult {

unit-test/enclave/src/test_crypto.rs

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -20,16 +20,16 @@ use crate::TestResult;
2020
use alloc::string::String;
2121
use sgx_tcrypto::*;
2222

23-
static HASH_TEST_VEC: &'static [&'static str] = &[
24-
&"abc",
25-
&"abcdbcdecdefdefgefghfghighijhijkijkljklmklmnlmnomnopnopq",
26-
&"abcdefghbcdefghicdefghijdefghijkefghijklfghijklmghijklmnhijklmnoijklmnopjklmnopqklmnopqrlmnopqrsmnopqrstnopqrstu",
23+
static HASH_TEST_VEC: &[&str] = &[
24+
"abc",
25+
"abcdbcdecdefdefgefghfghighijhijkijkljklmklmnlmnomnopnopq",
26+
"abcdefghbcdefghicdefghijdefghijkefghijklfghijklmghijklmnhijklmnoijklmnopjklmnopqklmnopqrlmnopqrsmnopqrstnopqrstu",
2727
];
2828

29-
static HASH_SHA256_TRUTH: &'static [&'static str] = &[
30-
&"ba7816bf8f01cfea414140de5dae2223b00361a396177a9cb410ff61f20015ad",
31-
&"248d6a61d20638b8e5c026930c3e6039a33ce45964ff2167f6ecedd419db06c1",
32-
&"cf5b16a778af8380036ce59e7b0492370b249b11e8f07a51afac45037afee9d1",
29+
static HASH_SHA256_TRUTH: &[&str] = &[
30+
"ba7816bf8f01cfea414140de5dae2223b00361a396177a9cb410ff61f20015ad",
31+
"248d6a61d20638b8e5c026930c3e6039a33ce45964ff2167f6ecedd419db06c1",
32+
"cf5b16a778af8380036ce59e7b0492370b249b11e8f07a51afac45037afee9d1",
3333
];
3434

3535
pub fn test_rsgx_sha256_slice() -> TestResult {

unit-test/enclave/src/test_seal.rs

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -52,8 +52,7 @@ pub fn test_seal_unseal() -> TestResult {
5252

5353
unsafe impl ContiguousMemory for RandData {}
5454

55-
let mut data = RandData::default();
56-
data.key = 0x1234;
55+
let mut data = RandData { key: 0x1234, ..Default::default() };
5756

5857
// Use sgx random instead of StdRng
5958
rsgx_read_rand(&mut data.rand).map_err(|_| "Failed to generate random data")?;
@@ -105,7 +104,7 @@ pub fn test_mac_aadata_slice() -> TestResult {
105104
if unsealed_data.get_decrypt_txt() != &text {
106105
return Err("Decrypted text verification failed");
107106
}
108-
if unsealed_data.get_additional_txt() != &aad_data {
107+
if unsealed_data.get_additional_txt() != aad_data {
109108
return Err("AAD verification failed");
110109
}
111110

0 commit comments

Comments
 (0)