Commit b44327eb authored by Jiapeng Chong's avatar Jiapeng Chong Committed by Herbert Xu

crypto: lib/mpi - Use swap() in mpi_powm()

Use existing swap() function rather than duplicating its implementation.

./lib/crypto/mpi/mpi-pow.c:211:11-12: WARNING opportunity for swap().
./lib/crypto/mpi/mpi-pow.c:239:12-13: WARNING opportunity for swap().
Reported-by: default avatarAbaci Robot <abaci@linux.alibaba.com>
Closes: https://bugzilla.openanolis.cn/show_bug.cgi?id=9327Signed-off-by: default avatarJiapeng Chong <jiapeng.chong@linux.alibaba.com>
Signed-off-by: default avatarHerbert Xu <herbert@gondor.apana.org.au>
parent f0da7a23
...@@ -176,7 +176,6 @@ int mpi_powm(MPI res, MPI base, MPI exp, MPI mod) ...@@ -176,7 +176,6 @@ int mpi_powm(MPI res, MPI base, MPI exp, MPI mod)
for (;;) { for (;;) {
while (c) { while (c) {
mpi_ptr_t tp;
mpi_size_t xsize; mpi_size_t xsize;
/*if (mpihelp_mul_n(xp, rp, rp, rsize) < 0) goto enomem */ /*if (mpihelp_mul_n(xp, rp, rp, rsize) < 0) goto enomem */
...@@ -207,9 +206,7 @@ int mpi_powm(MPI res, MPI base, MPI exp, MPI mod) ...@@ -207,9 +206,7 @@ int mpi_powm(MPI res, MPI base, MPI exp, MPI mod)
xsize = msize; xsize = msize;
} }
tp = rp; swap(rp, xp);
rp = xp;
xp = tp;
rsize = xsize; rsize = xsize;
if ((mpi_limb_signed_t) e < 0) { if ((mpi_limb_signed_t) e < 0) {
...@@ -235,9 +232,7 @@ int mpi_powm(MPI res, MPI base, MPI exp, MPI mod) ...@@ -235,9 +232,7 @@ int mpi_powm(MPI res, MPI base, MPI exp, MPI mod)
xsize = msize; xsize = msize;
} }
tp = rp; swap(rp, xp);
rp = xp;
xp = tp;
rsize = xsize; rsize = xsize;
} }
e <<= 1; e <<= 1;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment