diff mbox series

crypto: testmgr - Fix format argument warning

Message ID 20201010021637.112091-1-yebin10@huawei.com
State New
Headers show
Series crypto: testmgr - Fix format argument warning | expand

Commit Message

Ye Bin Oct. 10, 2020, 2:16 a.m. UTC
Fix follow warning:
[crypto/testmgr.c:2317]: (warning) %d in format string (no. 5) requires
'int' but the argument type is 'unsigned int'.

Reported-by: Hulk Robot <hulkci@huawei.com>
Signed-off-by: Ye Bin <yebin10@huawei.com>
---
 crypto/testmgr.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

Comments

Eric Biggers Oct. 10, 2020, 6:32 p.m. UTC | #1
On Sat, Oct 10, 2020 at 10:16:37AM +0800, Ye Bin wrote:
> Fix follow warning:

> [crypto/testmgr.c:2317]: (warning) %d in format string (no. 5) requires

> 'int' but the argument type is 'unsigned int'.

> 

> Reported-by: Hulk Robot <hulkci@huawei.com>

> Signed-off-by: Ye Bin <yebin10@huawei.com>

> ---

>  crypto/testmgr.c | 2 +-

>  1 file changed, 1 insertion(+), 1 deletion(-)

> 

> diff --git a/crypto/testmgr.c b/crypto/testmgr.c

> index a64a639eddfa..aefa4b6b8d78 100644

> --- a/crypto/testmgr.c

> +++ b/crypto/testmgr.c

> @@ -2315,7 +2315,7 @@ static void generate_random_aead_testvec(struct aead_request *req,

>  	if (vec->setkey_error == 0 && vec->setauthsize_error == 0)

>  		generate_aead_message(req, suite, vec, prefer_inauthentic);

>  	snprintf(name, max_namelen,

> -		 "\"random: alen=%u plen=%u authsize=%u klen=%u novrfy=%d\"",

> +		 "\"random: alen=%u plen=%u authsize=%u klen=%u novrfy=%u\"",

>  		 vec->alen, vec->plen, authsize, vec->klen, vec->novrfy);


Actually vec->novrfy is 'unsigned char', not 'unsigned int'.  Both %u and %d
will work, but %d is technically correct because 'unsigned char' gets promoted
to 'int'.  What tool are you using that claims this is wrong?

- Eric
diff mbox series

Patch

diff --git a/crypto/testmgr.c b/crypto/testmgr.c
index a64a639eddfa..aefa4b6b8d78 100644
--- a/crypto/testmgr.c
+++ b/crypto/testmgr.c
@@ -2315,7 +2315,7 @@  static void generate_random_aead_testvec(struct aead_request *req,
 	if (vec->setkey_error == 0 && vec->setauthsize_error == 0)
 		generate_aead_message(req, suite, vec, prefer_inauthentic);
 	snprintf(name, max_namelen,
-		 "\"random: alen=%u plen=%u authsize=%u klen=%u novrfy=%d\"",
+		 "\"random: alen=%u plen=%u authsize=%u klen=%u novrfy=%u\"",
 		 vec->alen, vec->plen, authsize, vec->klen, vec->novrfy);
 }