Truncation may occur before type conversion, use force cast to eliminate errors.
Signed-off-by: Wenkai Lin linwenkai6@hisilicon.com --- v1/drv/hisi_hpre_udrv.c | 18 +++++++++--------- v1/wd_rsa.c | 12 ++++++------ wd_mempool.c | 2 +- wd_rsa.c | 12 ++++++------ 4 files changed, 22 insertions(+), 22 deletions(-)
diff --git a/v1/drv/hisi_hpre_udrv.c b/v1/drv/hisi_hpre_udrv.c index 7ce8f47..9496737 100644 --- a/v1/drv/hisi_hpre_udrv.c +++ b/v1/drv/hisi_hpre_udrv.c @@ -286,7 +286,7 @@ static int qm_rsa_out_transfer(struct wcrypto_rsa_msg *msg, msg->result = WD_SUCCESS; if (hw_msg->alg == HPRE_ALG_KG_CRT) { msg->out_bytes = CRT_GEN_PARAMS_SZ(kbytes); - *in_len = GEN_PARAMS_SZ(kbytes); + *in_len = (size_t)GEN_PARAMS_SZ(kbytes); *out_len = msg->out_bytes; wcrypto_get_rsa_kg_out_crt_params(key, &qinv, &dq, &dp); ret = qm_tri_bin_transfer(&qinv, &dq, &dp, "rsa kg qinv&dp&dq"); @@ -298,7 +298,7 @@ static int qm_rsa_out_transfer(struct wcrypto_rsa_msg *msg, } else if (hw_msg->alg == HPRE_ALG_KG_STD) { msg->out_bytes = GEN_PARAMS_SZ(kbytes); *out_len = msg->out_bytes; - *in_len = GEN_PARAMS_SZ(kbytes); + *in_len = (size_t)GEN_PARAMS_SZ(kbytes);
wcrypto_get_rsa_kg_out_params(key, &d, &n); ret = qm_tri_bin_transfer(&d, &n, NULL, "rsa kg d & n"); @@ -535,11 +535,11 @@ int qm_parse_rsa_sqe(void *msg, const struct qm_queue_info *info, }
if (hw_msg->alg == HPRE_ALG_KG_CRT) { - olen = CRT_GEN_PARAMS_SZ(kbytes); - ilen = GEN_PARAMS_SZ(kbytes); + olen = (size_t)CRT_GEN_PARAMS_SZ(kbytes); + ilen = (size_t)GEN_PARAMS_SZ(kbytes); } else if (hw_msg->alg == HPRE_ALG_KG_STD) { - olen = GEN_PARAMS_SZ(kbytes); - ilen = GEN_PARAMS_SZ(kbytes); + olen = (size_t)GEN_PARAMS_SZ(kbytes); + ilen = (size_t)GEN_PARAMS_SZ(kbytes); } else { olen = kbytes; ilen = kbytes; @@ -598,7 +598,7 @@ static void dh_xp_unmap(struct wcrypto_dh_msg *msg, struct wd_queue *q, { uintptr_t phy = DMA_ADDR(hw_msg->low_key, hw_msg->hi_key);
- drv_iova_unmap(q, msg->x_p, (void *)phy, GEN_PARAMS_SZ(msg->key_bytes)); + drv_iova_unmap(q, msg->x_p, (void *)phy, (size_t)GEN_PARAMS_SZ(msg->key_bytes)); }
static int qm_fill_dh_xp_params(struct wd_queue *q, struct wcrypto_dh_msg *msg, @@ -621,7 +621,7 @@ static int qm_fill_dh_xp_params(struct wd_queue *q, struct wcrypto_dh_msg *msg, return ret;
phy = (uintptr_t)drv_iova_map(q, (void *)x, - GEN_PARAMS_SZ(msg->key_bytes)); + (size_t)GEN_PARAMS_SZ(msg->key_bytes)); if (unlikely(!phy)) { WD_ERR("get dh xp parameter dma address fail!\n"); return -WD_ENOMEM; @@ -760,7 +760,7 @@ int qm_parse_dh_sqe(void *msg, const struct qm_queue_info *info, drv_iova_unmap(q, dh_msg->out, (void *)(uintptr_t)dma_out, dh_msg->key_bytes); drv_iova_unmap(q, NULL, (void *)(uintptr_t)dma_in, - GEN_PARAMS_SZ(dh_msg->key_bytes)); + (size_t)GEN_PARAMS_SZ(dh_msg->key_bytes)); drv_iova_unmap(q, NULL, (void *)(uintptr_t)dma_key, dh_msg->key_bytes); return 1; } diff --git a/v1/wd_rsa.c b/v1/wd_rsa.c index c5c109d..702f6be 100644 --- a/v1/wd_rsa.c +++ b/v1/wd_rsa.c @@ -178,7 +178,7 @@ static int kg_in_param_check(void *ctx, struct wd_dtb *e, return -WD_EINVAL; }
- kg_in_size = GEN_PARAMS_SZ(c->key_size); + kg_in_size = (int)GEN_PARAMS_SZ(c->key_size); if (unlikely(br->get_bufsize && br->get_bufsize(br->usr) < (kg_in_size + sizeof(*kg_in)))) { WD_ERR("Blk_size < need_size<0x%lx>.\n", (kg_in_size + sizeof(*kg_in))); @@ -202,7 +202,7 @@ struct wcrypto_rsa_kg_in *wcrypto_new_kg_in(void *ctx, struct wd_dtb *e, return NULL;
br = &c->setup.br; - kg_in_size = GEN_PARAMS_SZ(c->key_size); + kg_in_size = (int)GEN_PARAMS_SZ(c->key_size); kg_in = br->alloc(br->usr, kg_in_size + sizeof(*kg_in)); if (unlikely(!kg_in)) { WD_ERR("ctx br->alloc kg_in memory fail!\n"); @@ -285,7 +285,7 @@ struct wcrypto_rsa_kg_out *wcrypto_new_kg_out(void *ctx) if (c->setup.is_crt) kg_out_size = CRT_GEN_PARAMS_SZ(c->key_size); else - kg_out_size = GEN_PARAMS_SZ(c->key_size); + kg_out_size = (int)GEN_PARAMS_SZ(c->key_size);
br = &c->setup.br; if (unlikely(!br->alloc)) { @@ -434,7 +434,7 @@ static int create_ctx_key(struct wcrypto_rsa_ctx_setup *setup,
if (setup->is_crt) { len = sizeof(struct wcrypto_rsa_prikey) + - CRT_PARAMS_SZ(ctx->key_size); + (__u32)CRT_PARAMS_SZ(ctx->key_size); if (br->get_bufsize && br->get_bufsize(br->usr) < len) { WD_ERR("Blk_size < need_size<0x%x>.\n", len); return -WD_ENOMEM; @@ -449,7 +449,7 @@ static int create_ctx_key(struct wcrypto_rsa_ctx_setup *setup, init_pkey2(pkey2, ctx->key_size); } else { len = sizeof(struct wcrypto_rsa_prikey) + - GEN_PARAMS_SZ(ctx->key_size); + (__u32)GEN_PARAMS_SZ(ctx->key_size); if (br->get_bufsize && br->get_bufsize(br->usr) < len) { WD_ERR("Blk_size < need_size<0x%x>.\n", len); return -WD_ENOMEM; @@ -464,7 +464,7 @@ static int create_ctx_key(struct wcrypto_rsa_ctx_setup *setup, init_pkey1(pkey1, ctx->key_size); }
- len = sizeof(struct wcrypto_rsa_pubkey) + GEN_PARAMS_SZ(ctx->key_size); + len = sizeof(struct wcrypto_rsa_pubkey) + (__u32)GEN_PARAMS_SZ(ctx->key_size); if (br->get_bufsize && br->get_bufsize(br->usr) < len) { br->free(br->usr, ctx->prikey); WD_ERR("Blk_size < need_size<0x%x>.\n", len); diff --git a/wd_mempool.c b/wd_mempool.c index db88fb0..1bdc0f4 100644 --- a/wd_mempool.c +++ b/wd_mempool.c @@ -795,7 +795,7 @@ static int mbind_memory(void *addr, size_t size, int node) unsigned long node_mask; int ret = 0;
- node_mask = 1U << (unsigned int)node; + node_mask = (unsigned long)(1 << (unsigned int)node); ret = mbind(addr, size, MPOL_BIND, &node_mask, max_node, 0); if (ret < 0) { WD_ERR("failed to mbind memory, ret is %d!\n", ret); diff --git a/wd_rsa.c b/wd_rsa.c index 9e8c264..7e71a17 100644 --- a/wd_rsa.c +++ b/wd_rsa.c @@ -607,7 +607,7 @@ struct wd_rsa_kg_in *wd_rsa_new_kg_in(handle_t sess, struct wd_dtb *e, return NULL; }
- kg_in_size = GEN_PARAMS_SZ(c->key_size); + kg_in_size = (int)GEN_PARAMS_SZ(c->key_size); kg_in = malloc(kg_in_size + sizeof(*kg_in)); if (!kg_in) { WD_ERR("failed to malloc kg_in memory!\n"); @@ -682,9 +682,9 @@ struct wd_rsa_kg_out *wd_rsa_new_kg_out(handle_t sess) }
if (c->setup.is_crt) - kg_out_size = CRT_GEN_PARAMS_SZ(c->key_size); + kg_out_size = (int)CRT_GEN_PARAMS_SZ(c->key_size); else - kg_out_size = GEN_PARAMS_SZ(c->key_size); + kg_out_size = (int)GEN_PARAMS_SZ(c->key_size);
kg_out = malloc(kg_out_size + sizeof(*kg_out)); if (!kg_out) { @@ -828,7 +828,7 @@ static int create_sess_key(struct wd_rsa_sess_setup *setup,
if (setup->is_crt) { len = sizeof(struct wd_rsa_prikey) + - CRT_PARAMS_SZ(sess->key_size); + (int)CRT_PARAMS_SZ(sess->key_size); sess->prikey = malloc(len); if (!sess->prikey) { WD_ERR("failed to alloc sess prikey2!\n"); @@ -839,7 +839,7 @@ static int create_sess_key(struct wd_rsa_sess_setup *setup, init_pkey2(pkey2, sess->key_size); } else { len = sizeof(struct wd_rsa_prikey) + - GEN_PARAMS_SZ(sess->key_size); + (int)GEN_PARAMS_SZ(sess->key_size); sess->prikey = malloc(len); if (!sess->prikey) { WD_ERR("failed to alloc sess prikey1!\n"); @@ -851,7 +851,7 @@ static int create_sess_key(struct wd_rsa_sess_setup *setup, }
len = sizeof(struct wd_rsa_pubkey) + - GEN_PARAMS_SZ(sess->key_size); + (int)GEN_PARAMS_SZ(sess->key_size); sess->pubkey = malloc(len); if (!sess->pubkey) { free(sess->prikey);