diff mbox

[6/7] crypto: remove useless casts

Message ID 1466007277-17525-7-git-send-email-lvivier@redhat.com
State New
Headers show

Commit Message

Laurent Vivier June 15, 2016, 4:14 p.m. UTC
This patch is the result of coccinelle script
scripts/coccinelle/typecast.cocci

CC: Daniel P. Berrange <berrange@redhat.com>
Signed-off-by: Laurent Vivier <lvivier@redhat.com>
---
 crypto/cipher-builtin.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

Comments

Daniel P. Berrangé June 23, 2016, 11:07 a.m. UTC | #1
On Wed, Jun 15, 2016 at 06:14:36PM +0200, Laurent Vivier wrote:
> This patch is the result of coccinelle script
> scripts/coccinelle/typecast.cocci
> 
> CC: Daniel P. Berrange <berrange@redhat.com>
> Signed-off-by: Laurent Vivier <lvivier@redhat.com>
> ---
>  crypto/cipher-builtin.c | 4 ++--
>  1 file changed, 2 insertions(+), 2 deletions(-)
> 
> diff --git a/crypto/cipher-builtin.c b/crypto/cipher-builtin.c
> index 88963f6..d791c80 100644
> --- a/crypto/cipher-builtin.c
> +++ b/crypto/cipher-builtin.c
> @@ -132,7 +132,7 @@ static void qcrypto_cipher_aes_xts_encrypt(const void *ctx,
>  {
>      const QCryptoCipherBuiltinAESContext *aesctx = ctx;
>  
> -    qcrypto_cipher_aes_ecb_encrypt((AES_KEY *)&aesctx->enc,
> +    qcrypto_cipher_aes_ecb_encrypt(&aesctx->enc,
>                                     src, dst, length);
>  }
>  
> @@ -144,7 +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,
> +    qcrypto_cipher_aes_ecb_decrypt(&aesctx->dec,
>                                     src, dst, length);
>  }

Reviewed-by: Daniel P. Berrange <berrange@redhat.com>

I'm fine with this going in via qemu-trivial.

Regards,
Daniel
Michael Tokarev Sept. 14, 2016, 7:40 a.m. UTC | #2
15.06.2016 19:14, Laurent Vivier пишет:
> This patch is the result of coccinelle script
> scripts/coccinelle/typecast.cocci
>
> CC: Daniel P. Berrange <berrange@redhat.com>
> Signed-off-by: Laurent Vivier <lvivier@redhat.com>
> ---
>  crypto/cipher-builtin.c | 4 ++--
>  1 file changed, 2 insertions(+), 2 deletions(-)
>
> diff --git a/crypto/cipher-builtin.c b/crypto/cipher-builtin.c
> index 88963f6..d791c80 100644
> --- a/crypto/cipher-builtin.c
> +++ b/crypto/cipher-builtin.c
> @@ -132,7 +132,7 @@ static void qcrypto_cipher_aes_xts_encrypt(const void *ctx,
>  {
>      const QCryptoCipherBuiltinAESContext *aesctx = ctx;
>
> -    qcrypto_cipher_aes_ecb_encrypt((AES_KEY *)&aesctx->enc,
> +    qcrypto_cipher_aes_ecb_encrypt(&aesctx->enc,
>                                     src, dst, length);
>  }
>
> @@ -144,7 +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,
> +    qcrypto_cipher_aes_ecb_decrypt(&aesctx->dec,
>                                     src, dst, length);
>  }

This patch causes the following build failure:

   CC    crypto/block.o
In file included from 
/build/qemu/git/crypto/cipher.c:156:0:crypto/cipher-builtin.c: In 
function ‘qcrypto_cipher_aes_xts_encrypt’:
crypto/cipher-builtin.c:135:36: error: passing argument 1 of 
‘qcrypto_cipher_aes_ecb_encrypt’ discards ‘const’ qualifier from pointer 
target type [-Werror]
      qcrypto_cipher_aes_ecb_encrypt(&aesctx->enc,
                                     ^
crypto/cipher-builtin.c:76:13: note: expected ‘struct AES_KEY *’ but 
argument is of type ‘const struct AES_KEY *’
  static void qcrypto_cipher_aes_ecb_encrypt(AES_KEY *key,
              ^
crypto/cipher-builtin.c: In function ‘qcrypto_cipher_aes_xts_decrypt’:
crypto/cipher-builtin.c:147:36: error: passing argument 1 of 
‘qcrypto_cipher_aes_ecb_decrypt’ discards ‘const’ qualifier from pointer 
target type [-Werror]
      qcrypto_cipher_aes_ecb_decrypt(&aesctx->dec,
                                     ^
crypto/cipher-builtin.c:102:13: note: expected ‘struct AES_KEY *’ but 
argument is of type ‘const struct AES_KEY *’
  static void qcrypto_cipher_aes_ecb_decrypt(AES_KEY *key,
              ^
cc1: all warnings being treated as errors

It's interesting that the qemu functions accepts const argument,
while apparently this is wrong, as qcrypto functions modifies their
args.  Looks like a bug either in qemu or qcrypto... :)

I'll reverted this change for now.

Thanks,

/mjt
diff mbox

Patch

diff --git a/crypto/cipher-builtin.c b/crypto/cipher-builtin.c
index 88963f6..d791c80 100644
--- a/crypto/cipher-builtin.c
+++ b/crypto/cipher-builtin.c
@@ -132,7 +132,7 @@  static void qcrypto_cipher_aes_xts_encrypt(const void *ctx,
 {
     const QCryptoCipherBuiltinAESContext *aesctx = ctx;
 
-    qcrypto_cipher_aes_ecb_encrypt((AES_KEY *)&aesctx->enc,
+    qcrypto_cipher_aes_ecb_encrypt(&aesctx->enc,
                                    src, dst, length);
 }
 
@@ -144,7 +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,
+    qcrypto_cipher_aes_ecb_decrypt(&aesctx->dec,
                                    src, dst, length);
 }