uadk_engine/0064-uadk_engine-cleanup-static-check-warning-of-clangtid.patch
2023-08-04 16:24:25 +08:00

119 lines
3.0 KiB
Diff

From f17c89d7d27b3a728232c7e641c2978db238a2f3 Mon Sep 17 00:00:00 2001
From: Zhiqi Song <songzhiqi1@huawei.com>
Date: Sat, 22 Oct 2022 15:37:45 +0800
Subject: uadk_engine: cleanup static check warning of clangtidy tool
Cleanup the following warning:
1. Parameters of function should not be used as working
variable.
2. Cleanup uninitialized value.
3. Storage class should be specified after a type.
Signed-off-by: Zhiqi Song <songzhiqi1@huawei.com>
---
src/e_uadk.c | 6 ++----
src/uadk_cipher.c | 9 +++++----
src/uadk_ec.c | 5 +++--
src/uadk_rsa.c | 16 ++++++++--------
4 files changed, 18 insertions(+), 18 deletions(-)
diff --git a/src/e_uadk.c b/src/e_uadk.c
index 77612d7..21ceb86 100644
--- a/src/e_uadk.c
+++ b/src/e_uadk.c
@@ -89,13 +89,11 @@ static const ENGINE_CMD_DEFN g_uadk_cmd_defns[] = {
}
};
-__attribute__((constructor))
-static void uadk_constructor(void)
+static void __attribute__((constructor)) uadk_constructor(void)
{
}
-__attribute__((destructor))
-static void uadk_destructor(void)
+static void __attribute__((destructor)) uadk_destructor(void)
{
}
diff --git a/src/uadk_cipher.c b/src/uadk_cipher.c
index 9d4f692..14e2af2 100644
--- a/src/uadk_cipher.c
+++ b/src/uadk_cipher.c
@@ -749,17 +749,18 @@ static void ctr_iv_inc(uint8_t *counter, __u32 c)
{
uint32_t n = CTR_128BIT_COUNTER;
uint8_t *counter1 = counter;
+ __u32 c_value = c;
/*
* Since the counter has been increased 1 by the hardware,
* so the c need to decrease 1.
*/
- c = c - 1;
+ c_value -= 1;
do {
--n;
- c += counter1[n];
- counter1[n] = (uint8_t)c;
- c >>= BYTE_BITS;
+ c_value += counter1[n];
+ counter1[n] = (uint8_t)c_value;
+ c_value >>= BYTE_BITS;
} while (n);
}
diff --git a/src/uadk_ec.c b/src/uadk_ec.c
index 37683cd..247b875 100644
--- a/src/uadk_ec.c
+++ b/src/uadk_ec.c
@@ -72,14 +72,15 @@ static void init_dtb_param(void *dtb, char *start,
__u32 dsz, __u32 bsz, __u32 num)
{
struct wd_dtb *tmp = dtb;
+ char *buff = start;
int i = 0;
while (i++ < num) {
- tmp->data = start;
+ tmp->data = buff;
tmp->dsize = dsz;
tmp->bsize = bsz;
tmp += 1;
- start += bsz;
+ buff += bsz;
}
}
diff --git a/src/uadk_rsa.c b/src/uadk_rsa.c
index bcdd6bc..7d25338 100644
--- a/src/uadk_rsa.c
+++ b/src/uadk_rsa.c
@@ -932,14 +932,14 @@ static int rsa_fill_prikey(RSA *rsa, struct uadk_rsa_sess *rsa_sess,
struct rsa_prikey_param *pri,
unsigned char *in_buf, unsigned char *to)
{
- struct wd_rsa_prikey *prikey;
- struct wd_dtb *wd_dq;
- struct wd_dtb *wd_dp;
- struct wd_dtb *wd_q;
- struct wd_dtb *wd_p;
- struct wd_dtb *wd_qinv;
- struct wd_dtb *wd_d;
- struct wd_dtb *wd_n;
+ struct wd_rsa_prikey *prikey = NULL;
+ struct wd_dtb *wd_qinv = NULL;
+ struct wd_dtb *wd_dq = NULL;
+ struct wd_dtb *wd_dp = NULL;
+ struct wd_dtb *wd_q = NULL;
+ struct wd_dtb *wd_p = NULL;
+ struct wd_dtb *wd_d = NULL;
+ struct wd_dtb *wd_n = NULL;
if (!(rsa_sess->is_prikey_ready) && (pri->is_crt)) {
wd_rsa_get_prikey(rsa_sess->sess, &prikey);
--
1.8.3.1