The driver uses a mixture of signed and unsigned integer variables for holding arrays lengths and indices, which gives rise to the following sparse warnings when the addresses of signed variables are passed to functions expecting pointers to unsigned integers: drivers/staging/ccree/cc_buffer_mgr.c:1050:46: warning: incorrect type in argument 4 (different signedness) drivers/staging/ccree/cc_buffer_mgr.c:1050:46: expected unsigned int [usertype] *lbytes drivers/staging/ccree/cc_buffer_mgr.c:1050:46: got int *<noident> drivers/staging/ccree/cc_buffer_mgr.c:1083:62: warning: incorrect type in argument 7 (different signedness) drivers/staging/ccree/cc_buffer_mgr.c:1083:62: expected unsigned int [usertype] *lbytes drivers/staging/ccree/cc_buffer_mgr.c:1083:62: got int *<noident> drivers/staging/ccree/cc_buffer_mgr.c:1092:46: warning: incorrect type in argument 4 (different signedness) drivers/staging/ccree/cc_buffer_mgr.c:1092:46: expected unsigned int [usertype] *lbytes drivers/staging/ccree/cc_buffer_mgr.c:1092:46: got int *<noident> drivers/staging/ccree/cc_buffer_mgr.c:1120:49: warning: incorrect type in argument 4 (different signedness) drivers/staging/ccree/cc_buffer_mgr.c:1120:49: expected unsigned int [usertype] *src_last_bytes drivers/staging/ccree/cc_buffer_mgr.c:1120:49: got int *<noident> drivers/staging/ccree/cc_buffer_mgr.c:1121:49: warning: incorrect type in argument 5 (different signedness) drivers/staging/ccree/cc_buffer_mgr.c:1121:49: expected unsigned int [usertype] *dst_last_bytes drivers/staging/ccree/cc_buffer_mgr.c:1121:49: got int *<noident> drivers/staging/ccree/cc_buffer_mgr.c:1124:49: warning: incorrect type in argument 2 (different signedness) drivers/staging/ccree/cc_buffer_mgr.c:1124:49: expected unsigned int [usertype] *src_last_bytes drivers/staging/ccree/cc_buffer_mgr.c:1124:49: got int *<noident> drivers/staging/ccree/cc_buffer_mgr.c:1125:44: warning: incorrect type in argument 3 (different signedness) drivers/staging/ccree/cc_buffer_mgr.c:1125:44: expected unsigned int [usertype] *dst_last_bytes drivers/staging/ccree/cc_buffer_mgr.c:1125:44: got int *<noident> drivers/staging/ccree/cc_cipher.c:697:67: warning: incorrect type in argument 6 (different signedness) drivers/staging/ccree/cc_cipher.c:697:67: expected unsigned int *seq_size drivers/staging/ccree/cc_cipher.c:697:67: got int *<noident> drivers/staging/ccree/cc_cipher.c:700:31: warning: incorrect type in argument 8 (different signedness) drivers/staging/ccree/cc_cipher.c:700:31: expected unsigned int *seq_size drivers/staging/ccree/cc_cipher.c:700:31: got int *<noident> drivers/staging/ccree/cc_hash.c:480:57: warning: incorrect type in argument 6 (different signedness) drivers/staging/ccree/cc_hash.c:480:57: expected unsigned int *seq_size drivers/staging/ccree/cc_hash.c:480:57: got int *<noident> drivers/staging/ccree/cc_hash.c:530:57: warning: incorrect type in argument 6 (different signedness) drivers/staging/ccree/cc_hash.c:530:57: expected unsigned int *seq_size drivers/staging/ccree/cc_hash.c:530:57: got int *<noident> drivers/staging/ccree/cc_hash.c:1305:43: warning: incorrect type in argument 3 (different signedness) drivers/staging/ccree/cc_hash.c:1305:43: expected unsigned int *seq_size drivers/staging/ccree/cc_hash.c:1305:43: got int *<noident> drivers/staging/ccree/cc_hash.c:1307:43: warning: incorrect type in argument 3 (different signedness) drivers/staging/ccree/cc_hash.c:1307:43: expected unsigned int *seq_size drivers/staging/ccree/cc_hash.c:1307:43: got int *<noident> drivers/staging/ccree/cc_hash.c:1317:69: warning: incorrect type in argument 6 (different signedness) drivers/staging/ccree/cc_hash.c:1317:69: expected unsigned int *seq_size drivers/staging/ccree/cc_hash.c:1317:69: got int *<noident> drivers/staging/ccree/cc_hash.c:1390:43: warning: incorrect type in argument 3 (different signedness) drivers/staging/ccree/cc_hash.c:1390:43: expected unsigned int *seq_size drivers/staging/ccree/cc_hash.c:1390:43: got int *<noident> drivers/staging/ccree/cc_hash.c:1393:43: warning: incorrect type in argument 3 (different signedness) drivers/staging/ccree/cc_hash.c:1393:43: expected unsigned int *seq_size drivers/staging/ccree/cc_hash.c:1393:43: got int *<noident> drivers/staging/ccree/cc_hash.c:1404:69: warning: incorrect type in argument 6 (different signedness) drivers/staging/ccree/cc_hash.c:1404:69: expected unsigned int *seq_size drivers/staging/ccree/cc_hash.c:1404:69: got int *<noident> drivers/staging/ccree/cc_hash.c:1469:43: warning: incorrect type in argument 3 (different signedness) drivers/staging/ccree/cc_hash.c:1469:43: expected unsigned int *seq_size drivers/staging/ccree/cc_hash.c:1469:43: got int *<noident> drivers/staging/ccree/cc_hash.c:1472:43: warning: incorrect type in argument 3 (different signedness) drivers/staging/ccree/cc_hash.c:1472:43: expected unsigned int *seq_size drivers/staging/ccree/cc_hash.c:1472:43: got int *<noident> drivers/staging/ccree/cc_hash.c:1483:69: warning: incorrect type in argument 6 (different signedness) drivers/staging/ccree/cc_hash.c:1483:69: expected unsigned int *seq_size drivers/staging/ccree/cc_hash.c:1483:69: got int *<noident> drivers/staging/ccree/cc_aead.c:2011:37: warning: incorrect type in argument 3 (different signedness) drivers/staging/ccree/cc_aead.c:2011:37: expected unsigned int *seq_size drivers/staging/ccree/cc_aead.c:2011:37: got int *<noident> drivers/staging/ccree/cc_aead.c:2017:45: warning: incorrect type in argument 3 (different signedness) drivers/staging/ccree/cc_aead.c:2017:45: expected unsigned int *seq_size drivers/staging/ccree/cc_aead.c:2017:45: got int *<noident> drivers/staging/ccree/cc_aead.c:2020:45: warning: incorrect type in argument 3 (different signedness) drivers/staging/ccree/cc_aead.c:2020:45: expected unsigned int *seq_size drivers/staging/ccree/cc_aead.c:2020:45: got int *<noident> drivers/staging/ccree/cc_aead.c:2024:44: warning: incorrect type in argument 3 (different signedness) drivers/staging/ccree/cc_aead.c:2024:44: expected unsigned int *seq_size drivers/staging/ccree/cc_aead.c:2024:44: got int *<noident> drivers/staging/ccree/cc_aead.c:2026:44: warning: incorrect type in argument 3 (different signedness) drivers/staging/ccree/cc_aead.c:2026:44: expected unsigned int *seq_size drivers/staging/ccree/cc_aead.c:2026:44: got int *<noident> This patch fixes those warnings by converting those signed variables to unsigned as follows: * changed the types of a number of index and length variables from signed to unsigned integer types. * changed the return-types of a couple of functions that return length values which are assigned to one of these variables from signed to unsigned integer types. Signed-off-by: Jeremy Sowden <jeremy@xxxxxxxxxx> --- In v7: * Added missing CC. In v6: * Dropped the removal of the hard-coded index values. * Included the sparse warnings in the change-log. In v5: * White-space errors fixed. In v4: * Split the removal of the hard-coded index values into a separate patch. In v3: * removed hard-coded index values. * more detailed change-log. * fixed formatting. In v2: * more detailed change-log. drivers/staging/ccree/cc_aead.c | 13 ++++++++----- drivers/staging/ccree/cc_buffer_mgr.c | 2 +- drivers/staging/ccree/cc_cipher.c | 3 ++- drivers/staging/ccree/cc_hash.c | 17 +++++++++-------- 4 files changed, 20 insertions(+), 15 deletions(-) drivers/staging/ccree/cc_aead.c | 13 ++++++++----- drivers/staging/ccree/cc_buffer_mgr.c | 2 +- drivers/staging/ccree/cc_cipher.c | 3 ++- drivers/staging/ccree/cc_hash.c | 17 +++++++++-------- 4 files changed, 20 insertions(+), 15 deletions(-) diff --git a/drivers/staging/ccree/cc_aead.c b/drivers/staging/ccree/cc_aead.c index b58413172231..1a58040111c7 100644 --- a/drivers/staging/ccree/cc_aead.c +++ b/drivers/staging/ccree/cc_aead.c @@ -257,7 +257,8 @@ static void cc_aead_complete(struct device *dev, void *cc_req, int err) aead_request_complete(areq, err); } -static int xcbc_setkey(struct cc_hw_desc *desc, struct cc_aead_ctx *ctx) +static unsigned int xcbc_setkey(struct cc_hw_desc *desc, + struct cc_aead_ctx *ctx) { /* Load the AES key */ hw_desc_init(&desc[0]); @@ -297,7 +298,8 @@ static int xcbc_setkey(struct cc_hw_desc *desc, struct cc_aead_ctx *ctx) return 4; } -static int hmac_setkey(struct cc_hw_desc *desc, struct cc_aead_ctx *ctx) +static unsigned int hmac_setkey(struct cc_hw_desc *desc, + struct cc_aead_ctx *ctx) { unsigned int hmac_pad_const[2] = { HMAC_IPAD_CONST, HMAC_OPAD_CONST }; unsigned int digest_ofs = 0; @@ -307,7 +309,7 @@ static int hmac_setkey(struct cc_hw_desc *desc, struct cc_aead_ctx *ctx) CC_SHA1_DIGEST_SIZE : CC_SHA256_DIGEST_SIZE; struct cc_hmac_s *hmac = &ctx->auth_state.hmac; - int idx = 0; + unsigned int idx = 0; int i; /* calc derived HMAC key */ @@ -544,7 +546,8 @@ cc_aead_setkey(struct crypto_aead *tfm, const u8 *key, unsigned int keylen) struct cc_crypto_req cc_req = {}; struct crypto_authenc_key_param *param; struct cc_hw_desc desc[MAX_AEAD_SETKEY_SEQ]; - int seq_len = 0, rc = -EINVAL; + unsigned int seq_len = 0; + int rc = -EINVAL; struct device *dev = drvdata_to_dev(ctx->drvdata); dev_dbg(dev, "Setting key in context @%p for %s. key=%p keylen=%u\n", @@ -1883,7 +1886,7 @@ static int cc_proc_aead(struct aead_request *req, enum drv_crypto_direction direct) { int rc = 0; - int seq_len = 0; + unsigned int seq_len = 0; struct cc_hw_desc desc[MAX_AEAD_PROCESS_SEQ]; struct crypto_aead *tfm = crypto_aead_reqtfm(req); struct cc_aead_ctx *ctx = crypto_aead_ctx(tfm); diff --git a/drivers/staging/ccree/cc_buffer_mgr.c b/drivers/staging/ccree/cc_buffer_mgr.c index 14b2eabbf70a..6dbc9b4d6eb8 100644 --- a/drivers/staging/ccree/cc_buffer_mgr.c +++ b/drivers/staging/ccree/cc_buffer_mgr.c @@ -1018,7 +1018,7 @@ static int cc_aead_chain_data(struct cc_drvdata *drvdata, struct device *dev = drvdata_to_dev(drvdata); enum drv_crypto_direction direct = areq_ctx->gen_ctx.op_type; unsigned int authsize = areq_ctx->req_authsize; - int src_last_bytes = 0, dst_last_bytes = 0; + u32 src_last_bytes = 0, dst_last_bytes = 0; int rc = 0; u32 src_mapped_nents = 0, dst_mapped_nents = 0; u32 offset = 0; diff --git a/drivers/staging/ccree/cc_cipher.c b/drivers/staging/ccree/cc_cipher.c index 5c7e91f1cde7..3a356ceef911 100644 --- a/drivers/staging/ccree/cc_cipher.c +++ b/drivers/staging/ccree/cc_cipher.c @@ -630,7 +630,8 @@ static int cc_cipher_process(struct ablkcipher_request *req, struct device *dev = drvdata_to_dev(ctx_p->drvdata); struct cc_hw_desc desc[MAX_ABLKCIPHER_SEQ_LEN]; struct cc_crypto_req cc_req = {}; - int rc, seq_len = 0, cts_restore_flag = 0; + int rc, cts_restore_flag = 0; + unsigned int seq_len = 0; gfp_t flags = cc_gfp_flags(&req->base); dev_dbg(dev, "%s req=%p info=%p nbytes=%d\n", diff --git a/drivers/staging/ccree/cc_hash.c b/drivers/staging/ccree/cc_hash.c index 8afc39f10bb3..9529f16d168d 100644 --- a/drivers/staging/ccree/cc_hash.c +++ b/drivers/staging/ccree/cc_hash.c @@ -410,7 +410,7 @@ static int cc_hash_digest(struct ahash_request *req) struct cc_hw_desc desc[CC_MAX_HASH_SEQ_LEN]; cc_sram_addr_t larval_digest_addr = cc_larval_digest_addr(ctx->drvdata, ctx->hash_mode); - int idx = 0; + unsigned int idx = 0; int rc = 0; gfp_t flags = cc_gfp_flags(&req->base); @@ -506,7 +506,7 @@ static int cc_hash_digest(struct ahash_request *req) } static int cc_restore_hash(struct cc_hw_desc *desc, struct cc_hash_ctx *ctx, - struct ahash_req_ctx *state, int idx) + struct ahash_req_ctx *state, unsigned int idx) { /* Restore hash digest */ hw_desc_init(&desc[idx]); @@ -621,7 +621,7 @@ static int cc_hash_finup(struct ahash_request *req) bool is_hmac = ctx->is_hmac; struct cc_crypto_req cc_req = {}; struct cc_hw_desc desc[CC_MAX_HASH_SEQ_LEN]; - int idx = 0; + unsigned int idx = 0; int rc; gfp_t flags = cc_gfp_flags(&req->base); @@ -680,7 +680,7 @@ static int cc_hash_final(struct ahash_request *req) bool is_hmac = ctx->is_hmac; struct cc_crypto_req cc_req = {}; struct cc_hw_desc desc[CC_MAX_HASH_SEQ_LEN]; - int idx = 0; + unsigned int idx = 0; int rc; gfp_t flags = cc_gfp_flags(&req->base); @@ -945,7 +945,8 @@ static int cc_xcbc_setkey(struct crypto_ahash *ahash, struct cc_crypto_req cc_req = {}; struct cc_hash_ctx *ctx = crypto_ahash_ctx(ahash); struct device *dev = drvdata_to_dev(ctx->drvdata); - int idx = 0, rc = 0; + unsigned int idx = 0; + int rc = 0; struct cc_hw_desc desc[CC_MAX_HASH_SEQ_LEN]; dev_dbg(dev, "===== setkey (%d) ====\n", keylen); @@ -1229,7 +1230,7 @@ static int cc_mac_final(struct ahash_request *req) struct device *dev = drvdata_to_dev(ctx->drvdata); struct cc_crypto_req cc_req = {}; struct cc_hw_desc desc[CC_MAX_HASH_SEQ_LEN]; - int idx = 0; + unsigned int idx = 0; int rc = 0; u32 key_size, key_len; u32 digestsize = crypto_ahash_digestsize(tfm); @@ -1351,7 +1352,7 @@ static int cc_mac_finup(struct ahash_request *req) struct device *dev = drvdata_to_dev(ctx->drvdata); struct cc_crypto_req cc_req = {}; struct cc_hw_desc desc[CC_MAX_HASH_SEQ_LEN]; - int idx = 0; + unsigned int idx = 0; int rc = 0; u32 key_len = 0; u32 digestsize = crypto_ahash_digestsize(tfm); @@ -1435,7 +1436,7 @@ static int cc_mac_digest(struct ahash_request *req) struct cc_crypto_req cc_req = {}; struct cc_hw_desc desc[CC_MAX_HASH_SEQ_LEN]; u32 key_len; - int idx = 0; + unsigned int idx = 0; int rc; gfp_t flags = cc_gfp_flags(&req->base); base-commit: 197ecafc874d240ef069122479341f1382848ee1 -- 2.15.1 _______________________________________________ devel mailing list devel@xxxxxxxxxxxxxxxxxxxxxx http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel