[PATCH] lib/bch:using swap() instead of tmp variable
From: Yihao Han
Date: Tue Nov 09 2021 - 01:19:17 EST
swap() was used instead of the tmp variable to swap values
Signed-off-by: Yihao Han <hanyihao@xxxxxxxx>
---
lib/bch.c | 16 ++++------------
1 file changed, 4 insertions(+), 12 deletions(-)
diff --git a/lib/bch.c b/lib/bch.c
index c8095f30f254..0d6a2942ad20 100644
--- a/lib/bch.c
+++ b/lib/bch.c
@@ -500,7 +500,7 @@ static int solve_linear_system(struct bch_control *bch, unsigned int *rows,
unsigned int *sol, int nsol)
{
const int m = GF_M(bch);
- unsigned int tmp, mask;
+ unsigned int mask;
int rem, c, r, p, k, param[BCH_MAX_M];
k = 0;
@@ -514,9 +514,7 @@ static int solve_linear_system(struct bch_control *bch, unsigned int *rows,
for (r = p; r < m; r++) {
if (rows[r] & mask) {
if (r != p) {
- tmp = rows[r];
- rows[r] = rows[p];
- rows[p] = tmp;
+ swap(rows[r],rows[p]);
}
rem = r+1;
break;
@@ -833,21 +831,15 @@ static void gf_poly_div(struct bch_control *bch, struct gf_poly *a,
static struct gf_poly *gf_poly_gcd(struct bch_control *bch, struct gf_poly *a,
struct gf_poly *b)
{
- struct gf_poly *tmp;
-
dbg("gcd(%s,%s)=", gf_poly_str(a), gf_poly_str(b));
if (a->deg < b->deg) {
- tmp = b;
- b = a;
- a = tmp;
+ swap(b,a);
}
while (b->deg > 0) {
gf_poly_mod(bch, a, b, NULL);
- tmp = b;
- b = a;
- a = tmp;
+ swap(b,a);
}
dbg("%s\n", gf_poly_str(a));
--
2.17.1