diff mbox series

[3/3] crypto: Redundant type conversion for AES_KEY pointer

Message ID 20200325092137.24020-4-kuhn.chenqun@huawei.com
State New
Headers show
Series Three trivial patchs | expand

Commit Message

Chen Qun March 25, 2020, 9:21 a.m. UTC
Fix: eaec903c5b8

Reported-by: Euler Robot <euler.robot@huawei.com>
Signed-off-by: Chen Qun <kuhn.chenqun@huawei.com>
---
Cc: "Daniel P. Berrangé" <berrange@redhat.com>
---
 crypto/cipher-builtin.c | 6 ++----
 1 file changed, 2 insertions(+), 4 deletions(-)

Comments

Laurent Vivier March 25, 2020, 9:45 a.m. UTC | #1
Le 25/03/2020 à 10:21, Chen Qun a écrit :
> Fix: eaec903c5b8
>

Did you run the coccinelle script scripts/coccinelle/typecast.cocci ?

Thanks,
Laurent

> Reported-by: Euler Robot <euler.robot@huawei.com>
> Signed-off-by: Chen Qun <kuhn.chenqun@huawei.com>
> ---
> Cc: "Daniel P. Berrangé" <berrange@redhat.com>
> ---
>  crypto/cipher-builtin.c | 6 ++----
>  1 file changed, 2 insertions(+), 4 deletions(-)
> 
> diff --git a/crypto/cipher-builtin.c b/crypto/cipher-builtin.c
> index bf8413e71a..99d6280a16 100644
> --- a/crypto/cipher-builtin.c
> +++ b/crypto/cipher-builtin.c
> @@ -133,8 +133,7 @@ static void qcrypto_cipher_aes_xts_encrypt(const void *ctx,
>  {
>      const QCryptoCipherBuiltinAESContext *aesctx = ctx;
>  
> -    qcrypto_cipher_aes_ecb_encrypt((AES_KEY *)&aesctx->enc,
> -                                   src, dst, length);
> +    qcrypto_cipher_aes_ecb_encrypt(&aesctx->enc, src, dst, length);
>  }
>  
>  
> @@ -145,8 +144,7 @@ static void qcrypto_cipher_aes_xts_decrypt(const void *ctx,
>  {
>      const QCryptoCipherBuiltinAESContext *aesctx = ctx;
>  
> -    qcrypto_cipher_aes_ecb_decrypt((AES_KEY *)&aesctx->dec,
> -                                   src, dst, length);
> +    qcrypto_cipher_aes_ecb_decrypt(&aesctx->dec, src, dst, length);
>  }
>  
>  
>
Daniel P. Berrangé March 25, 2020, 9:45 a.m. UTC | #2
On Wed, Mar 25, 2020 at 05:21:37PM +0800, Chen Qun wrote:
> Fix: eaec903c5b8
> 
> Reported-by: Euler Robot <euler.robot@huawei.com>
> Signed-off-by: Chen Qun <kuhn.chenqun@huawei.com>
> ---
> Cc: "Daniel P. Berrangé" <berrange@redhat.com>
> ---
>  crypto/cipher-builtin.c | 6 ++----
>  1 file changed, 2 insertions(+), 4 deletions(-)

Acked-by: Daniel P. Berrangé <berrange@redhat.com>

> 
> diff --git a/crypto/cipher-builtin.c b/crypto/cipher-builtin.c
> index bf8413e71a..99d6280a16 100644
> --- a/crypto/cipher-builtin.c
> +++ b/crypto/cipher-builtin.c
> @@ -133,8 +133,7 @@ static void qcrypto_cipher_aes_xts_encrypt(const void *ctx,
>  {
>      const QCryptoCipherBuiltinAESContext *aesctx = ctx;
>  
> -    qcrypto_cipher_aes_ecb_encrypt((AES_KEY *)&aesctx->enc,
> -                                   src, dst, length);
> +    qcrypto_cipher_aes_ecb_encrypt(&aesctx->enc, src, dst, length);
>  }
>  
>  
> @@ -145,8 +144,7 @@ static void qcrypto_cipher_aes_xts_decrypt(const void *ctx,
>  {
>      const QCryptoCipherBuiltinAESContext *aesctx = ctx;
>  
> -    qcrypto_cipher_aes_ecb_decrypt((AES_KEY *)&aesctx->dec,
> -                                   src, dst, length);
> +    qcrypto_cipher_aes_ecb_decrypt(&aesctx->dec, src, dst, length);
>  }
>  
>  
> -- 
> 2.23.0
> 
> 

Regards,
Daniel
Chen Qun March 25, 2020, 10:06 a.m. UTC | #3
>-----Original Message-----
>From: Laurent Vivier [mailto:laurent@vivier.eu]
>Sent: Wednesday, March 25, 2020 5:45 PM
>To: Chenqun (kuhn) <kuhn.chenqun@huawei.com>; qemu-devel@nongnu.org;
>qemu-trivial@nongnu.org
>Cc: Zhanghailiang <zhang.zhanghailiang@huawei.com>; Euler Robot
><euler.robot@huawei.com>; Daniel P. Berrangé <berrange@redhat.com>
>Subject: Re: [PATCH 3/3] crypto: Redundant type conversion for AES_KEY pointer
>
>Le 25/03/2020 à 10:21, Chen Qun a écrit :
>> Fix: eaec903c5b8
>>
>
>Did you run the coccinelle script scripts/coccinelle/typecast.cocci ?
>
Yes, I run it and plan to integrate it into EulerRobot so that similar issues can be discovered sooner.

Thanks.
>
>> Reported-by: Euler Robot <euler.robot@huawei.com>
>> Signed-off-by: Chen Qun <kuhn.chenqun@huawei.com>
>> ---
>> Cc: "Daniel P. Berrangé" <berrange@redhat.com>
>> ---
>>  crypto/cipher-builtin.c | 6 ++----
>>  1 file changed, 2 insertions(+), 4 deletions(-)
>>
>> diff --git a/crypto/cipher-builtin.c b/crypto/cipher-builtin.c index
>> bf8413e71a..99d6280a16 100644
>> --- a/crypto/cipher-builtin.c
>> +++ b/crypto/cipher-builtin.c
>> @@ -133,8 +133,7 @@ static void qcrypto_cipher_aes_xts_encrypt(const
>> void *ctx,  {
>>      const QCryptoCipherBuiltinAESContext *aesctx = ctx;
>>
>> -    qcrypto_cipher_aes_ecb_encrypt((AES_KEY *)&aesctx->enc,
>> -                                   src, dst, length);
>> +    qcrypto_cipher_aes_ecb_encrypt(&aesctx->enc, src, dst, length);
>>  }
>>
>>
>> @@ -145,8 +144,7 @@ static void qcrypto_cipher_aes_xts_decrypt(const
>> void *ctx,  {
>>      const QCryptoCipherBuiltinAESContext *aesctx = ctx;
>>
>> -    qcrypto_cipher_aes_ecb_decrypt((AES_KEY *)&aesctx->dec,
>> -                                   src, dst, length);
>> +    qcrypto_cipher_aes_ecb_decrypt(&aesctx->dec, src, dst, length);
>>  }
>>
>>
>>
Laurent Vivier March 25, 2020, 10:14 a.m. UTC | #4
Le 25/03/2020 à 11:06, Chenqun (kuhn) a écrit :
>> -----Original Message-----
>> From: Laurent Vivier [mailto:laurent@vivier.eu]
>> Sent: Wednesday, March 25, 2020 5:45 PM
>> To: Chenqun (kuhn) <kuhn.chenqun@huawei.com>; qemu-devel@nongnu.org;
>> qemu-trivial@nongnu.org
>> Cc: Zhanghailiang <zhang.zhanghailiang@huawei.com>; Euler Robot
>> <euler.robot@huawei.com>; Daniel P. Berrangé <berrange@redhat.com>
>> Subject: Re: [PATCH 3/3] crypto: Redundant type conversion for AES_KEY pointer
>>
>> Le 25/03/2020 à 10:21, Chen Qun a écrit :
>>> Fix: eaec903c5b8
>>>
>>
>> Did you run the coccinelle script scripts/coccinelle/typecast.cocci ?
>>
> Yes, I run it and plan to integrate it into EulerRobot so that similar issues can be discovered sooner.
> 
> Thanks.
>>
>>> Reported-by: Euler Robot <euler.robot@huawei.com>
>>> Signed-off-by: Chen Qun <kuhn.chenqun@huawei.com>
>>> ---
>>> Cc: "Daniel P. Berrangé" <berrange@redhat.com>
>>> ---
>>>  crypto/cipher-builtin.c | 6 ++----
>>>  1 file changed, 2 insertions(+), 4 deletions(-)
>>>
>>> diff --git a/crypto/cipher-builtin.c b/crypto/cipher-builtin.c index
>>> bf8413e71a..99d6280a16 100644
>>> --- a/crypto/cipher-builtin.c
>>> +++ b/crypto/cipher-builtin.c
>>> @@ -133,8 +133,7 @@ static void qcrypto_cipher_aes_xts_encrypt(const
>>> void *ctx,  {
>>>      const QCryptoCipherBuiltinAESContext *aesctx = ctx;
>>>
>>> -    qcrypto_cipher_aes_ecb_encrypt((AES_KEY *)&aesctx->enc,
>>> -                                   src, dst, length);
>>> +    qcrypto_cipher_aes_ecb_encrypt(&aesctx->enc, src, dst, length);
>>>  }
>>>
>>>
>>> @@ -145,8 +144,7 @@ static void qcrypto_cipher_aes_xts_decrypt(const
>>> void *ctx,  {
>>>      const QCryptoCipherBuiltinAESContext *aesctx = ctx;
>>>
>>> -    qcrypto_cipher_aes_ecb_decrypt((AES_KEY *)&aesctx->dec,
>>> -                                   src, dst, length);
>>> +    qcrypto_cipher_aes_ecb_decrypt(&aesctx->dec, src, dst, length);
>>>  }
>>>
>>>
>>>
> 

Reviewed-by: Laurent Vivier <laurent@vivier.eu>
Laurent Vivier April 3, 2020, 8:47 a.m. UTC | #5
Le 25/03/2020 à 10:21, Chen Qun a écrit :
> Fix: eaec903c5b8
> 
> Reported-by: Euler Robot <euler.robot@huawei.com>
> Signed-off-by: Chen Qun <kuhn.chenqun@huawei.com>
> ---
> Cc: "Daniel P. Berrangé" <berrange@redhat.com>
> ---
>  crypto/cipher-builtin.c | 6 ++----
>  1 file changed, 2 insertions(+), 4 deletions(-)
> 
> diff --git a/crypto/cipher-builtin.c b/crypto/cipher-builtin.c
> index bf8413e71a..99d6280a16 100644
> --- a/crypto/cipher-builtin.c
> +++ b/crypto/cipher-builtin.c
> @@ -133,8 +133,7 @@ static void qcrypto_cipher_aes_xts_encrypt(const void *ctx,
>  {
>      const QCryptoCipherBuiltinAESContext *aesctx = ctx;
>  
> -    qcrypto_cipher_aes_ecb_encrypt((AES_KEY *)&aesctx->enc,
> -                                   src, dst, length);
> +    qcrypto_cipher_aes_ecb_encrypt(&aesctx->enc, src, dst, length);
>  }
>  
>  
> @@ -145,8 +144,7 @@ static void qcrypto_cipher_aes_xts_decrypt(const void *ctx,
>  {
>      const QCryptoCipherBuiltinAESContext *aesctx = ctx;
>  
> -    qcrypto_cipher_aes_ecb_decrypt((AES_KEY *)&aesctx->dec,
> -                                   src, dst, length);
> +    qcrypto_cipher_aes_ecb_decrypt(&aesctx->dec, src, dst, length);
>  }
>  
>  
> 

Applied to my trivial-patches-for-5.1 branch.

Thanks,
Laurent
Laurent Vivier May 4, 2020, 12:36 p.m. UTC | #6
Le 03/04/2020 à 10:47, Laurent Vivier a écrit :
> Le 25/03/2020 à 10:21, Chen Qun a écrit :
>> Fix: eaec903c5b8
>>
>> Reported-by: Euler Robot <euler.robot@huawei.com>
>> Signed-off-by: Chen Qun <kuhn.chenqun@huawei.com>
>> ---
>> Cc: "Daniel P. Berrangé" <berrange@redhat.com>
>> ---
>>  crypto/cipher-builtin.c | 6 ++----
>>  1 file changed, 2 insertions(+), 4 deletions(-)
>>
>> diff --git a/crypto/cipher-builtin.c b/crypto/cipher-builtin.c
>> index bf8413e71a..99d6280a16 100644
>> --- a/crypto/cipher-builtin.c
>> +++ b/crypto/cipher-builtin.c
>> @@ -133,8 +133,7 @@ static void qcrypto_cipher_aes_xts_encrypt(const void *ctx,
>>  {
>>      const QCryptoCipherBuiltinAESContext *aesctx = ctx;
>>  
>> -    qcrypto_cipher_aes_ecb_encrypt((AES_KEY *)&aesctx->enc,
>> -                                   src, dst, length);
>> +    qcrypto_cipher_aes_ecb_encrypt(&aesctx->enc, src, dst, length);
>>  }
>>  
>>  
>> @@ -145,8 +144,7 @@ static void qcrypto_cipher_aes_xts_decrypt(const void *ctx,
>>  {
>>      const QCryptoCipherBuiltinAESContext *aesctx = ctx;
>>  
>> -    qcrypto_cipher_aes_ecb_decrypt((AES_KEY *)&aesctx->dec,
>> -                                   src, dst, length);
>> +    qcrypto_cipher_aes_ecb_decrypt(&aesctx->dec, src, dst, length);
>>  }
>>  
>>  
>>
> 
> Applied to my trivial-patches-for-5.1 branch.

Removed from the queue because of build errors:

https://travis-ci.com/github/vivier/qemu/jobs/327261040

In file included from /home/travis/build/vivier/qemu/crypto/cipher.c:157:0:
1251/home/travis/build/vivier/qemu/crypto/cipher-builtin.c: In function
‘qcrypto_cipher_aes_xts_encrypt’:
1252/home/travis/build/vivier/qemu/crypto/cipher-builtin.c:136:36:
error: passing argument 1 of ‘qcrypto_cipher_aes_ecb_encrypt’ discards
‘const’ qualifier from pointer target type [-Werror=discarded-qualifiers]
1253     qcrypto_cipher_aes_ecb_encrypt(&aesctx->enc, src, dst, length);
1254                                    ^
1255/home/travis/build/vivier/qemu/crypto/cipher-builtin.c:77:13: note:
expected ‘AES_KEY * {aka struct aes_key_st *}’ but argument is of type
‘const AES_KEY * {aka const struct aes_key_st *}’
1256 static void qcrypto_cipher_aes_ecb_encrypt(AES_KEY *key,
1257             ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
1258/home/travis/build/vivier/qemu/crypto/cipher-builtin.c: In function
‘qcrypto_cipher_aes_xts_decrypt’:
1259/home/travis/build/vivier/qemu/crypto/cipher-builtin.c:147:36:
error: passing argument 1 of ‘qcrypto_cipher_aes_ecb_decrypt’ discards
‘const’ qualifier from pointer target type [-Werror=discarded-qualifiers]
1260     qcrypto_cipher_aes_ecb_decrypt(&aesctx->dec, src, dst, length);
1261                                    ^
1262/home/travis/build/vivier/qemu/crypto/cipher-builtin.c:103:13: note:
expected ‘AES_KEY * {aka struct aes_key_st *}’ but argument is of type
‘const AES_KEY * {aka const struct aes_key_st *}’
1263 static void qcrypto_cipher_aes_ecb_decrypt(AES_KEY *key,
1264             ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
1265cc1: all warnings being treated as errors
1266/home/travis/build/vivier/qemu/rules.mak:69: recipe for target
'crypto/cipher.o' failed
1267make: *** [crypto/cipher.o] Error 1
1268make: *** Waiting for unfinished jobs....
diff mbox series

Patch

diff --git a/crypto/cipher-builtin.c b/crypto/cipher-builtin.c
index bf8413e71a..99d6280a16 100644
--- a/crypto/cipher-builtin.c
+++ b/crypto/cipher-builtin.c
@@ -133,8 +133,7 @@  static void qcrypto_cipher_aes_xts_encrypt(const void *ctx,
 {
     const QCryptoCipherBuiltinAESContext *aesctx = ctx;
 
-    qcrypto_cipher_aes_ecb_encrypt((AES_KEY *)&aesctx->enc,
-                                   src, dst, length);
+    qcrypto_cipher_aes_ecb_encrypt(&aesctx->enc, src, dst, length);
 }
 
 
@@ -145,8 +144,7 @@  static void qcrypto_cipher_aes_xts_decrypt(const void *ctx,
 {
     const QCryptoCipherBuiltinAESContext *aesctx = ctx;
 
-    qcrypto_cipher_aes_ecb_decrypt((AES_KEY *)&aesctx->dec,
-                                   src, dst, length);
+    qcrypto_cipher_aes_ecb_decrypt(&aesctx->dec, src, dst, length);
 }