public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
* [PATCH] crypto: lib/mpi: delete unnecessary condition
@ 2024-07-04 15:25 Dan Carpenter
  2024-07-05  6:43 ` tianjia.zhang
  2024-07-12 23:57 ` Herbert Xu
  0 siblings, 2 replies; 3+ messages in thread
From: Dan Carpenter @ 2024-07-04 15:25 UTC (permalink / raw)
  To: Herbert Xu, Tianjia Zhang
  Cc: David S. Miller, Mimi Zohar, linux-crypto, linux-kernel,
	kernel-janitors

We checked that "nlimbs" is non-zero in the outside if statement so delete
the duplicate check here.

Signed-off-by: Dan Carpenter <dan.carpenter@linaro.org>
---
 lib/crypto/mpi/mpi-bit.c | 10 ++++------
 1 file changed, 4 insertions(+), 6 deletions(-)

diff --git a/lib/crypto/mpi/mpi-bit.c b/lib/crypto/mpi/mpi-bit.c
index 070ba784c9f1..e08fc202ea5c 100644
--- a/lib/crypto/mpi/mpi-bit.c
+++ b/lib/crypto/mpi/mpi-bit.c
@@ -212,12 +212,10 @@ void mpi_rshift(MPI x, MPI a, unsigned int n)
 			return;
 		}
 
-		if (nlimbs) {
-			for (i = 0; i < x->nlimbs - nlimbs; i++)
-				x->d[i] = x->d[i+nlimbs];
-			x->d[i] = 0;
-			x->nlimbs -= nlimbs;
-		}
+		for (i = 0; i < x->nlimbs - nlimbs; i++)
+			x->d[i] = x->d[i+nlimbs];
+		x->d[i] = 0;
+		x->nlimbs -= nlimbs;
 
 		if (x->nlimbs && nbits)
 			mpihelp_rshift(x->d, x->d, x->nlimbs, nbits);
-- 
2.43.0


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

* Re: [PATCH] crypto: lib/mpi: delete unnecessary condition
  2024-07-04 15:25 [PATCH] crypto: lib/mpi: delete unnecessary condition Dan Carpenter
@ 2024-07-05  6:43 ` tianjia.zhang
  2024-07-12 23:57 ` Herbert Xu
  1 sibling, 0 replies; 3+ messages in thread
From: tianjia.zhang @ 2024-07-05  6:43 UTC (permalink / raw)
  To: Dan Carpenter, Herbert Xu
  Cc: David S. Miller, Mimi Zohar, linux-crypto, linux-kernel,
	kernel-janitors

Hi,

On 2024/7/4 23:25, Dan Carpenter wrote:
> We checked that "nlimbs" is non-zero in the outside if statement so delete
> the duplicate check here.
>
> Signed-off-by: Dan Carpenter <dan.carpenter@linaro.org>
> ---


Reviewed-by: Tianjia Zhang <tianjia.zhang@linux.alibaba.com>


>   lib/crypto/mpi/mpi-bit.c | 10 ++++------
>   1 file changed, 4 insertions(+), 6 deletions(-)
>
> diff --git a/lib/crypto/mpi/mpi-bit.c b/lib/crypto/mpi/mpi-bit.c
> index 070ba784c9f1..e08fc202ea5c 100644
> --- a/lib/crypto/mpi/mpi-bit.c
> +++ b/lib/crypto/mpi/mpi-bit.c
> @@ -212,12 +212,10 @@ void mpi_rshift(MPI x, MPI a, unsigned int n)
>   			return;
>   		}
>   
> -		if (nlimbs) {
> -			for (i = 0; i < x->nlimbs - nlimbs; i++)
> -				x->d[i] = x->d[i+nlimbs];
> -			x->d[i] = 0;
> -			x->nlimbs -= nlimbs;
> -		}
> +		for (i = 0; i < x->nlimbs - nlimbs; i++)
> +			x->d[i] = x->d[i+nlimbs];
> +		x->d[i] = 0;
> +		x->nlimbs -= nlimbs;
>   
>   		if (x->nlimbs && nbits)
>   			mpihelp_rshift(x->d, x->d, x->nlimbs, nbits);


Cheers,

Tianjia


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

* Re: [PATCH] crypto: lib/mpi: delete unnecessary condition
  2024-07-04 15:25 [PATCH] crypto: lib/mpi: delete unnecessary condition Dan Carpenter
  2024-07-05  6:43 ` tianjia.zhang
@ 2024-07-12 23:57 ` Herbert Xu
  1 sibling, 0 replies; 3+ messages in thread
From: Herbert Xu @ 2024-07-12 23:57 UTC (permalink / raw)
  To: Dan Carpenter
  Cc: Tianjia Zhang, David S. Miller, Mimi Zohar, linux-crypto,
	linux-kernel, kernel-janitors

On Thu, Jul 04, 2024 at 10:25:05AM -0500, Dan Carpenter wrote:
> We checked that "nlimbs" is non-zero in the outside if statement so delete
> the duplicate check here.
> 
> Signed-off-by: Dan Carpenter <dan.carpenter@linaro.org>
> ---
>  lib/crypto/mpi/mpi-bit.c | 10 ++++------
>  1 file changed, 4 insertions(+), 6 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] 3+ messages in thread

end of thread, other threads:[~2024-07-12 23:57 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2024-07-04 15:25 [PATCH] crypto: lib/mpi: delete unnecessary condition Dan Carpenter
2024-07-05  6:43 ` tianjia.zhang
2024-07-12 23:57 ` Herbert Xu

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox