Skip to contentSkip to conversation

lib/mpi: use swap() to make code cleaner

PATCH New Yang Guang 1 participant 1 message Oct 28, 2021

lore
Share & tools
lore

Yang Guang

author
#0 lore raw

PATCH 1/1 lib/mpi: use swap() to make code cleaner

Using swap() make it more readable.

---
 lib/mpi/ec.c | 6 ++----
 1 file changed, 2 insertions(+), 4 deletions(-)
lib/mpi/ec.c +2 -4
index 40f5908e57a4..a2f5694425ee 100644
@@ -1282,14 +1282,12 @@ void mpi_ec_mul_point(MPI_POINT result,
 		sum = &p2_;
 
 		for (j = nbits-1; j >= 0; j--) {
-			MPI_POINT t;
-
 			sw = mpi_test_bit(scalar, j);
 			point_swap_cond(q1, q2, sw, ctx);
 			montgomery_ladder(prd, sum, q1, q2, point->x, ctx);
 			point_swap_cond(prd, sum, sw, ctx);
-			t = q1;  q1 = prd;  prd = t;
-			t = q2;  q2 = sum;  sum = t;
+			swap(q1, prd);
+			swap(q2, sum);
 		}
 
 		mpi_clear(result->y);
Signature · 1 line
2.30.2