From: Chenghai Huang <huangchenghai2@huawei.com> Several variables use narrower types than their assignments, causing implicit narrowing and sign-comparison warnings under static analysis and stricter toolchains. - widen destroy_aead and uadk_e_destroy_aead num to __u32 - widen digest processing_len to size_t in uadk_digest - cast BN_bn2bin results to __u32 for dsize in uadk_rsa - remove redundant blank line in ecx compkey functions Signed-off-by: Chenghai Huang <huangchenghai2@huawei.com> --- src/uadk_aead.c | 4 ++-- src/uadk_cipher_adapter.h | 2 +- src/uadk_digest.c | 3 ++- src/uadk_ecx.c | 1 - src/uadk_prov_ecx.c | 1 - src/uadk_rsa.c | 6 +++--- 6 files changed, 8 insertions(+), 9 deletions(-) diff --git a/src/uadk_aead.c b/src/uadk_aead.c index a026284..b88d034 100644 --- a/src/uadk_aead.c +++ b/src/uadk_aead.c @@ -796,7 +796,7 @@ EVP_CIPHER *uadk_create_gcm_cipher_meth(int nid) return aead; } -static void destroy_aead(struct engine_cipher_info *info, int num) +static void destroy_aead(struct engine_cipher_info *info, __u32 num) { __u32 i; @@ -808,7 +808,7 @@ static void destroy_aead(struct engine_cipher_info *info, int num) } } -void uadk_e_destroy_aead(struct engine_cipher_info *info, int num) +void uadk_e_destroy_aead(struct engine_cipher_info *info, __u32 num) { __u32 i; int ret; diff --git a/src/uadk_cipher_adapter.h b/src/uadk_cipher_adapter.h index f7b6fb4..011f98c 100644 --- a/src/uadk_cipher_adapter.h +++ b/src/uadk_cipher_adapter.h @@ -28,7 +28,7 @@ struct engine_cipher_info { EVP_CIPHER *uadk_create_gcm_cipher_meth(int nid); EVP_CIPHER *uadk_create_cipher_meth(int nid); -void uadk_e_destroy_aead(struct engine_cipher_info *info, int num); +void uadk_e_destroy_aead(struct engine_cipher_info *info, __u32 num); void uadk_e_destroy_cipher(struct engine_cipher_info *info, int num); int uadk_e_bind_ciphers(ENGINE *e); diff --git a/src/uadk_digest.c b/src/uadk_digest.c index 29448b7..e18b25b 100644 --- a/src/uadk_digest.c +++ b/src/uadk_digest.c @@ -679,7 +679,8 @@ static int digest_update_inner(EVP_MD_CTX *ctx, const void *data, size_t data_le (struct digest_priv_ctx *)EVP_MD_CTX_md_data(ctx); const unsigned char *tmpdata = (const unsigned char *)data; size_t left_len = data_len; - int ret, processing_len; + size_t processing_len; + int ret; if (unlikely(!priv)) { fprintf(stderr, "priv get from digest ctx is NULL.\n"); diff --git a/src/uadk_ecx.c b/src/uadk_ecx.c index 3a33968..cbec886 100644 --- a/src/uadk_ecx.c +++ b/src/uadk_ecx.c @@ -652,7 +652,6 @@ static int ecx_compkey_init_iot(struct ecx_ctx *ecx_ctx, struct wd_ecc_req *req, uadk_ecc_fill_req(req, WD_ECXDH_COMPUTE_KEY, ecx_in, ecx_out); return UADK_E_SUCCESS; - } static void ecx_compkey_uninit_iot(handle_t sess, struct wd_ecc_req *req) diff --git a/src/uadk_prov_ecx.c b/src/uadk_prov_ecx.c index 9f0335f..7820b29 100644 --- a/src/uadk_prov_ecx.c +++ b/src/uadk_prov_ecx.c @@ -1058,7 +1058,6 @@ static int uadk_prov_ecx_compkey_init_iot(PROV_ECX_KEYEXCH_CTX *ecxctx, struct w uadk_prov_ecc_fill_req(req, WD_ECXDH_COMPUTE_KEY, ecx_in, ecx_out); return UADK_P_SUCCESS; - } static void uadk_prov_ecx_compkey_uninit_iot(PROV_ECX_KEYEXCH_CTX *ecxctx, struct wd_ecc_req *req) diff --git a/src/uadk_rsa.c b/src/uadk_rsa.c index 8774d5d..e692ea7 100644 --- a/src/uadk_rsa.c +++ b/src/uadk_rsa.c @@ -1288,7 +1288,7 @@ static int rsa_fill_keygen_data(struct uadk_rsa_sess *rsa_sess, if (!keygen_param->wd_e) return UADK_E_FAIL; - keygen_param->wd_e->dsize = BN_bn2bin(bn_param->e, + keygen_param->wd_e->dsize = (__u32)BN_bn2bin(bn_param->e, (unsigned char *)keygen_param->wd_e->data); wd_rsa_get_prikey(rsa_sess->sess, &key_pair->prikey); @@ -1300,9 +1300,9 @@ static int rsa_fill_keygen_data(struct uadk_rsa_sess *rsa_sess, if (!keygen_param->wd_q || !keygen_param->wd_p) return UADK_E_FAIL; - keygen_param->wd_q->dsize = BN_bn2bin(bn_param->q, + keygen_param->wd_q->dsize = (__u32)BN_bn2bin(bn_param->q, (unsigned char *)keygen_param->wd_q->data); - keygen_param->wd_p->dsize = BN_bn2bin(bn_param->p, + keygen_param->wd_p->dsize = (__u32)BN_bn2bin(bn_param->p, (unsigned char *)keygen_param->wd_p->data); rsa_sess->req.src_bytes = rsa_sess->key_size; -- 2.43.0