diff mbox series

crypto: lib/mpi: delete unnecessary condition

Message ID 6686bed3.4a0a0220.6aa45.6c34@mx.google.com (mailing list archive)
State Accepted
Delegated to: Herbert Xu
Headers show
Series crypto: lib/mpi: delete unnecessary condition | expand

Commit Message

Dan Carpenter July 4, 2024, 3:25 p.m. UTC
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(-)

Comments

tianjia.zhang July 5, 2024, 6:43 a.m. UTC | #1
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
Herbert Xu July 12, 2024, 11:57 p.m. UTC | #2
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.
diff mbox series

Patch

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);