2021-11-04 06:20:06

by David Yang

[permalink] [raw]
Subject: [PATCH] crypto: hisilicon/hpre - use swap() to make code cleaner

From: Yang Guang <[email protected]>

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

Reported-by: Zeal Robot <[email protected]>
Signed-off-by: Yang Guang <[email protected]>
---
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


2021-11-04 09:34:55

by liulongfang

[permalink] [raw]
Subject: Re: [PATCH] crypto: hisilicon/hpre - use swap() to make code cleaner

On 2021/11/4 14:19, [email protected] wrote:
> From: Yang Guang <[email protected]>
>
> Use the macro 'swap()' defined in 'include/linux/minmax.h' to avoid
> opencoding it.
>
> Reported-by: Zeal Robot <[email protected]>
> Signed-off-by: Yang Guang <[email protected]>
> ---
> 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.

2021-11-20 04:29:20

by Herbert Xu

[permalink] [raw]
Subject: Re: [PATCH] crypto: hisilicon/hpre - use swap() to make code cleaner

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

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