linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] crypto: hisilicon/hpre -  use swap() to make code cleaner
@ 2021-11-04  6:19 davidcomponentone
  2021-11-04  9:34 ` liulongfang
  2021-11-20  4:29 ` Herbert Xu
  0 siblings, 2 replies; 4+ messages in thread
From: davidcomponentone @ 2021-11-04  6:19 UTC (permalink / raw)
  To: xuzaibo
  Cc: davidcomponentone, herbert, davem, linux-crypto, linux-kernel,
	Yang Guang, Zeal Robot

From: Yang Guang <yang.guang5@zte.com.cn>

Use the macro 'swap()' defined in 'include/linux/minmax.h' to avoid
opencoding it.

Reported-by: Zeal Robot <zealci@zte.com.cn>
Signed-off-by: Yang Guang <yang.guang5@zte.com.cn>
---
 drivers/crypto/hisilicon/hpre/hpre_crypto.c | 5 +----
 1 file changed, 1 insertion(+), 4 deletions(-)

diff --git a/drivers/crypto/hisilicon/hpre/hpre_crypto.c b/drivers/crypto/hisilicon/hpre/hpre_crypto.c
index a032c192ef1d..0f1724d355b8 100644
--- a/drivers/crypto/hisilicon/hpre/hpre_crypto.c
+++ b/drivers/crypto/hisilicon/hpre/hpre_crypto.c
@@ -1177,13 +1177,10 @@ static void hpre_rsa_exit_tfm(struct crypto_akcipher *tfm)
 static void hpre_key_to_big_end(u8 *data, int len)
 {
 	int i, j;
-	u8 tmp;
 
 	for (i = 0; i < len / 2; i++) {
 		j = len - i - 1;
-		tmp = data[j];
-		data[j] = data[i];
-		data[i] = tmp;
+		swap(data[j], data[i]);
 	}
 }
 
-- 
2.30.2


^ permalink raw reply related	[flat|nested] 4+ messages in thread

* Re: [PATCH] crypto: hisilicon/hpre - use swap() to make code cleaner
  2021-11-04  6:19 [PATCH] crypto: hisilicon/hpre - use swap() to make code cleaner davidcomponentone
@ 2021-11-04  9:34 ` liulongfang
  2021-11-20  4:29 ` Herbert Xu
  1 sibling, 0 replies; 4+ messages in thread
From: liulongfang @ 2021-11-04  9:34 UTC (permalink / raw)
  To: davidcomponentone, xuzaibo
  Cc: herbert, davem, linux-crypto, linux-kernel, Yang Guang, Zeal Robot

On 2021/11/4 14:19, davidcomponentone@gmail.com wrote:
> From: Yang Guang <yang.guang5@zte.com.cn>
> 
> Use the macro 'swap()' defined in 'include/linux/minmax.h' to avoid
> opencoding it.
> 
> Reported-by: Zeal Robot <zealci@zte.com.cn>
> Signed-off-by: Yang Guang <yang.guang5@zte.com.cn>
> ---
>  drivers/crypto/hisilicon/hpre/hpre_crypto.c | 5 +----
>  1 file changed, 1 insertion(+), 4 deletions(-)
> 
> diff --git a/drivers/crypto/hisilicon/hpre/hpre_crypto.c b/drivers/crypto/hisilicon/hpre/hpre_crypto.c
> index a032c192ef1d..0f1724d355b8 100644
> --- a/drivers/crypto/hisilicon/hpre/hpre_crypto.c
> +++ b/drivers/crypto/hisilicon/hpre/hpre_crypto.c
> @@ -1177,13 +1177,10 @@ static void hpre_rsa_exit_tfm(struct crypto_akcipher *tfm)
>  static void hpre_key_to_big_end(u8 *data, int len)
>  {
>  	int i, j;
> -	u8 tmp;
>  
>  	for (i = 0; i < len / 2; i++) {
>  		j = len - i - 1;
> -		tmp = data[j];
> -		data[j] = data[i];
> -		data[i] = tmp;
> +		swap(data[j], data[i]);
>  	}
>  }
>  >
OK!
Thanks.

Longfang.

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [PATCH] crypto: hisilicon/hpre -  use swap() to make code cleaner
  2021-11-04  6:19 [PATCH] crypto: hisilicon/hpre - use swap() to make code cleaner davidcomponentone
  2021-11-04  9:34 ` liulongfang
@ 2021-11-20  4:29 ` Herbert Xu
  1 sibling, 0 replies; 4+ messages in thread
From: Herbert Xu @ 2021-11-20  4:29 UTC (permalink / raw)
  To: davidcomponentone
  Cc: xuzaibo, davem, linux-crypto, linux-kernel, Yang Guang, Zeal Robot

On Thu, Nov 04, 2021 at 02:19:10PM +0800, davidcomponentone@gmail.com wrote:
> From: Yang Guang <yang.guang5@zte.com.cn>
> 
> Use the macro 'swap()' defined in 'include/linux/minmax.h' to avoid
> opencoding it.
> 
> Reported-by: Zeal Robot <zealci@zte.com.cn>
> Signed-off-by: Yang Guang <yang.guang5@zte.com.cn>
> ---
>  drivers/crypto/hisilicon/hpre/hpre_crypto.c | 5 +----
>  1 file changed, 1 insertion(+), 4 deletions(-)

Patch applied.  Thanks.
-- 
Email: Herbert Xu <herbert@gondor.apana.org.au>
Home Page: http://gondor.apana.org.au/~herbert/
PGP Key: http://gondor.apana.org.au/~herbert/pubkey.txt

^ permalink raw reply	[flat|nested] 4+ messages in thread

* [PATCH] crypto: hisilicon/hpre - use swap() to make code cleaner
@ 2021-10-28 11:04 cgel.zte
  0 siblings, 0 replies; 4+ messages in thread
From: cgel.zte @ 2021-10-28 11:04 UTC (permalink / raw)
  To: herbert; +Cc: davem, linux-crypto, linux-kernel, Changcheng Deng, Zeal Robot

From: Changcheng Deng <deng.changcheng@zte.com.cn>

Use swap() in order to make code cleaner. Issue found by coccinelle.

Reported-by: Zeal Robot <zealci@zte.com.cn>
Signed-off-by: Changcheng Deng <deng.changcheng@zte.com.cn>
---
 drivers/crypto/hisilicon/hpre/hpre_crypto.c | 5 +----
 1 file changed, 1 insertion(+), 4 deletions(-)

diff --git a/drivers/crypto/hisilicon/hpre/hpre_crypto.c b/drivers/crypto/hisilicon/hpre/hpre_crypto.c
index a032c192ef1d..f7957197ef10 100644
--- a/drivers/crypto/hisilicon/hpre/hpre_crypto.c
+++ b/drivers/crypto/hisilicon/hpre/hpre_crypto.c
@@ -1177,13 +1177,10 @@ static void hpre_rsa_exit_tfm(struct crypto_akcipher *tfm)
 static void hpre_key_to_big_end(u8 *data, int len)
 {
 	int i, j;
-	u8 tmp;
 
 	for (i = 0; i < len / 2; i++) {
 		j = len - i - 1;
-		tmp = data[j];
-		data[j] = data[i];
-		data[i] = tmp;
+		swap(data[i], data[j]);
 	}
 }
 
-- 
2.25.1


^ permalink raw reply related	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2021-11-20  4:29 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-11-04  6:19 [PATCH] crypto: hisilicon/hpre - use swap() to make code cleaner davidcomponentone
2021-11-04  9:34 ` liulongfang
2021-11-20  4:29 ` Herbert Xu
  -- strict thread matches above, loose matches on Subject: below --
2021-10-28 11:04 cgel.zte

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).