]> git.ipfire.org Git - thirdparty/kernel/linux.git/commitdiff
crypto: lib/mpi - Use swap() in mpi_powm()
authorJiapeng Chong <jiapeng.chong@linux.alibaba.com>
Fri, 14 Jun 2024 03:09:12 +0000 (11:09 +0800)
committerHerbert Xu <herbert@gondor.apana.org.au>
Fri, 21 Jun 2024 12:04:18 +0000 (22:04 +1000)
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>
lib/crypto/mpi/mpi-pow.c

index 2fd7a46d55ecc70813b9cf64314d17e890f0ff65..67fbd4c2503d08e5e8f63c0e59810d053362bce5 100644 (file)
@@ -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;