diff options
author | Jiapeng Chong <jiapeng.chong@linux.alibaba.com> | 2024-06-14 11:09:12 +0800 |
---|---|---|
committer | Herbert Xu <herbert@gondor.apana.org.au> | 2024-06-21 22:04:18 +1000 |
commit | b44327ebc1c926e4b55a7721e3d91313fcf188b1 (patch) | |
tree | 2726680f50a140baf8f7d9b4d42d6cab203fc233 /lib/crypto | |
parent | f0da7a231c7d0bafb6bb56da597cb2bfaf2c7028 (diff) | |
download | lwn-b44327ebc1c926e4b55a7721e3d91313fcf188b1.tar.gz lwn-b44327ebc1c926e4b55a7721e3d91313fcf188b1.zip |
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: Abaci Robot <abaci@linux.alibaba.com>
Closes: https://bugzilla.openanolis.cn/show_bug.cgi?id=9327
Signed-off-by: Jiapeng Chong <jiapeng.chong@linux.alibaba.com>
Signed-off-by: Herbert Xu <herbert@gondor.apana.org.au>
Diffstat (limited to 'lib/crypto')
-rw-r--r-- | lib/crypto/mpi/mpi-pow.c | 9 |
1 files changed, 2 insertions, 7 deletions
diff --git a/lib/crypto/mpi/mpi-pow.c b/lib/crypto/mpi/mpi-pow.c index 2fd7a46d55ec..67fbd4c2503d 100644 --- a/lib/crypto/mpi/mpi-pow.c +++ b/lib/crypto/mpi/mpi-pow.c @@ -176,7 +176,6 @@ int mpi_powm(MPI res, MPI base, MPI exp, MPI mod) for (;;) { while (c) { - mpi_ptr_t tp; mpi_size_t xsize; /*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) xsize = msize; } - tp = rp; - rp = xp; - xp = tp; + swap(rp, xp); rsize = xsize; if ((mpi_limb_signed_t) e < 0) { @@ -235,9 +232,7 @@ int mpi_powm(MPI res, MPI base, MPI exp, MPI mod) xsize = msize; } - tp = rp; - rp = xp; - xp = tp; + swap(rp, xp); rsize = xsize; } e <<= 1; |